OIC Integration: ServiceNow and Twilio Integration for Voice and SMS Notifications
Updated: Jun 21
The OIC REST Service built to integrate ServiceNow and Twilio in same flow enables automated ServiceNow incident creation and notification to support engineer about the same incident via Voice call and SMS instantaneously. With this OIC service in place, the support teams can be engaged almost immediately for any issue. This integration can be an enabler in implementing a shift from on-desk support to on-call support for priority incidents. As the interface to this service is REST API based, it can be plugged into any application/database/scripting language that supports a REST call.
To implement this service in OIC, we need to have a ServiceNow account and Twilio subscription. We also need to make several configurations in Twilio, like the number that will initiate outbound call, message to be relayed and certain security settings (I have detailed those in next sections). OIC DVMs hold the information on which support engineer to be called and their contact info. Once we have these setups in place, we can simply deploy this service on any OIC instance.
I used a trail Twilio subscription to do this POC. Once you login into Twilio account, perform the following:
a) Security Parameters: Note down the following highlighted values that will be required in security configuration of the Twilio Adapter.
b) Register Numbers: You would need 2 numbers, one trail number that will initiate the outbound call (provided by Twilio) and second verified number(your own number), that will receive the call. You can have multiple verified numbers in trail account. So you can make calls to different numbers.
c) Setup Voice Message: Create a TwiML App and paste the url of the Voice response message there. Note down the SID of this message, it needs to passed as request parameter.
Here is the sample voice message xml:
A few configurations are required on ServiceNow so that we could create an incident seamlessly using OIC ServiceNow Adapter.
a) Admin User: It is preferred to have a separate user with admin access that will be used to
create an incident.
b) ws-access on Tables: Enable ws-access on sys_plugins and sys_package tables.
OIC Integration Service
Once the above configurations are done, we are good to go with the OIC integration service build. Lets look at the connections setting required for this service.
ServiceNow Adapter (invoke): We will use this adapter to create an incident in ServiceNow Instance. We need to add the ServiceNow Instance URL and choose Basic Auth under security and provide the credentials as shown below.
Twilio Adapter (Invoke): This adapter will be used to send SMS Notifications to the Support Engineer. We will need only two parameters while creating this connection. You can refer the Twilio configuration section above to get these 2 values for your account.
Important Note: Currently, OIC Twilio Adapter does not support Voice/Audio Calls. I have used the native Twilio APIs to integrate that function in OIC. That is explained in detail in next section.
REST Adapter (invoke): This adapter will be used to invoke native Twilio API's for Voice/Audio calls integration. Here you need to add the Twilio Account url with basic auth in security. That will be your AccountSID and AuthToken again.
REST Adapter (trigger): This adapter will be used to exposed this service as REST and it will be the entry point of the integration.
Integration Service: Now we will bind all these adapters/connections in OIC Integration Service. Below is the complete flow design:
We need to choose "App Driven Orchestration" Integration pattern for the options and drag the "Incident API" REST connection in the trigger section and add the following configurations.
After this, we need to drag the "ServiceNow" connection in the flow that will automatically generate the map activity for source to target payload mapping. You need to choose "Create Update and Delete" Action and select "incident" from Table names in the Adpater. Once that is done, the request payload elements will generate in the Map activity for mapping. Here are the screenshots for that.
Similarly we have to do for "makeCall" REST connection, as mentioned before, here we are using native Twilio APIs to integration the audio/voice call function. OIC Twilio adapter does not provide this capability at present. This is a POST call that needs the following four request parameters.
Important Point: You need to select the "Send query parameters as form data in message body" otherwise it will not work.
Please refer the below screenshots for configuration details and mapping. I have used the lookups for "To" mapping and "applicationSID" is the value you noted in section c) of Twilio configurations above.
Now we are in the last leg of the Integration, here we will configure the SMS functions and you will notice that Twilio Adapter does not offer the Voice/Audio Call functions in the adapter, hence we used the makeCall REST api above for it. For SMS, we will need 3 request parameters to make the call.
"To": Again I picked it from lookup values (makes it easier to change the SMS and Call recipient with a single change)
"From": Fixed value. YOu will get this from your Twilio subscription.
"Body": This is the SMS body, here I have included the Incident number generated in earlier ServiceNow call in the SMS body.
After this, I just map the reply to calling service. And it concludes the Integration.
Here is my service invocation from Postman. Within a few seconds an Incident was raised in ServiceNow and I received the Call and an SMS.
Thanks for going through this blog and I hope it helped in achieving your goal in some way!