A Harper Systems Component for tracking Twilio SMS opt-outs and opt-ins.
Twilio recommends tracking your customer's SMS opt out status per carrier and country-based legal compliance regulations regarding messaging:
As a business, you must follow certain guidelines when adding and removing customers from your text message lists to ensure you only send messages customers want and comply with SMS regulations.
Keeping track of your user's status (Twilio official docs)
If you see the OptOutType property in Twilio's request to your application...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.
This component offers an easy to use endpoint and storage system to add as your opt-in status tracker. The phonenumber and status is stored in a Harper datatable for easy access. Whether you are sending one-off SMS messages or a text blast you will need to make sure your customers are opted in before sending.
This component listens on inbound SMS for the OptOutType Parameter and subsequently updates the phone number's corresponding status.
How to listen for inbound messages with OptOutType & use this component:
- In the Twilio Console, go to Twilio Messaging Services
- Select a service and click on Integrations
- Select Send a webhook for Incoming Messages
- Add https://this-applications-url.com/optInStatus to the Request URL
- Make sure to leave it as a POST
- Save!
- Verify this component is working by texting an opt-in or opt-out keyword to a phone number in the service. This will appear in the Harper datatable PhoneNumbers: accessible either in your Harper Studio UI or via the RESTful API endpoint for PhoneNumbers
Install Harper or run npm i -g harperdb
git clone this repo & cd to it
npm i
npm run dev
Endpoint | Description |
---|---|
/optInStatus |
Supports POST req for inbound Twilio SMS & update optin status |
/PhoneNumbers |
Direct REST interface for the PhoneNumbers table |
Deploy this Harper component wherever you like: Linode, AWS, GCP, DigitalOcean, on prem
Follow the Harper installation guide on the machine where this will be deployed