We have different mechanisms to handle the opt-in and opt-out.
Keywords
Record level opt-out
Org level opt-out
Time based opt-out
Opt-out URL
Keywords
ValueText has many service providers to serve the entire world.
Most of the gateways support STOP and START.
STOP is for opt-out and START is for opt-in. If your customer replies 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 the sender id level.
If you are sending messages with a Sender id example ValueText then this will not help because the reply is not accepted by the sender id.
If you are sending messages with an Alphanumeric Sender id then you can use the URL in the text to opt-out. Please refer opt-out URL section.
Record level opt-out
If you are sending manual messages from the record level by using the chat console, then this will help you.
The console will lock automatically based on the check box enabled at a record level. Example SMS opt-out check box at the 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 7: Text opt-out settings > choose an object [1] and select field [2].
This setting 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 store 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 is enabled at contact.
Org level opt-out works based on phone number not based on the object. It will stop the message from any object even if you send it 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.
2. Automation
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 promotional messages after business hours as per the country’s 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 the rsplus__Business_Hours__c field of the message bucket while you are sending the message from the 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 the BASIC, STANDARD app or sending the messages with an Alphanumeric sender id then this option will help you.
You can create a site page or use an existing site page and add a publicOptoutPage page at the Site Visualforce Pages section of the site.
Build the public url:
<site public url>/publicOptoutPage
You can convert that long URL into a short URL by using bitly, google, or any other services.
Include the long URL in the text. Your users can access and enable the unsubscribe like we do email unsubscribe.