Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brighthustle/adonisjs-whatsapp

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brighthustle/adonisjs-whatsapp

Connect your WhatsApp Cloud API with AdonisJS

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

adonisjs-whatsapp

What's this

This package makes it easy for developers to access the WhatsApp Cloud API service in the AdonisJS 5 application.

Getting Started

Please create and configure your Facebook WhatsApp application by following the "Get Started" section of the official guide.

Setup

Install the package using npm or yarn:

npm i adonisjs-whatsapp
# or
yarn add adonisjs-whatsapp

Then, configure the package using the configure command:

node ace configure 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_ID: Env.schema.number(),
WABA_TOKEN: Env.schema.string(),
WABA_VERIFY: Env.schema.string(),

Usage

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.

// start/whatsapp.ts

import WhatsApp from '@ioc:Adonis/Addons/WhatsApp'

WhatsApp.on('message:text', function (message) {
  // TODO: do whatever you want
})

To send text, images, and more, use the same singleton in your preload or controller file.

// app/Controllers/Http/ExampleController.ts

import WhatsApp from '@ioc:Adonis/Addons/WhatsApp'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'

export default class ExampleController {
  public async example(_ctx: HttpContextContract) {
    await WhatsApp.sendText(628123456789, 'Lorem ipsum dolor sit amet.')
  }
}

Features

  • Mark messages as read
  • Upload media to the WhatsApp server
  • Download media from the WhatsApp server
  • Send text messages
  • Send images
  • Send documents
  • Send audios
  • Send videos
  • Send stickers
  • Send locations
  • Send template messages
  • Send contacts
  • Send reply button messages
  • Send list messages
  • Include a Webhook Endpoint
  • Event listener when receiving a webhook

Changelog

Please see the CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see LICENSE file for more information.

Disclaimer

This package is not officially maintained by Facebook. WhatsApp and Facebook trademarks and logos are the property of Meta Platforms, Inc.

Keywords

FAQs

Package last updated on 16 Aug 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc