Skip to contentSkip to navigationSkip to topbar

SMS Opt-In Builder

Created by: Twilio
  • SMS
  • Runtime
  • JavaScript
(information)

Info

Regulations require that you first register your number to use these resources to send SMS traffic to US and Canadian mobile destinations. If you are sending to Canada or the US and have not already done so, please see our documentation to register your Twilio phone number(link takes you to an external page) or Toll-Free number(link takes you to an external page) before you use this template.

Learn how to build your own customized opt-in form hosted on Twilio.

Features include:

  • Auto-generated Terms of Service based on industry standards
  • Capture opt-ins and opt-outs with webhooks, Segment events, or Airtable
  • Configure colors and brand logo for your business
  • Live preview of your opt-in form
  • Optimized for both desktop and mobile device opt-ins
  • Templated language for industry standard opt-in requirements

You can provide details such as your campaign name, message frequency, opt-in keywords, and your own styling.

Finally, if you are applying for a short code(link takes you to an external page) or building an A2P 10DLC(link takes you to an external page) campaign list,this template app will show you the best practices you need to know, for obtaining SMS opt-in.

A demo screenshot of the opt-in builder on the left side and the built opt-in form on the right side.

Related Reading

Report this template(link takes you to an external page)
Download the code from GitHub to customize and self-host or share with your developer
(information)
  1. Get the code for this project

    The code for this sample is available on GitHub to view.

    View on GitHub(link takes you to an external page)
  2. Get Twilio credentials

    You will need an Account SID and Auth Token in order to run this code.

    Checking for existing account...

  3. Set up the code sample locally

Need some help?

We all do sometimes; code is hard. Get help now from our support team(link takes you to an external page), or lean on the wisdom of the crowd by browsing the Twilio tag(link takes you to an external page)on Stack Overflow.

Terms of servicePrivacy Policy

Copyright © 2026 Twilio Inc.