Skip to content

0426abhishek/whatsapp-business-api

Repository files navigation

Whatsapp Business API

Implementation node js script to send text messages and create template to the user using whatsapp service.


Setup

Before you start the project, make sure you have the whatsapp account set up. You can use this link to sign in: https://developers.facebook.com/apps/.

Once you have the whatsapp account set up, enter the API_KEY, APP_NAME and SOURCE_MOBILE_NUMBER in .env file. If using the test account, then SOURCE_MOBILE_NUMBER would be 917834811114.


Installation

Once set up is done. Run the following command to start the server.

npm install
npm start

The server will run on port 3000.


getTemplatesList

Api to get the list of templates available.

  • Type: 'GET'
  • Response OK Status: 200

markUserOptIn

Api to mark user opt in for sending the whatsapp message.

  • Type: 'GET'
  • Content Type: 'application/json'
  • Params:
    • mobileNumber: string
  • Response OK Status: 200

sendMediaImageMessage

Api to send image along with the caption.

  • Type: 'GET'
  • Content Type: 'application/json'
  • Params:
    • mobileNumber: string
    • imageUrl: string(public available image url)
    • caption: string
  • Response OK Status: 200

sendMediaVideoMessage

Api to send video along with the caption.

  • Type: 'GET'
  • Content Type: 'application/json'
  • Params:
    • mobileNumber: string
    • videoUrl: string(public available video url)
    • caption: string
  • Response OK Status: 200

sendTextMessage

Api to send text message.

  • Type: 'GET'
  • Content Type: 'application/json'
  • Params:
    • mobileNumber: string
    • message: string(4096 characters limit)
  • Response OK Status: 200

sendTemplateMessage

Api to send templated text message.

  • Type: 'GET'
  • Content Type: 'application/json'
  • Params:
    • mobileNumber: string
    • templateId: string
    • templateParams: array of string containing data for each param
    • message: string(4096 characters limit)/object
  • Response OK Status: 200

Bulk Scripts

Before you run the script, make sure that you have the user details in csv format having first column to be name and other column to be mobileNumber. You can take at the example file in assets folder(/assets/contactDetails.csv)

Bulk OptIn

To run the script, type

node run bulkOptIn

The output of the script file will be stored in results/bulkOptInResults.json file.

Bulk Send

To run the script, type

node run bulkSend

The output of the script file will be stored in results/bulkSendResults.json file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published