This API will connect the two numbers given for the agent and customer. It will connect ‘From’ number first. Once the person at ‘From’ end picks up the phone, it will connect to the number provided in the ‘To’. You can choose which number to be connected first by giving that number in the ‘From’ field.


An HTTP POST request to 

https://~exotel_sid~:~exotel_token~@api.exotel.com/v1/Accounts/~exotel_sid~/Calls/connect  

has to be made.


Replace ~exotel_sid~ and ~exotel_token~ with the values from the Exotel Settings tab of your Exotel portal.


The following are the POST parameters:

PARAMETER NAME
MANDATORY/OPTIONAL
VALUE
From
Mandatory

The Agent phone # that will be called first
If mobile number, prefix the 10 digits with a 0; Ex:  09052161119.
If landline number, prefix it with STD code; Ex: 08030752400

To
Mandatory

Your customer's phone number.
If mobile number, prefix the 10 digits with a 0; Ex: 09052161119.
If landline number, prefix it with STD code; Ex: 08030752400

CallerId
Mandatory

This is your Exotel Number (pick one from the 'Company Numbers' page)

CallType
Mandatory

"trans" - for Transactional Calls 
"promo" - for Promotional calls No longer supported by Exotel

TimeLimit
Optional
The time limit (in seconds) that you want this call to last. The call will be cut after this time. (max. 14400 i.e. 4 hours)
TimeOut
Optional

The time (in seconds) to ring the called parties (both first and second call leg)

StatusCallback
Optional

When the call completes, an HTTP POST will be made to the URL mentioned with the following four parameters:
CallSid - an alpha-numeric unique identifier
Status - One of: completed, failed, busy, no-answer.
RecordingUrl - link to the call recording (if it exists)
DateUpdated - time when the call state was updated last

MaxRetries Optional     Number of times the call should be retried if we get failed or no-answer status from 1st leg.
(Default value: 3)


HTTP Response:


On success, 

  • the HTTP response status code will be 200
  • the HTTP body will contain an XML similar to the one below. The "Sid" is the unique identifier of the call and it will be useful to log this for future debugging purposes.
<?xml version="1.0" encoding="UTF-8"?>

<TwilioResponse>

 <Call>

  <Sid>xxxxxxxxxxxxxxxxxxxx</Sid>

  <ParentCallSid/>
  <DateCreated>2012-08-17 12:31:49</DateCreated>
  <DateUpdated>2012-08-17 12:31:49</DateUpdated>
  <AccountSid>xxxxxxxxx</AccountSid>
  <To>09052161119</To>
  <From>09739761117</From>
  <PhoneNumberSid>xxxxxxx</PhoneNumberSid>
  <Status>in-progress</Status>
  <StartTime>2012-08-17 12:31:49</StartTime>
  <EndTime>2012-08-17 12:32:57</EndTime>
  <Duration></Duration>
  <Price></Price>
  <Direction>outbound-api</Direction>
  <AnsweredBy/>
  <ForwardedFrom/>

  <CallerName/>

  <RecordingUrl/>
  <Uri>/v1/Accounts/xxxxxxxx/Calls/xxxxxxxxxxxxxx</Uri>
 </Call>
</TwilioResponse>



On failure,

  • the HTTP response status code will be non-200.
  • the HTTP body will contain an XML (such as the one below) with details of why the request failed.


<TwilioResponse>
  <RestException>
    <Status>404</Status>
    <Message>No matching results</Message>
  </RestException>
</TwilioResponse>


Rate Limit:

This API is rate limited to 200 calls per minute. Once this limit has been crossed, your requests will be rejected with an HTTP 429 'Too Many Requests' code.


Sample PHP Code:

An example PHP code for this is available in Github 

Sample Ruby Code:

Sample code available at Github and Ruby Gem available at rubygems.org


Need a techie for this integration?
Check our Phone a Friend App