The CreatorCon Call for Content is officially open! Get started here.

Paul Lathrop1
ServiceNow Employee
ServiceNow Employee

It's easy to create Twilio sub-accounts in ServiceNow using Flow Designer and a REST Action. 

1) Create a trigger. Since this is a 'hello world" I kept it super simple. On update of Customer [customer_account], run trigger once. Silly simple just to get to test the creation of sub-accounts in Twilio

find_real_file.png

Next I jump right in and create the REST Action.

First let's take a look at the Twilio API docs:

find_real_file.png

Also you can test this call from the Twilio Console for your account:

find_real_file.png

Ok now you have the call structure down and see what it's like you're ready to go.

Back in the Flow Designer we create a new Action. For the input we're going to use Company Name, and for the Output we're going to use Body. 

Click on the Green Arrow + and create a new step - scroll down to Integrations on the Popup and click on REST.

find_real_file.png

Ok this is where we are really getting things done. In fact, we could have started from this spot and tested it from here and been a lot farther along but this is my process.

find_real_file.png

We define connection inline, add the credential alias for sn_twilio_direct.twilio_direct_credential and if you click on the little circle (i) button you can add your Account SID and Auth Token. That covers authentication.

Your base URL is https://api.twilio.com/2010-04-01/Accounts.json

Next I build request Manually, HTTP Method POST, and Query Parameters are FriendlyName and then I drag the Input Data Pill CompanyName into the Value field.

Now you can Save, Publish, and Test! You'll see the JSON structures that you also saw in the Twilio Docs, and Console Test. Now you can just add this action into your flow and  test it and run it.

find_real_file.png

I just ran this test into a Log action to see the JSON response body.

find_real_file.png

In a real deployment I would Parse that JSON response and add the Account SID and Auth Token to a safe place in ServiceNow. Perhaps I'd leave this part hidden from my user! I'd use Flow Designer to fill in the required fields in which the ServiceNow Twilio spoke needs Account SID and Auth Token.

Thanks! This was a fun little project!

 

 

 

 

 

 

Version history
Last update:
‎04-16-2021 08:03 AM
Updated by: