Twilio is a service that gives you the capabilities of SMS, voice calls, and messaging. This integration with SubscriptionFlow allows you to send notifications and automate communication workflows with Twilios powerful API. Perfect for enhancing customer engagement and real-time interactions.
Integration Installation and Setting up:
Goto admin dashboard and proceed to the Apps section. There scroll down till you find the communication section and select Twilio
Next goto the twilio console and on the main dashboard, copy the Account SID and the Auth Token and paste it in the Twilio integration section on SubscriptionFlow.
After successful installation, go over to the admin dashboard, to preferences, click the ‘More’ tab and scroll down till you find the ‘Chat Preference’ section. Enable it and save.
Managing Customer Consent for Messaging (Whatsapp):
Due to the compliance protocol for whatsapp. We must obtain the opt in consent from the recipient of the whatsapp messages. This can be managed through the SubscriptionFlow chat APIs.
Get your Auth Tokens
Before utilizing SubscriptionFlow APIs, you must obtain the Auth Tokens. Request for getting Bearer Token can be made after getting the client ID and client secret from your account by going to the link here.
Endpoint for opting in for messages:
https://{{domain_name}}/api/v1/chat/subscribe
Endpoint for opting out for messages:
https://{{domain_name}}/api/v1/chat/unsubscribe
Curl Example
Please note the recipient id in the case of the customer will be the customer id
curl --location 'http://apptesting.sflocal.test/api/v1/chat/subscribe' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"recipient_id":"6fb168d9-d864-4229-a0ca-534179d59729",
"recipient_phone":"+923194484802",
"recipient_type":"Customer"
}'
Postman Example
To enable customer messaging, we must obtain the customer id and their phone number to which the messages will be sent.
The following is a postman example for the sake of testing. You may wish to utilize the endpoint during a consent form, through emails, through checkouts, where the customer has agreed to receive whatsapp messages.
You must also provide the customer a way to opt out of the messaging service. For that, you just need to send in the recipient phone :
Twilio Sandbox Testing
Please note that all of the examples shown below will be done using the twilio sandbox. To officially start sending whatsapp messages with real customers/clients you must register a proper whatsapp sender. (Read More)
You can access twilio sandbox testing by going over to Messaging,and then going to the whatsapp section in ‘try it out’. In order to test without setting up a whatsapp sender, you need to first join the twilio messaging chat (or by scanning the QR code on the device you want to test with)
To ensure that SubscriptionFlow is able to interact with the sandbox as well, head over to the Twilio integration page and ensure that the default whatsapp sender is registered and it's the same number shown on the sandbox page.
Sending Messages To Customers - Manually (Whatsapp):
To begin sending messages, we must understand that whatsapp messaging from businesses requires a prepared template to be sent as the first message. (Read More).
To send a prepared message template we must have it approved by both Twilio and Whatsapp. To begin creating a template, head over to the twilio console, messaging, content template builder.
While creating the message template, you can add dynamic text using variables like so. These can be populated within SubscriptionFlow, such as adding the Customer name in a message template (discussed later)
Make sure to add the content SID given on the template builder in the twilio console
Now go over to the Twilio integration page and import the template by clicking the ‘Add template’ button.
It is also recommended to add ‘Twilio’ in the template name to not mix it with non twilio templates
Once the template is successfully imported, you can add the contents of the variables. This can be done by either writing the variables content yourself
Or dynamically adding placeholders from the dropdown, depending on the type of message/module its imported as
Now to send customers/clients messages manually, you must goto their detail page (or view them in the customer section). If you have enabled the chat feature, you may be able to begin sending messages by clicking the chat icon :
In the send message section, you will be able to select the template you imported (if it was imported as a ‘Customer’ template)
If the message is sent, you can view it by going to the chats section in the customer details. Unsuccessful messages are also added here for reference or for debugging problems.
Please note that these tests are done via sandbox testing. If you are testing via sandbox and you have not received messages, please make sure that :
- You have scanned the QR code on the device you want to test with and that you send a message to the Twilio chat : ‘join - XXXX’ (shown on the sandbox page)
- The customer you are testing with has the same number as your device.
- The default number on the twilio integration page is the same as the one shown on the sandbox page.
- The variable content you added, is saved properly
Additionally, whatsapp sandbox allows us to send templates that are not approved/ still waiting but on a real whatsapp sender, the message template must be approved before it is sent.
Sending Messages To Customers - Automated (Whatsapp):
Please make sure you read through the section for sending messages manually as it covers key concepts when it comes to sending messages through whatsapp.
For the sake of simplicity we will send an automated message whenever a customer billing address is updated
Automating messages through SubscriptionFlow is relatively streamlined if you are familiar with workflows. Head over to the workflow section from the admin dashboard. Add a new workflow
In the enrollment trigger section we will add that we want to check if a customers ‘billing address’ field is updated :
Next we will add a send message section
To make sure we send the notice to the Customers phone, we must select the target record phone number which represents the Customer. After that save the workflow
Thus in summary, we have created an automated workflow that will send messages to customers who have their billing address updated :
In the history section, we can observe that the message was indeed queued once we changed the customer's billing address.
And in the Chats section under customer details we can see the message sent:
Comments
0 comments
Please sign in to leave a comment.