メニュー

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

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 for more.)

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

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 and give it a name

        Messaging Serviceを作成する

        Create a Messaging Service and give it a name

        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.

        SMS機能の利用できる電話番号を購入する

        Sending SMS messages requires an SMS capable phone number. You can search for and purchase available phone numbers 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.

        SMSの利用できる番号を検索する

        検索結果の表示時に、どの番号でSMSが利用できるか確認できます。

        SMSの利用できる番号を購入しましょう。

        ピッカピカの新しいTwilio電話番号で、モバイル機器にSMSを送りはじめることができます。

        Add a number to number pool

        Now, associate your SMS-enabled Twilio number with the Messaging Service that you created.

        You can do this in the Twilio Console in the Senders section under your Messaging Service. Click the Add Sender IDs button, select the Sender Type, and assign the senders to your Messaging Service.

        You can also use the Messaging Services REST API to add the Phone Number you purchased to your sender pool. To do this, you will need the Phone Number's unique SID, which starts with PNXXX. You can find this in the Phone Numbers Section of the Twilio Console.

        find_phone_number_sid.png

        Use the Phone Number's SID to attach to the Messaging Service that you created:

              
              
              
              
              Associate a Phone Number with your Messaging Service

              Add Number to Numbers Pool

              Associate a Phone Number with your Messaging Service

              Please note: Advanced Opt-Out currently does not support changing or reporting on blocked phone numbers via the Console or the REST API.

              Advanced Opt-Out is disabled by default for your Messaging Service. Once you enable Advanced Opt-Out, the only way to disable it is to contact our support team.

              Now that you have your Messaging Service, locate the Opt-Out Management section for your Messaging Service. This is where you can enable and configure your Advanced Opt-Out preferences.

              advanced-opt-out-configuration.png

              To turn on Advanced Opt-Out for your Messaging Service, click the Enable Advanced Opt-Out button.

              Make changes before enabling Advanced Opt-Out

              To remain compliant and provide your customers with the best possible experience, make sure that you have correctly configured Advanced Opt-Out prior to enabling it.

              Before enabling Advanced Opt-Out for your Messaging Service, you can change the configuration, such as the keywords and responses, and save your changes. These changes do not take effect on your Messaging Service until you enable Advanced Opt-Out. However, the changes that you make to keywords and responses are saved and reflected in the console.

              Be aware that as soon as you enable Advanced Opt-Out for your Messaging Service, the configuration applies to all of the senders (long codes, short codes, and toll-free numbers) in your Sender Pool.

              Double-check your keywords for Short Codes and Advanced Opt-Out

              If you have short codes in your Messaging Service's Sender Pool, it is a good idea to confirm that the keywords (opt-out, opt-in, and help) listed in the Advanced Opt-Out configuration exactly match the stop-words that you included in your application for the short code. In order to remain compliant per the requirements of your short code application, make sure that you are addressing the keywords the customers will use to opt in and out of your Messages.

              Once you enable Advanced Opt-out, the changes apply to all of the senders in your sender pool, including your short codes. Your keywords and responses in Advanced Opt-Out will take precedence over the settings for your Short Code, which is a potential compliance risk.

              We highly recommend verifying that the configuration in Advanced Opt-Out matches any keyword and confirmation message pairings that you may have previously set up in your application or that you specified when obtaining a short code.

              Configuring Advanced Opt-Out keywords

              There are three ways in which you can edit the keywords for for your Messaging Service:

              • Edit the Standard Opt-Out keywords
              • Add language-specific Opt-Out keywords
              • Add Country Code Opt-Out keywords

              Edit the Standard Opt-Out keywords

              Standard Opt-Out keywords apply to Messages in any country where you have not specified keyword and confirmation message pairs, which the next section covers. Since we have not added any country overrides yet, Advanced Opt-Out for your new Messaging Service currently handles all messages based on the Standard Keywords by default.

              To change the Standard Opt-Out keywords, click the Edit text to the right of the section header. This opens up an editing interface where you can add, change, and remove the keywords and confirmation message for opt-out, opt-in, and help interactions.

              Click Edit to edit the keywords and confirmation message for opt-out, opt-in, and help messages

              Keywords are case-insensitive

              Twilio tries to match keywords in a case insensitive way. "Stop" will be handled the same way as "STOP" or "stop".

              When configuring Advanced Opt-Out, developers should make sure not to include any Personally Identifiable Information (PII) in the response messages to customers.

              Editing the Opt-out keywords and confirmation message

              When Twilio receives an Opt-out keyword from one of your users, it adds this phone number to a list of blocked numbers. Twilio checks this list before sending any future outgoing messages. Any subsequent outgoing messages from your account to this user will fail with Error Code 21610 asynchronously.

              The reserved Opt-out keyword "stop" is non-removable. If your use case requires more keywords than Twilio recognizes by default, you can add them in the textbox, separated by commas.

              Special behavior for toll-free numbers

              If your Messaging Service includes Toll-Free US numbers, please be aware of the following special behavior:

              • Toll-Free US numbers always unsubscribe a user who replies STOP
              • Only the keywords START and UNSTOP can fully undo the blocking. Twilio's supported keyword "YES" will not work to opt-in a previously unsubscribed user.

              If using a Toll-Free US number to communicate with your users, make sure to communicate the STOP and START/UNSTOP keywords to them.

              Edit the Opt-in keywords and confirmation message

              You can specify which keywords Twilio will interpret as Opt-in keywords. When one of your users sends an Opt-in keyword, Twilio removes the blocked number entry containing the user’s number (if it exists) and sends the confirmation message that you define. This confirmation message notifies the customer that they have opted back in. Any subsequent outgoing messages to this user from your account will not be blocked.

              Please note: "start" and "unstop" are reserved Opt-In keywords and non-removable.

              Edit the Help keywords and confirmation message

              With help keywords, you can give your end users more information as to who owns a particular number as well as what actions are available. When Twilio receives a help keyword from one of your users, there is no impact on the block list. However, if the user has opted out previously, they won't receive your defined help message in response.

              Keep in mind that the keyword "help" is reserved and cannot be removed.

              Add Language-specific keywords for Opt-out, Opt-in, and Help messages

              If you are communicating with customers in more than one language, you can specify pairs of keywords and confirmation messages in the target languages of your end users. When an end user sends a Message using one of your configured keywords, Advanced Opt-Out matches the keyword and returns the confirmation message that you specified.

              For example, let's say that you plan to send Messages internationally to both English-speaking and Spanish-speaking users. You can create keyword and confirmation message pairs under the Language-specific Opt-Out Keywords section for Spanish, rather than setting country-specific Spanish keywords for each Spanish-speaking country in which you plan to send Messages.

              Click "Add Opt-Out Keywords" to add language-specific opt-out keywords. Select the language from the dropdown, then add the keyword(s) and the matching confirmation message.

              Click on Add Opt-Out Keywords under Language Specific Opt-Out Keywords to create language-specific pairings for Opt-out, Opt-in, and Help messages.

              Create keywords and confirmation messages per country code

              If you correspond with users in a country where you would like to provide a localized experience, you can do that by creating a country code pairing for keywords and confirmation messages.

              Please note: a Country Override replaces the Standard Keywords in the specified country. Be sure to add all keywords and confirmation responses that you wish to support for this country. Twilio first checks the list of keywords for the specified country. If it finds a match with a country-specific keyword, it will return the matching confirmation message. If not, it will check the list of Standard Opt-Out keywords.

              You can add these keywords in the Country Code Opt-Out Keywords section under Advanced Opt-Out Management.

              Click "Add Opt-Out Keywords" link under "Country Code Opt-Out Keywords." Use the dropdown menus to select the country name and at least one language. Enter the keyword and confirmation message.

              When specifying Country Code keywords, you must select at least one language to add keywords. If you wish to localize the behavior further, you can add another language.

              When receiving an incoming message from one of your users, Twilio matches the country code of your user’s phone number with the configuration that you specified. It then attempts to match one of the keywords listed in the pre-defined languages. If there is a match, Twilio applies any necessary opt-out action then replies with the message in the language of your user's keyword.

              Therefore, all keywords in a country, across all languages, need to be unique.

              Note: It is up to the developer to handle localization of keywords for Country Overrides. Twilio does not perform translation; it will only handle the literal keywords as specified in the Country Code Keywords.

              Be aware: the same keyword cannot be entered in two different languages for the same country. If a word is entered in one language, the same keyword won't be accepted in another language.

              Keeping track of your users' status

              With Advanced Opt-Out, you can keep track of the most up-to-date information about your users' opt-in and opt-out preferences. When an incoming message triggers one of your Opt-Out keywords, Twilio includes an OptOutType property in the request object sent to the webhook URL configured for your Messaging Service. The corresponding value is START, STOP, or HELP, depending on the incoming keyword.

              If you see the OptOutType property in Twilio's request to your application, that indicates that Advanced Opt-Out has already matched one of your keywords and replied with the corresponding confirmation message. You may want to store this information, but because Twilio has already sent a confirmation message/reply to your end user, we do not recommend sending another Message back from your application to the end user. In the case of Opt-out keywords, for example, Twilio will not send any further Messages to the end user, failing with Error Code 21610.

              関連トピック

              You’ve now successfully added global keywords to your Messaging Service by configuring the Advanced Opt-Out feature.

              Check out these other Messaging Service Resources to improve your users' experience:

              Rate this page:

              ヘルプが必要ですか?

              誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。