Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@brighthustle/adonisjs-whatsapp
Advanced tools
Readme
This package makes it easy for developers to access the WhatsApp Cloud API service in the AdonisJS 5 application.
Please create and configure your Facebook WhatsApp application by following the "Get Started" section of the official guide.
For AdonisJS v5 use 1.x branchInstall the package using npm or yarn:
npm i @brighthustle/adonisjs-whatsapp
# or
yarn add @brighthustle/adonisjs-whatsapp
Then, configure the package using the configure command:
node ace configure @brighthustle/adonisjs-whatsapp
After executing the above command, a config/whatsapp.ts
file will be created, where you can define the WhatsApp Cloud API.
An important step is to set environment variables in your .env
and validate them in the env.ts
file.
WABA_PHONE_ID: Env.schema.string(),
WABA_ID: Env.schema.string(),
WABA_TOKEN: Env.schema.string(),
WABA_VERIFY: Env.schema.string(),
To send text, images, and more, use the same singleton in your preload, controller or service file.
// app/controllers/example_controller.ts
import whatsapp from '@brighthustle/adonisjs-whatsapp/services/main'
import type { HttpContext } from '@adonisjs/core/http'
export default class ExampleController {
public async example(ctx: HttpContext) {
await whatsapp.sendText(0000000000, 'Lorem ipsum dolor sit amet.', {}, 1)
}
}
The last parameter, in this case, 1, is required when the configuration provider is set to lucid
. It represents the data ID and is used to associate the message with a specific context when using the Lucid database provider.
Make sure to fetch the parameters from database
according to your specific use case and configuration.
The package supports events that are triggered when receiving a webhook from WhatsApp, some of which can be seen here.
The event can be subscribed to via the start/whatsapp.ts file. It have phoneNumberId which can be used to identify the message is sent for which user.
To handle incoming WhatsApp messages in your AdonisJS application, you can subscribe to the message:text
and other event using the start/whatsapp.ts
file. This event provides a WhatsAppMessageContract
object, which contains information about the incoming message.
// start/whatsapp.ts
import whatsapp from '@brighthustle/adonisjs-whatsapp/services/main'
import { WhatsAppMessageContract } from '@brighthustle/adonisjs-whatsapp/types'
whatsapp.on('message:text', function (message: WhatsAppMessageContract) {
// TODO: do whatever you want
// Example: Identify the user by phoneNumberId
const userPhoneNumberId = message.phoneNumberId;
console.log(`Received a text message for user with phoneNumberId: ${userPhoneNumberId}`);
// TODO: Add your custom logic to handle the message
})
Please see the CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see LICENSE file for more information.
This package is not officially maintained by Facebook. WhatsApp and Facebook trademarks and logos are the property of Meta Platforms, Inc.
This package is modified from the original package https://github.com//adonisjs-whatsapp Written By : sooluh
FAQs
Connect your WhatsApp Cloud API with AdonisJS
The npm package @brighthustle/adonisjs-whatsapp receives a total of 0 weekly downloads. As such, @brighthustle/adonisjs-whatsapp popularity was classified as not popular.
We found that @brighthustle/adonisjs-whatsapp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.