Intelligent outbound call callback API
After you initiate a call using the voice service API, the voice service sends the transcribed text back to your business through the callback HTTP interface for intelligent outbound calls. Your business then returns the next action to the voice service, which facilitates the Intelligent Speech Interaction between the bot and the user. This topic describes the configuration, request parameters, response parameters, and request and response examples for the callback HTTP interface for intelligent outbound calls used in Intelligent Speech Interaction.
Business process
The voice platform uses the HTTP protocol to push real-time speech-to-text transcripts. The voice platform sends an exception status even when the user is silent. In the response message, you can specify the platform's next action, such as playing an audio file, stopping the current audio playback, transferring the call to an agent, or hanging up. For a complete description of the business process for Intelligent Speech Interaction outbound calls, see Intelligent Speech Interaction outbound call business process.
Configure the callback API
-
Log in to the Voice Service console.
-
In the left-side navigation pane, go to and turn on the Intelligent Speech Interaction Callback URL switch.
-
In the Callback URL field, enter a callback URL (for example,
https://push.example.com/contextpath/receive.do). The Response Info area shows the required JSON response format. This information is read-only.NoteThe callback URL receives real-time speech-to-text results and returns the next action.
ImportantBefore saving, ensure that the server corresponding to the receiving address is fully deployed and can return a response in the required JSON format. The response must contain the
result,msg,code, anddatafields, where thedatafield must contain thecall_id,action,action_code, andextendfields. For the specific format, see the Response Example section. -
Click Save. The system sends a one-time HTTP validation request to the callback URL to verify that the response conforms to the specified JSON format. If the callback URL is unreachable or the response format is incorrect, the settings will not be saved.
-
You can also click Test on the right to verify the configuration.
Callback API
|
Parameter |
Description |
|
Protocol |
HTTP |
|
Method |
POST |
|
Character encoding |
UTF-8 |
Request example
http://127.0.0.1/test?call_id=100001616500^1000018****×tamp=1504174341229&content_type=normal&content={"words": "Hello","begin_offset": "1000","end_offset": "9000","begin_time": "2017-06-01 10:00:00"}
Request parameters
|
Parameter |
Type |
Required |
Example |
Description |
|
call_id |
String |
required |
100001616500^1000018**** |
The unique ID for the call. |
|
timestamp |
Long |
required |
1504174341229 |
The request timestamp, in milliseconds. |
|
content_type |
String |
required |
normal |
The message type. Valid values:
|
|
content |
JSON |
required |
{"role": "B","identity": "id2","words": "Hello","begin_offset": "1000","end_offset": "9000","begin_time": "2017-06-01 10:00:00"} |
The voice content in JSON format. For details, see the following tables. |
When content_type is set to normal, the content parameter contains the following fields:
|
Parameter |
Type |
Required |
Example |
Description |
|
words |
String |
required |
Hello |
The transcribed text of an utterance. |
|
begin_offset |
String |
required |
6000000 |
The start time of the utterance, as an offset in milliseconds from the beginning of the session. |
|
end_offset |
String |
required |
7000000 |
The end time of the utterance, as an offset in milliseconds from the beginning of the session. |
|
begin_time |
String |
required |
7000000 |
The call start time, as a Unix timestamp in milliseconds. |
|
is_playing |
String |
optional |
true |
Specifies whether audio is currently playing. |
|
current_media_code |
String |
optional |
xxxx.wav |
The audio file that is currently being played. If the value is 'early_media', it indicates an early media message. |
|
dynamic_id |
String |
optional |
abcdefgh |
A custom dynamic extension ID. This ID is returned in subsequent callback URLs for tracking purposes. |
|
record_begin_time |
Long |
optional |
1543856399000 |
The recording start time, as a Unix timestamp in milliseconds. |
|
asr_begin_time |
String |
optional |
1543856399000 |
The user speech start time, as a Unix timestamp in milliseconds. |
|
asr_end_time |
String |
optional |
1543856399000 |
The user speech end time, as a Unix timestamp in milliseconds. |
|
play_begin_time |
String |
optional |
1543856399000 |
The server playback start time, as a Unix timestamp in milliseconds. |
|
play_end_time |
String |
optional |
1543856399000 |
The server playback end time, as a Unix timestamp in milliseconds. If playback has not finished, the value is 0. |
When content_type is set to mute, the content parameter contains the following fields:
|
Parameter |
Type |
Required |
Example |
Description |
|
dynamic_id |
String |
optional |
abcdefgh |
A custom dynamic extension ID. This ID is returned in subsequent callback URLs for tracking purposes. |
When content_type is set to dtmf, the content parameter contains the following fields:
|
Parameter |
Type |
Required |
Example |
Description |
|
dynamic_id |
String |
optional |
abcdefgh |
A custom dynamic extension ID. This ID is returned in subsequent callback URLs for tracking purposes. |
|
dtmf_digits |
String |
optional |
1 |
The DTMF key pressed by the user. If no key is pressed before the timeout, the value is 'noInputTimeout'. |
When content_type is set to timebreak, the content parameter contains the following fields:
|
Parameter |
Type |
Required |
Example |
Description |
|
current_media_code |
String |
optional |
xxxx.wav |
The audio file that is currently being played. |
|
asr_begin_time |
String |
optional |
1543856399000 |
The user speech start time, as a Unix timestamp in milliseconds. |
|
play_begin_time |
String |
optional |
1543856399000 |
The server playback start time, as a Unix timestamp in milliseconds. |
|
dynamic_id |
String |
optional |
abcdefgh |
A custom dynamic extension ID. This ID is returned in subsequent callback URLs for tracking purposes. |
When content_type is set to parallel_transfer, the content parameter contains the following fields:
|
Parameter |
Type |
Required |
Example |
Description |
|
dynamic_id |
String |
optional |
abcdefgh |
A custom dynamic extension ID. This ID is returned in subsequent callback URLs for tracking purposes. |
|
transfer_status |
String |
optional |
success\fail |
The status of the parallel transfer. Valid values: 'success' and 'fail'. |
|
fail_cause |
String |
optional |
transfer fail. |
The reason for the transfer failure. This field is present only when transfer_status is 'fail'. |
|
is_monitor |
Boolean |
optional |
true |
Specifies whether to monitor the call after it is successfully transferred to a call center. |
|
cc_name |
String |
optional |
aliyun_cc |
The name of the call center to which the call was successfully transferred. |
Response examples
Successful call
{
"result": "success",
"msg": "success",
"code": 200,
"data": {
"call_id": "100001616500^100001871490",
"action": "play",
"action_code": "411111",
"extend": "111"
}
}
Failed call
{"result":"fail","msg":"fail reason", "data":{}}
Return parameters
|
Parameter |
Type |
Required |
Example |
Description |
|
call_id |
String |
Required |
B |
The unique identifier for the call. |
|
action |
String |
Required |
play |
Specifies the next action to perform. Valid values:
|
|
action_break |
Boolean |
Optional |
true |
Specifies whether to break the previous action. Defaults to |
|
action_code |
String |
Optional |
abc.wav,def.wav,$name$ |
The code for the audio file to play. To play multiple files, separate their codes with a comma. This parameter supports TTS variables, which must be enclosed in dollar signs ( |
|
action_code_break |
Boolean |
Optional |
true |
Specifies whether the playback of the current media file can be broken. Valid values:
Note
The |
|
mute_time |
Integer |
Optional |
10000 |
The duration of silence, in milliseconds (ms). The value must be between 1,000 and 20,000. If the value is outside this range, the system uses the default value of 10,000. |
|
dynamic_id |
String |
Optional |
abc |
An opaque string for tracking the request. The system passes this ID back in the subsequent callback URL. |
|
action_code_param |
String |
Optional |
{"name":"Hello, there"} |
The TTS parameters in JSON format. The keys in this object correspond to the variables specified in |
|
number |
String |
Optional |
1370000**** |
The destination phone number for the transfer. This parameter is valid only when |
|
action_code_time_break |
Integer |
Optional |
120 |
The duration of continuous user speech, in milliseconds (ms), that triggers a break. If the |
|
dtmf_nonin_overtime |
Integer |
Optional |
3 |
The no-input timeout in seconds (s), specific to the |
|
dtmf_max_numbers |
Integer |
Optional |
5 |
The maximum number of digits to collect, specific to the |
|
dtmf_end_character |
String |
Optional |
# |
The character that terminates digit collection. This parameter is specific to the |
|
transfer_playfile |
String |
Optional |
# |
The audio file to play to the agent after a successful parallel transfer. |
|
is_monitor |
Boolean |
Optional |
true |
Indicates whether to monitor the call after a successful parallel transfer to a call center. |
|
cc_name |
String |
Optional |
aliyun_cc |
The name of the destination call center for a successful parallel transfer. |
Usage
The Intelligent Speech Interaction outbound callback HTTP interface pushes real-time speech-to-text results and interaction statuses for a single call. This interface does not record or return a cumulative call count. To get a total call count, use the call record query APIs to retrieve call logs and then aggregate the results yourself.