Create a Notification System in ServiceNow using Twilio SMS and Voice

July 23, 2021
Written by
Reviewed by

create_notification_system_service_now

If you're using ServiceNow, you might want a straightforward way to add one-way outbound messaging with voice and conferencing.

This tutorial shows how ServiceNow customers can utilize the out-of-the-box integration with Twilio Messaging and Programmable Voice using the free ServiceNow Notify plugin. The plugin is straightforward to set up, and the business value of implementing it is immense. You can greatly reduce your incidents' time to resolution, shorten the timeline for mobilizing resources to solve incidents and streamline communications with your customers during active incidents.

In this tutorial, you'll implement the ServiceNow and Twilio integration by configuring the following features:

  1. ServiceNow Notify for basic SMS and conference calls
  2. Alerts and Notifications using the ServiceNow Workflow Designer
  3. Alerts and Notifications using ServiceNow Business Rules

ServiceNow and Twilio integrations

This post is Twilio's recommended Crawl integration with ServiceNow. You can learn more about the ServiceNow use case on the Twilio website.

ServiceNow Crawl Walk Run Integrations with Twilio

If you'd like to do contextual outbound notifications and update ServiceNow in real-time via SMS or Voice, see our bi-directional incident management framework to integrate Twilio with ServiceNowWalk.

If you're looking for the most fully-featured Flex and ServiceNow integration, which includes inbound self-service and the ability to escalate to a live agent, see our guide on how to integrate Twilio Studio & Flex with ServiceNowRun.


Prerequisites

Before you get started, you will need:

Configure Twilio phone numbers

Login to your Twilio account.

Note: Only one Twilio account or subaccount can be configured on a given Notify driver at a time. Ensure that each ServiceNow instance on which you configure Notify uses a different Twilio account.

If you are using a free Twilio account, check out this helpful guide on the ServiceNow community board.

If you are going to follow Part 2 and/or Part 3 of this series, or if you are currently using other phone numbers in the account for a different application, consider implementing this tutorial on a separate account or subaccount. The ServiceNow Notify plugin automatically creates a TwiML "ServiceNowTwilioDirect" for all phone numbers attached to your Twilio account, which will overwrite the current configuration for those phone numbers.

Collect your Account SID and Authentication token under Project Info from the Twilio Console:

A screenshot of the Project Info section of the Twilio Console

You will need at least one Twilio number from which to send messages and place calls.

Buying one Twilio number per Notify Number Group will allow you to group Notify phone numbers, then share workflows across those grouped numbers. For each number group, you can specify a workflow for incoming and outgoing calls.

Under the "Phone Numbers" section of the Twilio Console, view the "Buy a number"  section to buy SMS and Voice capable numbers:

A screenshot of the Buy a Number section of the Twilio Console

Note: If you are going to send notifications to U.S.-based numbers, read about A2P 10DLC on the Twilio website and in the Twilio documentation. For simple testing, this step is not required. For production, we recommend that you perform the A2P 10DLC registration for the messaging service called "ServiceNowTwilioDirect", which will be automatically created by the ServiceNow Notify plugin in the next step.

Configure ServiceNow Notify

If you haven’t already done so, login to your existing ServiceNow account.

Follow this helpful guide on the ServiceNow community board to connect ServiceNow Notify with your Twilio account. In summary, you will need to:

  • Install the Plugins for Notify.
  • Notify (com.snc.notify) plugin - Provides powerful platform features for workflow-driven voice calls, conference calls, and SMS messages. You can activate the Notify plugin if you are an administrator.
  • Notify - Twilio Direct Driver (com.snc.notify.twilio_direct) plugin - Provides next generation integration with Twilio and Notify.

A screenshot of the Plugins section of the ServiceNow dashboard

Configure the ServiceNow integration with your Twilio account, then add your account SID and the Auth token. Import the phone numbers associated with your Twilio account to Notify.

A screenshot of the Twilio configuration section of the ServiceNow dashboard

Note: Notify automatically creates a TwiML application named "ServiceNowTwilioDirect" and configures the application to use the instance as an endpoint. This is the reason this integration can only use a single Twilio account or subaccount. You cannot have any existing TwiML app configured otherwise this step will fail.

A screenshot showing the new TwiML app in the Twilio Console

Follow this helpful guide on the ServiceNow community board to set up Notify. We'll walk through the main steps together below.

First, associate your Twilio number with the appropriate Notify Group:

A screenshot of the Notify phone number configuration section of the ServiceNow dashboard

Update the Notify Properties.

Set the glide.enable.notify_on_task property to 'true'.

Set your Twilio number on the glide.notify.task.phone_number property.

Set your Twilio number on the com.snc.on_call_rotation.notify_webrtc_number property.

A screenshot of the Notify Properties section of the ServiceNow dashboard

Convert phone numbers to E.164 format (optional)

You can optionally setup the Phone Number entries to be formatted in the E.164 format. Go to "My Profile", then with the cursor close to "Mobile phone", right click and select "Configure Dictionary":

A screenshot showing the User section of the ServiceNow dashboard

Change the type to "Phone Number (E164)" and click "Update":

A screenshot showing the mobile phone section of the ServiceNow dashboard

Go back to your testing user record and type your phone number into the Mobile Phone field (e.g. +12121234567). The system will automatically convert it to the E.164 format +1(212)123-4567:

A screenshot of the System Admin section of the ServiceNow dashboard

Verify the integration was successful

On the "Filter navigator", type "Incident" and you will see the "Incident" menu. Select "All". Select any of the existing Incidents:

A screenshot of the Incidents section of the ServiceNow dashboard

You should be able to see "Send SMS" and "Start Conference Call" links as shown below. If you do not see these links, follow this helpful guide on the ServiceNow community board for the steps needed to test the integration.

A screenshot of the Incident detail page in the ServiceNow dashboard

At this point, Notify is ready to be used directly from the incident tickets dashboard in ServiceNow to "Send SMS" or "Start Conference Call". 

Both options are intuitive and easy to use. Follow this helpful guide on the ServiceNow community board to further test the "Start Conference Call" functionality.

Note: All calls and messages made from tasks are initiated using a single Notify phone number (long code or short code). You can configure which phone number is used on the "Notify - Notify Properties" page as shown below.

A screenshot showing the Notify Properties section of the ServiceNow dashboard

Configure a click-to-call button (optional)

You can optionally configure a "Click to Call" button directly from the Incident form using this helpful guide on the ServiceNow community board. This is what it will look like, and you can place the call immediately using this icon:

A screenshot showing the Incident detail page of the ServiceNow dashboard

 

Configure Alerts and Notifications

Integrating Twilio with ServiceNow can reduce an incident’s time-to-resolution by:

  • Sending SMS notifications to the user confirming that the incident was opened and assigned to an engineer.
  • Alerting the on-call engineer via SMS that a High Priority incident was just assigned to them.

Watch this How to send SMS from ServiceNow with Twilio video to learn how to build these features. We’ll walk through the steps from the video below.

First, let’s send a message to the customer confirming that the incident was created and provide the engineer’s contact information. We will use the ServiceNow Workflow Designer for this. 

Go to the Workflow Editor in the ServiceNow dashboard. To locate it, type "Workflow Editor" in the search bar at the top of the left navigation bar:

A screenshot of the Workflow Schedules section of the ServiceNow dashboard

A new tab will open. Click on "New Workflow". This window will open:

A screenshot of the New Workflow window that appears in the ServiceNow dashboard
  1. Enter a Name for this flow (e.g. NotifyCustomerCaseAssigned)
  2. Define the Table on which it will run (e.g. Incident[Incident])
  3. Provide a Description for this workflow (e.g. "Notify customer that ticket was created and assigned to someone").
  4. Under the Conditions tab, for "If condition matches" select "Run the workflow always". For this example, select "Assigned to" and "is not empty". It should look like this:

A screenshot of the Conditions tab in the New Workflow pop in the ServiceNow dashboard

Click Submit. You will see your new Workflow created in a new tab:

A screenshot of the notification workflow

Delete the arrow connecting the boxes. On the tab "Core" on the right, open "Core Activities" →  "Notify" →  "Send SMS". Drag and drop the "Send SMS" activity to the "Workflow drawing canvas". A new window will appear to configure the "Send SMS" activity:

A screenshot of the SMS configuration settings
  1. Enter a Name for this workflow activity (e.g. "Notify Case was assigned to someone")
  2. Leave the Stage blank.
  3. Select the "From" number. If you click the search icon to the right of the "From" text field, it will show you the available Notify numbers if you added them to the "Notify on Task" group.
  4. Select the "To" or "To (groups)" fields depending on who you want to receive the notification

A screenshot of the Workflow Activity settings window

In the "To" area, click on the "Select field" icon:

A screenshot of the Workflow Activity settings window

Under "Caller", select "caller_id":

A screenshot of the Workflow Activity settings window

Customize the body of the message in the "Message" field.

Alternatively, you can select any custom fields you want to the right of the "Message" box, to insert dynamic information if needed.

For example, you can use this template:

Hi, ${caller_id.first_name},
Your incident ${number} was assigned successfully to ${assigned_to.first_name}, phone ${assigned_to.phone} and email ${assigned_to.email} . 
Thanks,
Your support team

A screenshot of the Workflow Activity settings window

Click Submit.

In the ServiceNow Console, click the "Begin" box and link it to the "Send SMS" box, click the "Send SMS" box and link it to the "End" box.

A screenshot of the notification workflow

Click the Validate icon, which is the checkbox in the top right corner. A screen will appear like the one shown below:

A screenshot of the Workflow Validation Report

If there are no errors or issues,  click "Publish" from the top menu dropdown:

A screenshot of the notification workflow

Test the alert and notification functionality

Let’s verify that this new Workflow functions as we expect. First, open a new incident by clicking on "Incident" and then "Create New":

A screenshot of the Incident detail page in the ServiceNow dashboard

Add information for the "Caller", "Assignment group" and "Assigned to" fields that you want to test. For example:

A screenshot of the Incident detail page in the ServiceNow dashboard

Click the Submit button. Your "Caller" or customer should receive a notification like this:

A screenshot of the SMS message sent by ServiceNow Notify
 

Success!

Configure ServiceNow Business Rules

Our last example will be to configure Alerts and Notifications using ServiceNow Business Rules.

ServiceNow Notify has powerful API’s for you to address business challenges like sending a notification for high-severity or stale incidents. We’ll use these APIs and the ServiceNow Business Rules to send a notification to the assigned engineer when a High Priority incident is created.

We will will use the following Notify SMS API:

A screenshot of the ServiceNow sendSMS() API reference

Type "Business Rules" in the "Filter navigator" of your ServiceNow dashboard:

A screenshot of the Business Rules section of the ServiceNow dashboard

Select "New":

A screenshot of the Business Rules section of the ServiceNow dashboard
  1. Give the new Business Rule a name (e.g. "NotifyAssigneeHighPriority").
  2. Select "Incident[incident]" under "Table"
  3. Check "Advanced"

A screenshot of the Business Rule detail page in the ServiceNow dashboard

Follow these configuration steps in the "When to run" tab:

  1. In the dropdown to the right of "When", select "After".
  2. Check "Insert" to the right of the "When" dropdown.
  3. Under "Filter Conditions", click on "Add Filter Condition". Set the priority to "Critical" and ensure the "Assigned to" value is "is not empty".

A screenshot of the Business Rule detail page in the ServiceNow dashboard

Click the "Advanced" tab, which is to the right of the "When to run" tab. You’ll see a "Script" text box which is where we’ll write the script using the SNC.Notify.sendSMS API. Here are the parameters we will need:

  • notifyPhoneNumber - The Twilio Number to send messages from.
  • toPhoneNumber - Dynamic number of the user the incident is assigned to (e.g. "+current.assigned_to.mobile_phone").
  • messageBody - Dynamic message (e.g. ''+current.number + ':' + current.short_description,current")
  • GlideRecord source - Glide record (e.g. "current").

For example:

(function executeRule(current, previous /*null when async*/) {

        // Add your code here

        SNC.Notify.sendSMS('+12345678900',''+current.assigned_to.mobile_phone,'Action required. New High Priority Incident assigned to you: '+current.number + ':' + current.short_description,current);
        
})(current, previous);

A screenshot of the Business Rule detail page in the ServiceNow dashboard

Click "Update".

Test the ServiceNow Business Rules setup

Let's test the setup! Go to Incidents and follow these steps:

  1. Select "New"
  2. Assign a Caller
  3. Ensure the "Impact" value is set to "1-High" and the "Urgency" value is set to "1-High". This will set the "Priority" to "1-Critical"
  4. Assign an engineer
  5. Provide a "Short description"
  6. Click "Submit"

A screenshot of the Incident detail page in the ServiceNow dashboard

The message will be sent automatically:

A screenshot of the SMS message sent by ServiceNow Notify
 

Success!

Conclusion

In this tutorial, you have learned how to configure ServiceNow Notify for basic SMS and conference calls, and how to configure Alerts and Notifications using the ServiceNow Workflow Designer and ServiceNow Business Rules.

Next steps

The Notify implementation is intuitive and simple to use. However, it is a one-way, outbound-only solution and works only with a single Twilio account or subaccount. If you need more flexibility, check out the other tutorials in the series to see how you can further enhance your ServiceNow integration with Twilio.

Al Kiramoto is a Solutions Engineer at Twilio who enjoys working with customers and solving business problems. He lives in Dallas, TX and enjoys a good barbecue and TexMex food. He can be reached at akiramoto [at] twilio.com.

Additional resources

The following reference resources will provide you with in-depth information on some of the topics mentioned in this post: