Implementation node js script to send text messages and create template to the user using whatsapp service.
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
.
Once set up is done. Run the following command to start the server.
npm install
npm start
The server will run on port 3000.
Api to get the list of templates available.
- Type: 'GET'
- Response OK Status: 200
Api to mark user opt in for sending the whatsapp message.
- Type: 'GET'
- Content Type: 'application/json'
- Params:
- mobileNumber: string
- Response OK Status: 200
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
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
Api to send text message.
- Type: 'GET'
- Content Type: 'application/json'
- Params:
- mobileNumber: string
- message: string(4096 characters limit)
- Response OK Status: 200
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
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)
To run the script, type
node run bulkOptIn
The output of the script file will be stored in results/bulkOptInResults.json file.
To run the script, type
node run bulkSend
The output of the script file will be stored in results/bulkSendResults.json file.