This is a guest post from Adam Marks.
A fairly common request that I get is, “how can I send my users/customers’ text messages from Salesforce?” There are apps on the app exchange that can do this, as well as Apex solutions too. Both of those approaches typically come with an additional cost, though. If you want to impress your users and save the day with a declarative option, well you are in luck, because I just so happen to have one!
Let’s look at our use case here:
When a critical field is updated on an Account, I want to send a notification to the Account owner via text.
Pretty straightforward, right? If you already know how to create E-mail alert Workflow rules then it will be pretty easy to set this up too. We won’t be detailing the full solution here, instead we’re just focusing on what you need to do to generate your Email to SMS Address. Let’s begin by outlining the basic steps:
- Create a new e-mail field on User named Email to SMS Address.
- Create a new picklist field on User named Cell Carrier. Your list options can be any carrier that is local to you or that your business uses. We will have several in our example below.
- Create a field update workflow rule that updates the Email to SMS Address field you created
That’s it, just 3 easy steps!
Let’s do a deeper dive into the workflow rule that will create your SMS email address.
I start by creating a new workflow rule on the User object and name it SMS Email create. Quick note before we go much further I am doing this on User, but you could do this same process on Lead or Contact or anywhere in the system you are capturing a mobile number. The steps, logic and syntax remain mostly the same. Just use your object instead of User. In my rule, I decided to go with logic that updates the Email to SMS Address field when:
- a record is new AND
- the mobile number field is not blank AND
- the cell carrier field is not blank
- the record is edited AND
- the mobile number field is changed OR
- the cell carrier field is changed
I would also recommend adding a validation rule that enforces if a mobile number is entered, a cell carrier must also be selected and vice versa.
Here is my syntax for the rule entry criteria:
Now let’s get into the field update action. For reference, you may be wondering what values work in the Cell Carrier pick list. Here are some examples:
If you have any smaller regional carriers you could use them too, but only if you can find their Email to SMS address domain. Speaking of Email to SMS address domains, now is a good time to take a peek behind the curtain and explain exactly how this whole thing works.
Each cell carrier has an address that can be used to send an email to a phone via text. The specific syntax for each carrier’s domain will vary but most of them are available online. For example, if you have Verizon then your domain is @vtext.com. So if my number was 804-867-5309 (it’s not by the way!) then my Email to SMS address would be email@example.com.
The field update action is taking the user’s cell phone number, extracting the special characters, and then mashing it up with the corresponding carrier’s Email to SMS address.
Let’s look at the syntax.
The substitute function is finding the “special” characters (dashes, spaces, commas, etc) and effectively deleting them. Once that has been done we use a Case statement to determine which Carrier is selected and insert the corresponding Email to SMS address domain. Pretty easy, right?
Once the field update fires, you should now have your Email to SMS field populated with the correct address. At that point, you are ready to send your first text!
Now you can create your email alert template(s) and additional Workflow rule(s) and then test them out. When a user/contact gets a text it will be formatted something like this:
The part before the forward slash (“/”) is the subject, and everything after is the body. Remember when creating your email templates that these are text messages, so brevity is going to be your friend here!
That’s it – you are now ready to send text messages out of Salesforce via Email Alert Workflow rules. All in all, pretty easy I think, and pretty cool too!
About Adam Marks
Like many others, I stumbled into Salesforce purely by chance over 5 years ago. The company I was working for bought Sales Cloud but had no idea what they were going to do it. Suffice to say once I got involved, I never looked back. The power and flexibility of the platform coupled with the speed at which you can accomplish goals is unparalleled in any other technology I have worked with. In addition to being a Salesforce MVP and fanatic, I also am a senior Salesforce and cloud technologies consultant with RTS Labs in Richmond Virginia.