If you are using the Cognigy Voice Gateway with a Twilio Elastic SIP Trunk, you can easily create outbound calls by following the setup process in this article.
An outbound call is triggered by an http request sent to Twilio. This type of outbound calling places a outward call from Twilio number to the end user. It then immediately redirects the call inbound to the voice gateway.
Requirements
There are two components required to do this:
- TwiML Bin - handles the call by forwarding to the VAIG number
- API request - initiates a call to a PTSN number
- Twilio Elastic SIP Trunk and number connected to Cognigy Voice Gateway
Access Requirements:
- Twilio console access
1) Create a TwiML Bin
Start in the Twilio console, and open the "TwiML Bins" menu under the "Developer tools" section.
Add a new TwiML bin by clicking the +.
Give your TwiML bin a friendly name and add the following TwiML code:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>+49XXXXXXXXXX</Number>
</Dial>
</Response>
Make sure to replace the number with one of your configured Twilio Elastic SIP Trunk numbers that is connected to the Cognigy Voice Gateway.
Once you have saved the TwiML bin, the URL will be provided. Copy this URL and use it in the Outbound call API referenced below.
2) Send a Twilio Outbound Call API request:
The Twilio Calls API is documented here: https://www.twilio.com/docs/voice/make-calls
You will need to send a POST request with the following body in "x-www-form-urlencoded"
Type: POST
URL: https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Calls.json
Auth: Basic Auth (Account SID and Token)
Header: "Context-Type" : "application/x-www-form-urlencoded"
Body: "x-www-form-urlencoded"
- From = <Any Number configured to your Twilio Account in format +49XXXXXXXXXX>
- To = <The PTSN number you wish to call in format +49XXXXXXXXXX>
- Url = <The URL from your TwiML Bin created earlier>
Send the API request and the call will be placed to the specified number. A short dial tone will be heard on answering which is Twilio forwarding the call to the Voice Gateway.
Comments
0 comments