npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

adonisjs-whatsapp

v0.2.6

Published

Connect your WhatsApp Cloud API with AdonisJS

Downloads

66

Readme

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.string(),
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

  • [x] Mark messages as read
  • [x] Upload media to the WhatsApp server
  • [x] Download media from the WhatsApp server
  • [x] Send text messages
  • [x] Send images
  • [x] Send documents
  • [x] Send audios
  • [x] Send videos
  • [x] Send stickers
  • [x] Send locations
  • [x] Send template messages
  • [x] Send contacts
  • [x] Send reply button messages
  • [x] Send list messages
  • [x] Include a Webhook Endpoint 
  • [x] 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.