Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Customizing Users’ Opt-in and Opt-out Experience with Advanced Opt-Out


In this tutorial, we will set up opt-in, opt-out, and help keywords and confirmation messages with the Advanced Opt-Out feature of Messaging Services. Configuring these keywords is an effective way to localize the experience for your customers and end users all over the world.

Twilio, by default, handles standard English-language reply messages such as STOP, UNSTOP, UNSUBSCRIBE or CANCEL for Toll-Free and Long Code numbers, in accordance with industry standards. (Please consult our support documentation on Twilio's support for opt-out keywords(link takes you to an external page) for more.)

This guide covers customizing opt-in/opt-out keywords and messages for your Messaging Service using the Advanced Opt-Out feature.


Create a Messaging Service

create-a-messaging-service page anchor
(information)

Info

If you already have set up your Messaging Service, skip ahead to enabling Advanced Opt-Out for your Messaging Service.

Global opt-in and opt-out keywords are a feature of Twilio Messaging Services. A Messaging Service is a higher-level "bundling" of messaging functionality around a common set of senders, features, and configuration.

If you haven't already done so, create a new Messaging Service:

Create a Messaging Service

create-a-messaging-service-1 page anchor

Create a Messaging Service and give it a name

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.messaging.v1.services
_10
.create({friendlyName: 'My First Messaging Service'})
_10
.then(service => console.log(service.sid));

Output

_33
{
_33
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_33
"date_created": "2015-07-30T20:12:31Z",
_33
"date_updated": "2015-07-30T20:12:33Z",
_33
"friendly_name": "My First Messaging Service",
_33
"inbound_request_url": "https://www.example.com/",
_33
"inbound_method": "POST",
_33
"fallback_url": "https://www.example.com",
_33
"fallback_method": "GET",
_33
"status_callback": "https://www.example.com",
_33
"sticky_sender": true,
_33
"smart_encoding": false,
_33
"mms_converter": true,
_33
"fallback_to_long_code": true,
_33
"scan_message_content": "inherit",
_33
"area_code_geomatch": true,
_33
"validity_period": 600,
_33
"synchronous_validation": true,
_33
"usecase": "marketing",
_33
"us_app_to_person_registered": false,
_33
"use_inbound_webhook_on_number": true,
_33
"links": {
_33
"phone_numbers": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers",
_33
"short_codes": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ShortCodes",
_33
"alpha_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/AlphaSenders",
_33
"messages": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages",
_33
"us_app_to_person": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p",
_33
"us_app_to_person_usecases": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Compliance/Usa2p/Usecases",
_33
"channel_senders": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/ChannelSenders"
_33
},
_33
"url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_33
}

Copy down the Messaging Service SID (It starts with MGXXX). You'll need it in the next step when you associate a phone number with this Service.


Purchase an SMS capable phone number

purchase-an-sms-capable-phone-number page anchor

Sending SMS messages requires an SMS capable phone number. You can search for and purchase available phone numbers(link takes you to an external page) in the Console. When you search, make sure that the number you choose is SMS capable. Check the appropriate box in the search UI to filter available numbers to those that are SMS capable.

Search for SMS Capable Number.Rate this page:

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.