Skip to main content

Connect Number to Call Flow

Call a phone number and connect them to an applet/IVR flow after they answer. Unlike Connect Two Numbers, this API uses a flow URL instead of a To number.

Request Parameters​

ParameterRequiredTypeDescription
FromYesStringThe phone number to call first.
CallerIdYesStringYour ExoPhone/virtual number.
UrlYesStringFlow URL: http://my.exotel.com/{your_sid}/exoml/start_voice/{app_id}
CallTypeNoStringtrans for transactional calls.
TimeLimitNoIntegerMax call duration in seconds. Max: 14400 (4 hours).
TimeOutNoIntegerTime in seconds to ring the called party before treating the call as unanswered. The timer runs only during ringing and stops once the call is answered.
StatusCallbackNoStringWebhook URL for call status updates.
StatusCallbackEventsNoArrayterminal, answered, or both.
CustomFieldNoStringMetadata passed to the applet via Passthru.
MachineDetectionNoStringEnable or Disable (default). Enables answering machine detection on Leg 1 (the From leg). Case-insensitive; omitting the parameter is treated as Disable. Empty string is invalid and returns 400.
AsyncAmdNoStringRequired when MachineDetection=Enable. Must be true — synchronous AMD is not supported. Any other value returns 400.
AsyncAmdStatusCallbackNoStringRequired when AsyncAmd=true. Absolute http or https URL that receives the AMD result.
StatusCallbackContentTypeNoStringmultipart/form-data (default) or application/json. Applies to both StatusCallback and AsyncAmdStatusCallback.
info

The Url parameter should point to a call flow (applet) configured in your Exotel dashboard. The app_id is the flow ID found in App Bazaar > My Apps.

Code Examples​

curl -u '<api_key>:<api_token>' -X POST 'https://api.exotel.com/v1/Accounts/<your_sid>/Calls/connect' \
-d 'From=+919876543210' \
-d 'CallerId=0XXXXXX4890' \
-d 'Url=http://my.exotel.com/<your_sid>/exoml/start_voice/<app_id>' \
-d 'CallType=trans' \
-d 'StatusCallback=https://yoururl.com/callback'

Response​

{
"Call": {
"Sid": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"ParentCallSid": null,
"DateCreated": "2017-03-03 12:30:24",
"DateUpdated": "2017-03-03 12:30:27",
"AccountSid": "your_sid",
"To": null,
"From": "09876543210",
"PhoneNumberSid": "0XXXXXX4890",
"Status": "in-progress",
"StartTime": "2017-03-03 12:30:27",
"EndTime": null,
"Duration": null,
"Price": null,
"Direction": "outbound-api",
"AnsweredBy": null,
"Uri": "/v1/Accounts/your_sid/Calls.json/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"RecordingUrl": null
}
}
note

When using a flow URL, the To field in the response will be null since the destination is a flow rather than a phone number. The call proceeds to the applet after the From party answers.

Answering Machine Detection (AMD)​

When MachineDetection=Enable, AMD runs in parallel with the call after Leg 1 (the From leg) answers. It classifies who picked up — a human or an answering machine / voicemail — without ending the call. The result is delivered to your AsyncAmdStatusCallback mid-call (not on StatusCallback), so you can act on it while the call is still live. AMD does not auto-hangup; your application decides what to do next.

Validation rules​

ConditionResult
MachineDetection omittedTreated as Disable; AMD params ignored
MachineDetection=DisableAMD params present but ignored; no 400
MachineDetection=Enable, valid AsyncAmd=true and AsyncAmdStatusCallbackAMD enabled
MachineDetection=Enable, missing or invalid AsyncAmd or AsyncAmdStatusCallback400
MachineDetection= (empty string)400

AsyncAmdStatusCallback payload​

Exotel POSTs to your URL when AMD completes. This can fire even if the call has already ended.

FieldTypeDescription
CallSidStringCall SID
AccountSidStringAccount SID
AnsweredByStringHUMAN, MACHINE, or NOTSURE
AmdCauseStringCause string from the AMD engine (e.g. HUMAN, INITIALSILENCE-2500-2500). Numbers inside the cause are detector thresholds in milliseconds, not the detection duration. Empty string when not provided.
MachineDetectionDurationStringAMD detection time in whole seconds, as a string (e.g. 4). 0 when AMD completes within the same second. Empty string when not provided.
CallStatusStringCall state at the time AMD completed (e.g. in-progress, completed). Reflects the state at the time of the result; it does not change the call.

Content-Type defaults to multipart/form-data. Pass StatusCallbackContentType=application/json on the original request to receive JSON instead.

Acting on the result​

AMD reports the outcome; your application decides the next step. When you receive a MACHINE verdict at your AsyncAmdStatusCallback, common patterns are:

  • Hang up the call — stop engaging a voicemail or IVR, so you don't spend time (and, in a voicebot flow, tokens) on a machine.
  • Drop a voicemail, then hang up — play a pre-recorded message for the machine, then end the call.

Call control — ending the call or playing audio on a live leg — is performed through the Legs & Bridges API (for example, the ExoML Hangup action). AMD itself never hangs up the call.

note

AnsweredBy is always one of HUMAN, MACHINE, or NOTSURE. AmdCause and MachineDetectionDuration are passed through from the telephony layer and may be empty for a given call.

Try It​