-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add whatsapp twilio provider with templates (#229)
- Loading branch information
LakshayaT
authored
May 2, 2024
1 parent
78de757
commit a646684
Showing
14 changed files
with
460 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## Twilio WhatsApp (Business) | ||
|
||
Using the WhatsApp Business Platform with Twilio, you can send and receive messages to WhatsApp users using the same Twilio Messaging APIs you already know and enjoy. Dive into the Twilio SDKs and helper libraries, see the quickstart and API reference docs, read through guides on templates and Twilio phone numbers, and find the sample code you'll need. | ||
|
||
This particular provider can be used to send WhatsApp messages generated using Content Template Builder. | ||
|
||
### Values to Update in Database | ||
|
||
When using Twilio to send WhatsApp messages via their API/Client, you need to provide certain variables that hold the Twilio configuration details. Here are the values you need to update in table `notify_providers`: | ||
|
||
Create a new entry in table `notify_providers` and set the fields - `name`, `application_id`, `user_id` | ||
|
||
- Set field `channel_type` = 7 (for Twilio WhatsApp (Business)) | ||
- Set field `is_enabled` = 1 (to enable the newly created provider) | ||
|
||
Then set the following configurations in the `configuration` field: | ||
|
||
| Key | Description | | ||
| --------------------- | ---------------------- | | ||
| TWILIO_WA_ACCOUNT_SID | Twilio SMS account SID | | ||
| TWILIO_WA_AUTH_TOKEN | Twilio SMS auth token | | ||
|
||
```jsonc | ||
// Sample json to set in configuration field | ||
{ | ||
"TWILIO_WA_ACCOUNT_SID": "ACXXXXXXXXXXXXXXXXX", | ||
"TWILIO_WA_AUTH_TOKEN": "someauthtoken", | ||
} | ||
``` | ||
|
||
### Sample Request Body | ||
|
||
Here's a sample request body: | ||
|
||
```jsonc | ||
{ | ||
// Set your respective providerId. channelType associated with providerId should be 7 (Twilio WhatsApp (Business)) | ||
"providerId": 7, | ||
"data": { | ||
"contentSid": "HXXXXXXXXX", | ||
"from": "MGXXXXXXXX", | ||
"contentVariables": { | ||
"1": "Name", | ||
"2": "52", // Numbers should also be strings | ||
}, | ||
"to": "+919004812051", | ||
}, | ||
} | ||
``` | ||
|
||
References | ||
|
||
- [Twilio - Send templates created with the content template builder](https://www.twilio.com/docs/content/send-templates-created-with-the-content-template-builder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ export const ChannelType = { | |
WA_TWILIO: 4, | ||
SMS_TWILIO: 5, | ||
SMS_PLIVO: 6, | ||
WA_TWILIO_BUSINESS: 7, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.