An SMS can be sent out automatically using a workflow e.g., in the process builder.
To do that, you need to specify parameters like a subject line or SMS text.
Required parameters to invoke Apex
•Mobile Phone number
•Contact or lead or account relationship, e.g. direct ID
•Subject line (option)
•SMS text (mandatory)
•Call result (option) - either complete name or API name
•Call result group (option) - either complete name or API name
If no mobile phone number is specified, a contact or lead or account relationship is required. If both are specified, the mobile number has priority.
A task is created depending on the configuration settings and considering the record type. If the subject line is empty, the SMS subject line from the configuration is used.
Go to Salesforce Setup-> (Quick search)-Process Builder ->Click on “New“ to create new process.
Click to add an object for that process is created. Example: Case. Also select when record is created as we want to send the SMS when case is created.
Define case criteria.
Add action for that criteria, select Apex and the apex class Mirage__MirageSMSUsingProcess that we are calling.
Now set values for the Apex method variables.
Parameters used to pass values from process are -
•recordId
Ex- ContactID(The SMS will go to that object's mobile number, Ex- contact )
Ex- AccountId(The SMS will go to that object's Phone number, Ex- Account)
Ex- LeadID(The SMS will go to that object's mobile number, Ex- Lead )
•defaultDestinationNumber
Mobile number to which SMS will be sent
•textMessage
Body of the message to send SMS
•subjectLine
Subject to create activity
•wrapUp
To fill call result to activity
•createActivityForSMS
When true, activity is created
Flow / Process with SMS Template
It is possible to use an SMS template. Just add the ID of the e-mail template in the field: templateID
To retrieve the ID of the template, open the template and copy the ID from the URL.
Example
https://mycompany.lightning.force.com/lightning/setup/CommunicationTemplatesEmail/page?address=%2F00X5i000001ZTAZEA4%3Fsetupid%3DCommunicationTemplatesEmail
SMS Configuration scenarios
scenario 1 - Default destination number is specified.
SMS will be sent to the default destination number specified in the configuration
Scenario 2 - Record id is specified
SMS will be sent to the record (Contact/Account/Lead) mobile/phone number specified in the configuration.
Ex- ContactId (The SMS will go to that object's mobile number, Ex- contact mobile number )
Ex- AccountId (The SMS will go to that object's Phone number, Ex- Account phone number)
Ex- LeadId (The SMS will go to that object's mobile number, Ex- Lead mobile number )
Scenario 3 - Default destination number and record id both are specified
SMS will be sent to the default destination number specified in the configuration. Priority is always given to the default destination number over the record id.
Scenario 4 - Custom object
An SMS can be sent using a phone number on a custom object. The only limitation is that a task can not be created as the custom object would not be linked to the task.
•defaultDestinationNumber must be set to the phone number filed of the custom object
•createActivityForSMS must be set to false