FlexML Responses
Introduction
The response to the CarrierX request should include FlexML instructions. Each set of FlexML instructions is wrapped within Response
wrapper start and end tags. Tags nested inside of Response
tags are called verbs, and attributes that modify these verbs are simply referred to as supported attributes. The verbs are executed from top to bottom. However, some instructions will break the flow, and the remainder of the verbs will not be executed.
Sample FlexML
<Response>
<Gather action="http://www.example.com/path/to/handler" timeout="5">
<Say>Please enter the extension of the party you would like to reach. </Say>
</Gather>
<Say>You did not enter an extension. </Say>
<Hangup />
</Response>
In this example, once the call has been connected, the called party will be prompted by the Say
message to enter the extension of the party they are trying to reach. The called party has five seconds to enter the extension because timeout
is set to 5
. If digits are entered, the action
URL will be requested, and the FlexML instructions at that URL will be executed. The rest of the FlexML instructions in the current instructions will be ignored.
If the called party does not enter digits after the 5
seconds has elapsed, the instructions will proceed to the Say
verb below Gather
. Then the Hangup
verb will be executed.
Status Callbacks
Data about completed calls can be received by setting status_callback_url
and status_callback_method
in the Call object or the DID object. The response to this request is not used. If a status_callback_url
is set on both the Call object and DID object, the URL set on the Call object will be used.
The status_callback_url
and status_callback_method
can also be overridden using the Override
verb in a FlexML response. Please refer to the Override section for more information.
Request Data
These status callback fields are in addition to the fields listed in the Requests section.
Attribute | Data Type | Description |
---|---|---|
CallDuration | integer | The duration of the call in seconds. |
PlaybackUrl | string | The URL of the file that was played. |
PlayOffset | integer | The position of the playback from the beginning of the file when the call ends (either played or skipped to using DTMF controls). |
RequestMethod | string | The type of request made to the |
RequestUrl | string | The initial URL to which the request was made, as set in the Call object or DID object. |
Successful requests return a JSON response that looks like the following:
{
"AccountSid":"",
"ApiVersion":"2.0",
"CallDuration":8,
"CallerName":"",
"CallSid":"4695bc4a0932bcd2e99492e523db9ee2",
"CallStatus":"completed",
"Direction":"inbound",
"From":"15162065338",
"OriginalFrom":"+15162065338",
"OriginalTo":"15162065337",
"PlaybackUrl":"https://storage.carrierx.com/f/5fac56c8-c9fa-4d0e-bf88-f114e0d0cfab.mp3",
"PlayOffset":37,
"RequestMethod":"GET",
"RequestUrl":"https://sampleurl.com/example",
"To":"15162065337"
}