Trigger a Call in Twilio

Description

In addition to receiving calls from Twilio within Cognigy.AI, you can also trigger Twilio to make a call.

Cognigy will use a HTTP Node to trigger Twilio to make a call and then connect the call back to a Cognigy.AI Flow.

For this, you need to perform the following steps:

1. Set up a Flow that the call will connect to

First you need to set up a Flow and Twilio Voice Endpoint in Cognigy and connect them to a Twilio number as per Deploy a Twilio Voice Endpoint.

2. Set up a TwiML Bin

Twilio can host TwiML for you. For that, create a TwilML bin under Runtime. This TwiML is called from Cognigy.AI and tells Twilio what to do after the call connects.

1069

You can see the TwiML to use below. Replace YOUR ENDPOINT URL with a valid Cognigy Endpoint URL.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Redirect>YOUR ENDPOINT URL</Redirect>
</Response>

Copy the TwiML Bin URL. You'll need it later.

3. Trigger the call from Cognigy

Build a Flow that contains a HTTP Request Node with the following parameters:

ParameterValue
TypePOST
URLhttps://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_ACCOUNT_SID/Calls.json
HeadersContent-Type: application/x-www-form-urlencoded
Payload is JSONfalse
PayloadTo=NUMBER_TO_CALL&Url=YOUR_TWIML_BIN_URL&From=YOUR_TWILIO_NUMBER
Authorization TypeBasic Auth
UsernameYOUR_TWILIO_ACCOUNT_SID
PasswordYOUR_TWILIO_AUTH_TOKEN

You can find the Twilio Account SID and Auth Token on your Twilio Dashboard.

This HTTP Request will trigger the call, connect it to your Endpoint specified in the TwiML Bin and return a call SID, which you could use to tie sessions together using Contact Profiles.