How to use twilio spoke to call a user.

Tyler Johnson
Kilo Guru

Trying to get a way to create a customized message to be used when calling a user from the action. since im using flow designer i have a catalog item triggering this call that pulls in the incident variables at the start. 
The 

TwiML Instructions URL inside of the  Make a Call Without Recording action works with the test value from twilio https://demo.twilio.com/docs/voice.xml  this calls and plays the message and then the rick roll song for a test. im having trouble finding a way to either create a xml file/url i can use so i can use the pills in the flow from the incident to provide the number and more details dynamically to the call being made. 

1 REPLY 1

pr8172510
Kilo Guru

 

Hi Tyler,

Good question — this comes up quite a bit when trying to make Twilio calls dynamic from Flow Designer.

What’s happening is that the TwiML Instructions URL expects a publicly accessible endpoint that returns valid TwiML (XML). The demo URL works because Twilio hosts it, but for your use case you’ll need to generate that XML dynamically.

Here are a few ways to approach it:


1. You can’t directly pass Flow Designer pills into static TwiML URL
The URL field itself doesn’t interpret Flow variables. So if you’re trying to embed incident data directly there, it won’t work unless the endpoint processes it.


2. Best approach → Create a dynamic TwiML endpoint in ServiceNow

You can create a Scripted REST API (or Processor) in ServiceNow that:

  • Accepts parameters (incident number, short description, caller, etc.)
  • Dynamically builds TwiML response
  • Returns XML to Twilio

Example:

 

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

var incident = request.queryParams.incident;
var message = "Incident " + incident + " has been created. Please check.";

var twiml = '<?xml version="1.0" encoding="UTF-8"?>' +
'<Response>' +
'<Say voice="alice">' + message + '</Say>' +
'</Response>';

response.setContentType('text/xml');
response.setBody(twiml);

})(request, response);

Then in Flow Designer:

  • Set TwiML URL like:
    https://<your-instance>/api/.../twiml?incident=${Incident.Number}

This way your pills are passed as query params, and the endpoint builds the message dynamically.


3. Alternative → Host TwiML externally (less flexible)

You could host a static XML file externally, but:

  • No dynamic data
  • Not useful for incident-driven messaging

So this is usually not recommended.


4. Make sure your instance is reachable

Twilio must be able to access your endpoint:

  • Instance should be publicly accessible
  • No auth blocking (or use basic auth / token if configured properly)

5. Test your TwiML endpoint separately

Before plugging into Flow:

  • Open the URL in browser / Postman
  • Confirm it returns valid XML
  • Then use it in Twilio action

6. Debugging tips

  • Check Twilio call logs (you’ll see if TwiML fetch fails)
  • Add gs.info() in your Scripted API
  • Validate XML format (invalid XML = silent failure)