Create a Notification System in ServiceNow using Twilio SMS and Voice

July 21, 2022
Written by
Reviewed by
Paul Kamp
Twilion

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 ServiceNow – Walk.

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 ServiceNow – Run.

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 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" app 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:

Auth Token and Account SID in 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:

SMS and Voice filters when buying numbers in Twilio

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, log into your existing ServiceNow account. In this blog post, we are using the San Diego release.

If you are working with prior releases (e.g., Rome), please follow this guide instead.

Log into ServiceNow, select All then type ‘Plugins’ on the filter. Click on ‘Plugins’. You will be redirected to All Applications:

ServiceNow All Applications

In the search field, type ‘Twilio’ then select Install for the Notify Plugin:

  • 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.

Twilio plugin for ServiceNow

Once installed, go to All, then type ‘Notify’ on the filter. Select Twilio Direct Configuration:

Twilio Direct Configuration in ServiceNow
  • Configure the ServiceNow integration with your Twilio account, then add your account SID and your Auth token. (You can find these in your Twilio Console.)
  • Import the phone numbers associated with your Twilio account to Notify.

Adding Twilio Credentials and phone number to ServiceNow

Click on the phone number to configure it:

  • Add a label (e.g., ‘Twilio Notify’)
  • Associate your Twilio number with the appropriate Notify Group (e.g., ‘Notify On Task Group’)
  • Hit the Save button

Associate a phone number with the right group in ServiceNow

 

  • Update the Notify Properties (All > Notify > Administration > Notify Properties)
    • Enable Notify integration for Task table and its extensions.
    • Enter the ‘Notify phone number used for sending SMS-s and starting conference calls from any record that belongs to the task table or table that extends task table’ – the Twilio number you bought.
    • Set the ‘Should confirmation SMSs for opt-in/out requests be saved into notify_message table for tracking purpose. property to ‘yes’
    • Set the ‘Enable Notify integration for Incident Communications Management property to ‘yes’
    • Add the ‘The Notify number to use for sending SMS-s and starting conference calls for Incident Communications Management’ – the Twilio number you bought.
    • Add the ‘Specify a valid Notify Number with voice capability’ – the Twilio number you bought.
    • Hit Save
Update the ServiceNow Notify preferences

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.

Opt-In and Opt-Out configuration (optional)

You can optionally setup the Opt-In and Opt-Out configuration. Go to the All > Notify > Administration > SMS preference configuration:

Create new preference configuration
  • Update the SMS Preference Configuration:
    • Select ‘TwilioDirect’ for Provider.
    • Check Enable for long code
    • Set the Opt-out confirmation message – see an example below
    • Set the Opt-in confirmation message – see an example below
    • Hit Submit

ServiceNow SMS preference configuration

Set default voice (optional)

Go to All > Notify > Administration > Twilio Direct Additional Properties:

Select your favorite voice (man, woman, alice, or any of the Amazon Polly voices):

ServiceNow Notify and Twilio Amazon voice preference

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 All > My Profile, then with the cursor close to "Mobile phone", right click and select Configure Dictionary:

Configure a phone number dictionary in ServiceNow

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

E.164 phone numbers in ServiceNow

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:

Mobile Phone field in ServiceNow with Twilio

Verify the integration was successful

Go to All > Service Desk > Incidents. Select any of the existing Incidents:

Viewing incidents in ServiceNow

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.

Send SMS and start conference calls from ServiceDesk

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.

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 the preferences, found in All > Notify > Administration >  Notify Properties.

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.

Workflow Editor in ServiceNow

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

New Workflow in the ServiceNow Workflow Editor
  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:

Setting up a new workflow in ServiceNow

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

New workflow tab in ServiceNow

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 on the Workflow drawing canvas. A new window will appear to configure the Send SMS activity:

Send SMS activity in ServiceNow
  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

Filters and settings to Send SMS in ServiceNow

In the “To” area, click on the Select field icon:

Select field icon in serviceNow Workflow

Click on Caller, which will select “${caller_id}”.

Caller in a ServiceNow Workflow Activity

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 ServiceNow SMS template

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.

Linking boxes in ServiceNow workflows

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

Validate the Send SMS Workflow in ServiceNow

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

Publish a Workflow in ServiceNow

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:

Open a test incident in ServiceNow to test a Twilio workflow

Add information for the “Caller”, “Short Description”, and “Assigned to” fields that you want to test. For example:

Adding caller, description, and assigned fields to an incident in ServiceNow to notify with Twilio

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

Test message from a ServiceNow and Twilio integration

Success!

Configure ServiceNow Business Rules

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

ServiceNow Notify has powerful APIs for you to address business challenges such as 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:

ServiceNow Notify API overview

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

Setting ServiceNow business rules in the filter navigator

Select New:

Adding a new ServiceNow business rule
  1. Give the new Business Rule a name (e.g., “NotifyAssigneeHighPriority”).
  2. Select Incident[incident] under Table
  3. Check Advanced
  4. In the dropdown to the right of When, select After
  5. Check Insert to the right of the When dropdown.
  6. Under Filter Conditions, click on Add Filter Condition. Set the priority to High and ensure the Assigned to value is is not empty.

Configuring a new business rule in ServiceNow

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 - Your 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*/) {

SNC.Notify.sendSMS('<<Replace with your Twilio Notify Number>>',''+current.assigned_to.mobile_phone,'Action required. New High Priority Incident assigned to you: '+current.number + ':' + current.short_description,current);
        
})(current, previous);

Editing the ServiceNow Business Rules advanced section

Click Submit.

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 2-Medium. This will set the Priority to 2-High
  4. Assign an engineer
  5. Provide a Short description
  6. Click Submit   

Test an incident with new business rules in ServiceNow with a Twilio integration

The message will be sent automatically:

Example notification on an incident in ServiceNow, using Twilio
 

Success!

Conclusion

In this tutorial, you learned how to configure ServiceNow Notify for basic SMS and conference calls, and learned 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: