We have different mechanisms to handle the opt in and opt out.
ValueText has many service providers to serve you entire world.
Most of the gateways support STOP and START.
STOP is for opt out and START is for opt in. If your customer reply with STOP you can not send any messages from Salesforce from the same sender id.
This opt out is under sender id level if you use long code or short code. You can send the message with different sender id so this opt out is under sender id level.
If you are sending the messages with Sender id example ValueText then this will not help because reply not accepted by sender id.
If you are sending the messages with alphanumeric Sender id then you can use url in the text to opt out. Please refer opt out url section.
Record level opt out
If you are sending the manual messages from the record level by using the lightning component or pages then this will help you.
Component will lock automatically based on the check box enabled at record level. Example SMS opt out check box at lead or contact level.
There are multiple check box fields at record level so you have to choose which field you are treating for text opt out at Salesforce > ValueText app from app menu > ValueText setup tab > Step 6: Text opt out settings > choose object and select fields.
This settings will not help in automation so you have to consider that check box in workflow / flow / process / apex criteria to stop sending the messages.
Org level opt out
The above example is record level but if you storing the same phone number in another record like contact or lead then record level opt out can not stop at lead if the check box enabled at contact.
Org level opt out work based on phone number not based on object. It will stop the message from any object even you send manually, flow or apex.
To enable org level opt out, you have to create a record at Opted Numbers object.
1. Manual way to opt out:
Phone number must be with country code without spaces and special chars. Example for USA 1xxxxxxxxx
Mark "enable opt - out" as true if you want to opt out.
You can automate the entire process when you receive a message with STOP / START ( you can also define your own keywords in your local language).
Step 1: Create a process builder on Message bucket
Step 2: Meet the criteria (Type__c == ‘Inbound’ & Message__c contains STOP )
Step 3: Call VtOptedOut for STOP and for START call VtOptedIn methods from apex action.
Step 4:Map the MobileNumbers field with Number__c from the message bucket.
Time based delivery
This is important for some countries. You can not send the promotional messages after business hours as per the country regulations.
Step 1: Create business hours in Salesforce and define available hours in each day.
Step 2: Map the Business Hours id ( 18 digits id ) to rsplus__Business_Hours__c field of message bucket while you are sending the message from process builder.
When your flow fires it will cross check the business hours and send the message, if it is out of business hours then it will send the message after the next business start.
Opt in URL
If you are using BASIC, STANDARD app or sending the messages with Alphanumeric sender id then this option will help you.
You can create a site page or use existing site page and add publicOptoutPage page at Site Visualforce Pages section of the site.
Build the public url:
<site public url>/publicOptoutPage
You can convert that long url into short url by using bitly, google or any other services.
Include the long url in text. Your users can access and enable the unsubscribe like we do email unsubscribe.