Lot of times, I get this question ‘How to send my customers text messages from salesforce?’. There are alot of apps available on appExchange to send text messages and you can do this using APEX as well. Both of these solutions comes with an additional cost, but this is one of the great ways to connect with your users/customers.
Let’s say we have a requirement:Whenever an important field is updated on an Account record, I want to send notification/alert to the owner of that account via a text message.
You probably know ‘how to send email alerts using Process Builder or Workflow rules’ then this is also very easy to set it up as well.I won’t be detailing the complete solution here, but we will focus on what you will need to do to generate your email to SMS address.
Let’s cover some basics first:
Step 1: Add a new email field on User and we will call it ‘Email to SMS Address‘.
Step 2: Add a new picklist field on User object and name it ‘Cell Carrier’. For eg: At&T, Verizon or T-mobile. Your list options can be any mobile carrier that is local to you.
Step 3:Create a field update workflow rule that updates the email to SMS address field you created.
It’s just a 3 Step process.
Let’s take a close look at the workflow rule that will create SMS email address:First thing first, we will create a new workflow rule on the User object and call it as ‘SMS email Create’.
Point to note here is that I am creating the workflow rule on User object but depending on your requirement you can do the same process using Lead or Contact or anywhere you are capturing a mobile number. All the steps remain same.In my logic, I have decided to update the Email to SMS Address field when:
1) A record is new AND
1.a)phone number field is not BLANK And
1.b) the cell carrier field is not BLANK
2) the record is edited AND
2.a) the phone number field is edited AND
2.b)cell carrier field is changed.
I will also recommend you to add a validation rule that enforces if a mobile number is entered, a cell carrier must also be selected and vice versa. Every cell phone carrier has an Email to SMS address domain that can be used to send an Email to Phone via text.
Now let’s talk about Email to SMS address Domain. The syntax for each carrier’s domain is different but you can find them online, for e.g. if you have Verizon as your cell carrier then your domain is @vtext.com.So if the mobile number is 804-123-6789 then my Email to SMS address will be firstname.lastname@example.org. Field Update action will take the customer’s cell phone number,extract the special characters and then mashing it up with carrier’s email to SMS address.
SUBSTITUTE function is used to find the special characters like (dashes,spaces,commas etc) and removing them. After that, we use a Case statement to find out which carrier is selected and add the corresponding Email to SMS address domain.
Once the field update is triggered, you will have your Email to SMS field populated with the correct address.Now you are all set to send your first text!!..Yippee!!
Now you can create email templates and additional workflow rules and play with them. The user/contact message will look something like this:
Text before forward slash (‘/’ )is the subject and everything after is the body of the text.
So now you are all set to try this out. Thank you for checking the blog post.
Check the following resources for more info: