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
- Navigate to the Salesforce Setup page
- In the Quick Find Bar search Custom Notifications
- Select Custom Notifications from the results
- Create a new Custom Notification
- Name: RingDNA New SMS
- API Name: RingDNA_New_SMS
Flow Overview:
Manual Implementation Steps
Create a new Flow in Salesforce
- Navigate to the Salesforce Setup page
- In the Quick Find Bar searchFlows
- Select Flows from the results
- 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.
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.
Type: Variable (Resource) Name: SMSAlertID Data Type: Text
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.
Type: Collection Variable (Resource) Name: OwnerId Data Type: Text (Allow Multiple Values)
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.
Type: Decision (Element) Name: MatchType Outcome Order: 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.
Type: Variable (Resource) Name: ParticipantId Data Type: Text Type: Variable (Resource) Name:ParticipantName Data Type:Text
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
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}
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]>
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]> |
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.
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.
Salesforce Custom Notification:
Email Notification: