SMS Opt-Out Keywords
UpdatedWhile opt-out keywords like STOP
and UNSUBSCRIBE
let people change their subscription preferences in Twilio, Customer.io doesn’t receive SMS replies directly. But, you can create a webhook-triggered campaign to send unsubscribe information from Twilio to Customer.io so you can reflect and respect your audience’s messaging preferences and privacy in Customer.io.
Webhook triggers can do more than help with Twilio!
Webhook-triggered campaigns let you trigger campaigns when something happens in another system—not just Twilio! You can even relate data to people in one-to-many style operations. See our webhook-triggered campaign page to learn more about how you can take advantage of webhook-triggered campaigns
How it works
To handle opt-out keywords, we’ll create a webhook-triggered campaign. When someone sends an incoming message to your Twilio sender, Twilio will send a webhook to Customer.io. If the webhook payload contains an OptOutKeyword
property, indicating that the customer wants to opt-out of messages, we’ll set the appropriate person’s sms_unsubscribe
attribute to true
.
incoming SMS Message]-->b[Twilio sends webhook
to Customer.io] b-->c subgraph z [Customer.io Campaign] c{Does webhook contain
opt out keyword?}-->|yes|d{does phone number match
someone in your audience?} d-->|yes|e[Set
sms_unsubscribe
to
true
on person]
c-.->|no|f[do nothing]
d-.->|no|f
endSet up a campaign to handle opt-out keywords
This process requires Twilio’s Advanced Opt-Out feature. This feature lets you customize your response to inbound messages—like setting the sms_unsubscribe
attribute on your audience in Customer.io! If you haven’t already enabled this setting, we’ll tell you how as a part of this process.
In Customer.io, go to Campaigns and click Create Campaign.
In the trigger step, click Data arrives via webhook and click Copy to copy the Webhook URL.
In Twilio, go to Phone Numbers > Active numbers, scroll down to the Messaging section, and paste the URL you copied in the previous step under A MESSAGE COMES IN.
(Optional, recommended) Using a test number, send an incoming message to your SMS sender number containing an opt out keyword. This simulated response populates a payload in Customer.io that shows the information that Twilio forwards to us when you receive an incoming message. We’re going to use the
OptOutType
to populate our campaign.Go to the Workflow step of the campaign and add a True/False Branch to your workflow. Click the branch and give it a name; in our example, we’ve called it “Unsubscribed”.
Click Add condition. For the trigger attribute, type
OptOutType
and set the condition to exists. Click Save.Drag Batch Update into the True side of your branch. Despite it being a batch update, we’re only using this action to set the
sms_unsubscribe
attribute for the individual recipient of each message. Your workflow will look like this:Click the action and click Add Details.
For Who do you want to update, click Add attribute condition and set the profile attributeA key-value pair that you associate with a person or an object—like a person’s name, the date they were created in your workspace, or a company’s billing date etc. Use attributes to target people and personalize messages. Attributes are analogous to traits in Data Pipelines. containing your audience’s phone number to the
From
value in the Trigger data.Under Which attributes do you want to add, change, or remove, set the
sms_unsubscribe
attribute to the Static value true.Save the batch update action, and then save and start your campaign.
Now, when people opt-out of SMS messages with an incoming opt-out keyword, we’ll reflect their opt out status appropriately in Customer.io.