Make an Outbound Call

With the REST api, you can make an outbound call to your customer. You can connect the call to your voice application.

Use Case:

  • Build an authentication system where you will call the customer and say the pin code.
  • Create a click to call button and connect the call to your call center.

To allow you to complete the call, we need the follow parameters in the post headers.

apikey: “YOURSECRECTAPIKEY”
from: This will be the Caller ID of the call.
to: Number that should be Dialed
url: This is web url, where your application reside, this URL will be called as soon as call is connected. If no URL, then call will be automatically connected to FROM number.

Once you have the post variables ready, you will call the URL to complete the call.

https://api.didforsale.com/didforsaleapi/index.php/api/V2/CallTermination/

Here is an example from curl.

Once we authenticate your account based on the API key, system will call 19499300360. As soon as person pickup the call system will execute further instruction from hello-world.php.

In another example if you want to authenticate a user by sending him secret pin.

Once the caller pick up the call, voice application system will call http://www.didforsale.com/apidemo/9499300360-authenticate.xml.

Code for 9499300360-authenticate.xml. PS: 9499300360-authenticate.xml should be generate dynamically for that particular session.

Now the system will say the message ” Your pin is 8 9 70″

This is how you can create a simple authentication system.

Advanced options: With these advanced attributes you can get the call status while system to trying to complete the calls.

Attributes

Attribute
Value
Default
url url none
Method POST/GET POST
senddigits any number digit none
statusCallbackEvent initiated, ringing, answered, completed completed
statusCallback status call back url none
statusCallbackMethod GET/POST post
secretKey proviateapikey none
optional specialtoken none

Attributes details:

url

If url is detected, phone system will call the to number, called a_leg and will send the answered call to the application. This happens only once the call is answered. This is use full for creating a click to call feature, and connecting the call to the call center.

sendDigits

This attribute, send dtmf digits once the call is answered. For example if you know call is being answered by the IVR and you digits needs to be pressed to connect the call to the destination number. There are two special key ‘w’ and ‘W’. If detect ‘w’ phone system wait for 0.5 seconds and if ‘W’ system wait for 1 second before sending next digits. Example ‘WWWW101’ system will wait for 5 seconds before sending 101.

Sample SendDigits

statusCallbackEvents

When the system made an outbound call, there are 4 things happens: “initiated”, means system is ready to make a call. “ringing” means end users phone is ringing, “answered”, enduser picked up the call, “completed”, end of the call. statusCallbackEvent event allows you to subscribe for for notifications for these events.

statusCallback

You must specify the callback url if you want to receive the events. This url will be called for all the events.

statusCallback Parameters:

Here is list of parameters you receive for each event.

Parameter Description
Called Number Dialed
ParentCallSid Call id of A Leg
CallStatus One of the event “initiated, ringing,
answered, completed”
Direction Call Direction”Inbound/Outbound”
callSid Orginal call ID
CallbackSource call-progress-event
CallDurartion Only on Completed Event
RecordingURL If Recording Enabled and only on Completed Event

Example statuscallback and statuscallbackevents.

Here system will call 19499300360 and send the event to http://www.didforsale.com/apidemo/event.php, once connected system will call 18005797676 and send the events of bleg to the same url, http://www.didforsale.com/apidemo/event.php

secretKey:

If your status callback url is at secure location and you want to provide access only using an API key, you can send your secret key and in the post variables, we will send the secret key as apikey=$secretkey

Optional:

These are optional token that we can append back to your callback url. Example you want to see special token called “token=123456”, we will send this optional string along with other data in the call back event.