Create SMS Notifications with Salesforce Flows

The purpose of this article is to provide an example of how a Salesforce Administrator can create a Flow to extend SMS notifications beyond the RingDNA Dialer extension to Salesforce or Email.

 

Example Package

An unmanaged package can be installed using the link below for easy experimentation in your Sandbox:

https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5f000000SESo


Prerequisite 

Create a Custom Notification Type

  1. Navigate to the Salesforce Setup page
  2. In the Quick Find Bar search Custom Notifications
  3. Select Custom Notifications from the results
  4. Create a new Custom Notification
    • Name: RingDNA New SMS
    • API Name: RingDNA_New_SMS


Flow Overview:

rtaImage__1_.jpeg

Manual Implementation Steps

Create a new Flow in Salesforce

  1. Navigate to the Salesforce Setup page
  2. In the Quick Find Bar searchFlows
  3. Select Flows from the results
  4. Select the option New Flow in the top-right corner of the page

When a Task is created in Salesforce containing the subject "Inbound Message:" this flow will be triggered.

rtaImage__2_.jpeg

Flow Settings

Type: Record Triggered Flow

Object: Task

Trigger the Flow when: A record is created

Entry Conditions: Subject STARTS WITH Inbound Message:

Optimize the Flow for: Actions and Related Records

Run Asynchronously: FALSE


1. The first thing this Flow will run is a Get Record on the object Custom Notification Type when DeveloperNameEQUALSRingDNA_New_SMS. Record IDs are not consistent across Salesforce Orgs when installing packages. This will look up the resulting ID and store it in the Text Variable SMSAlertID. If you are recreating this flow manually, an ID can be hardcoded when defining your Notification Type ID the Custom Notification Type Action later.


rtaImage__3_.jpeg

Type: Variable (Resource)

Name: SMSAlertID

Data Type: Text


Type: Get Record (Element)

Name: GetSMSAlertID

Object: Custom Notification Type

Condition: All Conditions Are Met

Rule: DeveloperName EQUALS RingDNA_New_SMS

Sort Order: Not Sorted

How Many Records to Store: Only the first record

How to Store Record Data: Choose fields and assign variables (advanced)

Where to Store Field Values: In separate variables

Field: Id → {!SMSAlertID}

When no records are returned, set specified variables to null: TRUE


2. Next an Assignment element stores the Task's Description and OwnerID as variables. This will be used later when invoking Send Custom Notification actions. Description contains the body of the SMS message and OwnerID will be the recipient of the notification.

rtaImage__4_.jpeg

Type: Collection Variable (Resource)

Name: OwnerId

Data Type: Text (Allow Multiple Values)


Type: Assignments (Element)

Name: InitializeTaskAssignments

Rule: {!SMSBody} EQUALS {!$Record.Description}

Rule: {!OwnerId} ADD {!$Record.OwnerId}

 

3. We now need to determine if the Task is attached to a Lead, Contact, or No Record so we can perform the correct Get Record in the next step. We will use a Decision step for this.

rtaImage__5_.jpeg

Type: Decision (Element)
Name:
MatchType

Outcome Order:
    Outcome Name:
MatchedLead

    Condition: All Conditions Are Met

    Rule: {!$Record.WhoId} STARTS WITH 00Q

    Outcome Name: MatchedContact

    Condition: All Conditions Are Met

Rule: {!$Record.WhoId} STARTS WITH 003

    Outcome Name: Default Outcome

    Condition: No Conditions Needed


4. We now have three branching paths. MatchedLead, MatchedContact, and our Default branch which I've relabeled as None. MatchedLead and MatchedContact lead into a Get Records element which will look up the associated Lead or Contact on the Task and allow us to store the Record ID to the ParticipantID variable and RecordFullName to the ParticipantName variable.

rtaImage__6_.jpeg

Type: Variable (Resource)
Name: ParticipantId

Data Type: Text


Type: Variable (Resource)
Name:ParticipantName

Data Type:Text


Type: Get Records (Element)

Name: GetContactParticipant

Object: Contact

Condition: All Conditions Are Met

Rule: Id EQUALS {!$Record.WhoId}

Sort Order: Not Sorted

How Many Records to Store: Only the first record

How to Store Record Data: Choose fields and assign variables (advanced)

Where to Store Field Values: In separate variables

Field: Id → {!ParticipantID}

Field: Name → {!ParticipantName}

When no records are returned, set specified variables to null: TRUE


Type: Get Records (Element)

Name: GetLeadParticipant

Object: Lead

Condition: All Conditions Are Met

Rule: Id EQUALS {!$Record.WhoId}

Sort Order: Not Sorted

How Many Records to Store: Only the first record

How to Store Record Data: Choose fields and assign variables (advanced)

Where to Store Field Values: In separate variables

Field: Id → {!ParticipantID}

Field: Name → {!ParticipantName}

When no records are returned, set specified variables to null: TRUE

 

5. At this point we will need to define a few formula resources. The first is NotificationTitle which inserts the Lead or Contact's name in the title of our Custom Salesforce Notification. We will also create a formula called OrgBaseURL to store the Base URL of the Salesforce instance for linking back to records in the Custom Notification and Email Notification.

Type: Formulas (Resource)

Name:NotificationTitle

Data Type:Text

Formula:"New SMS Message from " & {!ParticipantName}


Type: Formulas (Resource)

Name:OrgBaseURL

Data Type:Text

Formula:LEFT({!$Api.Partner_Server_URL_260}, FIND( "/services", {!$Api.Partner_Server_URL_260}))

6. Now we will define the Text Templates for our Email Alerts. We will be creating one for when a Task is attached to a Lead or Contact, and a slightly different template when no match is made.

Type: Text Template (Resource)

Name:EmailBody

Body:

<p>Hello,</p><p>You have received a RingDNA SMS Notification from <a href="{!OrgBaseURL}{!ParticipantID}" rel="noopener noreferrer" target="_blank">{!ParticipantName}</a>.</p><p>{!$Record.Subject}</p><p>"{!SMSBody}"</p><p></p><p><div><!--[if mso]>
  <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{!OrgBaseURL}{!$Record.Id}" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="10%" strokecolor="#0066ff" fillcolor="#0066ff">
    <w:anchorlock/>
    <center style="color:#ffffff;font-family:sans-serif;font-size:13px;font-weight:bold;">View Record in Salesforce</center>
  </v:roundrect>
<![endif]--><a href="{!OrgBaseURL}{!$Record.Id}"
style="background-color:#0066ff;border:1px solid #0066ff;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:13px;font-weight:bold;line-height:40px;text-align:center;text-decoration:none;width:200px;-webkit-text-size-adjust:none;mso-hide:all;">View in Salesforce</a></div></p>


Type: Text Template (Resource)

Name: EmailBody_Unknown

Body:

<p>Hello,</p><p>You have received a RingDNA SMS Notification from an unknown contact.</p><p>{!$Record.Subject}</p><p>"{!SMSBody}"</p><p></p><p><div><!--[if mso]>
  <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{!OrgBaseURL}{!$Record.Id}" style="height:40px;v-text-anchor:middle;width:200px;" arcsize="10%" strokecolor="#0066ff" fillcolor="#0066ff">
    <w:anchorlock/>
    <center style="color:#ffffff;font-family:sans-serif;font-size:13px;font-weight:bold;">View Record in Salesforce</center>
  </v:roundrect>
<![endif]--><a href="{!OrgBaseURL}{!$Record.Id}"
style="background-color:#0066ff;border:1px solid #0066ff;border-radius:4px;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:13px;font-weight:bold;line-height:40px;text-align:center;text-decoration:none;width:200px;-webkit-text-size-adjust:none;mso-hide:all;">View in Salesforce</a></div></p>


7. With everything now defined in our variables, It's time to send out the SMS and Email notifications. The Default "None" branch will be using one set of variables while MatchedLead and MatchedContact merges together.

rtaImage__7_.jpeg

Branch: MatchedLeadandMatchedContact

Type: Action (Send Custom Notification) (Element)

Name: SendSMSNotification

Custom Notification Type ID: {!SMSAlertID}

Notification Body: {!SMSBody}

Notification Title: {!NotificationTitle}

Recipient IDs: {!OwnerId}

Sender ID: DISABLED

Target ID: {!ParticipantID}

Target Page Reference: DISABLED

Type: Action (Send Email) (Element)

Name: SendEmailNotification

Body: {!EmailBody}

Subject: New SMS Message from {!ParticipantName}

Email Addresses (collection): DISABLED

Email Addresses (comma-separated): {!$Record.Owner:User.Email}

Rich-Text-Formatted Body: {!$GlobalConstant.True}

Sender Address: DISABLED

Sender Type: DISABLED

 

Branch: None/Default

Type: Action (Send Custom Notification) (Element)

Name: SendSMSNotificationUnknown

Custom Notification Type ID: {!SMSAlertID}

Notification Body: {!SMSBody}

Notification Title: New SMS from Unknown Person

Recipient IDs: {!OwnerId}

Sender ID: DISABLED

Target ID: {!ParticipantID}

Target Page Reference: DISABLED

Type: Action (Send Email) (Element)

Name: SendEmailNotificationUnknown

Body: {!EmailBody}

Subject: New SMS Message from Unknown Person

Email Addresses (collection): DISABLED

Email Addresses (comma-separated): {!$Record.Owner:User.Email}

Rich-Text-Formatted Body: {!$GlobalConstant.True}

Sender Address: DISABLED

Sender Type: DISABLED

 

Results

If you have correctly set up your Flow or installed the Unmanaged package, you will see the following alerts when a new Task is created, provided that the Subject Line begins with Inbound Message.

mceclip0.png

Salesforce Custom Notification:

rtaImage__8_.jpeg

Email Notification:

mceclip1.png

 

Was this article helpful?

/