Rate this page:

Send SMS Messages from Process Builder

Process Builder is a popular tool for building automated workflows in Salesforce. Twilio for Salesforce exposes two global Apex classes: Twilio Send SMS and Twilio Send to Studio that you can use to send out automated SMS messages when certain conditions are met. Common uses of Process Builder include:

  • SMS notifications.
  • Appointment reminders.
  • Customer satisfaction surveys.

Process Builder actions

Twilio Send SMS Message allows you to send a text message from Process Builder. This Apex class is useful for single-message use-cases such as alerts and notifications.

Twilio Send to Studio allows you to initiate SMS and Voice chatbots using Twilio Studio, Twilio’s drag-and-drop visual editor. This Apex class is useful for initiating longer conversations that might require if...then branching.

How many licenses do I need if I’m using Process Builder?

The answer to this question depends on which users are running your automation flow. See “How many seats do I need?” in the FAQ for more details.

Send SMS messages with Process Builder and Twilio for Salesforce

Ready to get started sending simple SMS alerts? Follow the instructions in the video below.

Twilio Send SMS Message parameters:

Parameter Description
Message The body of the SMS message that you would like to send. This can be static, a field reference, or a formula (useful for templated messages). Note the message length determines the number of segments.
To Mobile Number The phone number you want to send the message to. This can be static, a field reference, or a formula.
From Mobile Number The phone number you want to send the message from. This can be static, a field reference, or a formula.

Send to Studio with Twilio for Salesforce

Interested in crafting interactive bot conversations with your users? Learn how you can launch SMS bots using Twilio Studio and the Salesforce Process Builder in this video:

To configure the Twilio Send to Studio Apex class, provide the following values:

Parameter Description
From Number The phone number you want the Studio flow to be sent from. Currently we only support sending from a specific number, not a messaging service. This might mean your chat bot will contact a user from a new number.
Studio URL The Rest API URL that will call your Studio flow. Example: To find your Studio flow API URL, click on the gear icon in the top-right corner of the flow’s trigger.
To Mobile Number The number that the chat bot will send messages or make calls to.
Parameters (Optional) You can also include additional Salesforce data as context parameters in key/value pairs. This is useful if you want your chat bot to address the recipient by first name, or reference other information from Salesforce within your Studio flow under {{}}.

Updating a Salesforce record with a Twilio Function

The following code sample shows how to create a Salesforce contact using a Twilio Function. Functions can be run in Twilio Studio using the Function widget. Parameters passed to the Function widget will be accessible via the event object.

Note Before running this function, you will need to add nforce as a package dependency in your functions configuration page:


exports.handler = function(context, event, callback) {
  console.log('Running function')

  let nforce = require('nforce');
  let response = new Twilio.Response();
  let oauth;
  // Create the connection with the Salesforce connected app
  let org = nforce.createConnection({
    clientId: context.SF_CONSUMER_KEY,
    clientSecret: context.SF_CONSUMER_SECRET,
    redirectUri: '',
    mode: 'single'
  // Authenticate and return OAuth token
    username: context.SF_USERNAME,
    password: context.SF_PASSWORD + context.SF_TOKEN
  }, function(err, resp){
    if (!err) {
      console.log('Successfully authenticated:', resp);
      oauth = resp;
    let lastname = `${event.first_name} ${event.last_name}`; 
    // Set contact data
    let ct = nforce.createSObject('Contact');
    ct.set('lastname', lastname);
    ct.set('State__c', 'California');

    // Create contact in our SFDC org
    org.insert({ sobject: ct, oauth: oauth }, function(err, resp){
      if(!err) {
        console.log('Successfully created contact');
        callback(null, null);
      } else {
        console.log("Error creating contact:", err);

For more examples, see the documentation for nforce, the NodeJS client library for Salesforce.

Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.


        Thank you for your feedback!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        Step 1

        Get link

        Get a free personal referral link here

        Step 2

        Give $10

        Your user signs up and upgrade using link

        Step 3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more