detect_machine
A detection method that combines AMD (Answering Machine Detection) and fax detection.
Detect whether the user on the other end of the call is a machine (fax, voicemail, etc.) or a human.
The detection result(s) will be sent to the specified status_url as a POST request and will also be saved in the
detect_result variable.
An object that accepts the detect_machine parameters.
detect_machine parameters
falseIf true, stops detection on beep / end of voicemail greeting.
amd,faxComma-separated string of detectors to enable. Valid Values: amd, fax
1.0How long to wait for voice activity to finish (in seconds).
4.5How long to wait for initial voice activity before giving up (in seconds).
value of the end_silence_timeout parameterHow long to wait for voice activity to finish before firing the READY event (in seconds).
1.25The number of seconds of ongoing voice activity required to classify as MACHINE.
6The minimum number of words that must be detected in a single utterance before classifying the call as MACHINE.
The HTTP(S) URL to deliver detector events to. Learn more about status callbacks.
CEDThe tone to detect. Only the remote side tone will be received. (CED or CNG) Used for fax detection.
trueIf false, the detector will run asynchronously and status_url must be set. If true, the detector will wait for detection to complete before moving to the next SMWL instruction.
Variables
The following variables are available after the detect_machine method is executed and detection is complete.
You can reference these variables in your SMWL script utilizing the ${variable} syntax.
StatusCallbacks
A POST request will be sent to status_url with a JSON payload like the following:
The detection result. Valid values: HUMAN, MACHINE, FAX, UNKNOWN, finished.
Raw JSON example
{
"event_type": "calling.call.detect",
"event_channel": "swml:be38xxxx-8xxx-4xxxx-9fxx-bxxxxxxxxx",
"timestamp": 1745332535.668522,
"project_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"space_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"params": {
"control_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"detect": {
"type": "machine",
"params": {
"event": "HUMAN"
}
},
"call_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"node_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"segment_id": "xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
Examples
Play the detection result
- YAML
- JSON
version: 1.0.0
sections:
main:
- detect_machine:
status_url: 'https://example.com/detect-events'
timeout: 20
- play:
url: 'say:Detection result: ${detect_result}'
{
"version": "1.0.0",
"sections": {
"main": [
{
"detect_machine": {
"status_url": "https://example.com/detect-events",
"timeout": 20
}
},
{
"play": {
"url": "say:Detection result: ${detect_result}"
}
}
]
}
}
Conditional actions based on the detection result
- YAML
- JSON
version: 1.0.0
sections:
main:
- play:
url: "say: Welcome to the machine detection test."
- detect_machine:
status_url: "https://webhook.site/5c8abf82-b8c7-41c8-b5d6-b32a40068109"
detectors: "amd,fax"
wait: true
- cond:
- when: detect_result == 'machine'
then:
- play:
url: "say: You are a machine, goodbye."
- hangup: {}
- when: detect_result == 'human'
then:
- play:
url: "say: You are a human, hello."
- hangup: {}
- when: detect_result == 'fax'
then:
- play:
url: "say: You are a fax, goodbye."
- hangup: {}
- else:
- play:
url: "say: Unable to determine if you are a human, machine, or fax, goodbye. Result was ${detect_result}"
- hangup: {}
{
"version": "1.0.0",
"sections": {
"main": [
{
"play": {
"url": "say: Welcome to the machine detection test."
}
},
{
"detect_machine": {
"status_url": "https://webhook.site/5c8abf82-b8c7-41c8-b5d6-b32a40068109",
"detectors": "amd,fax",
"wait": true
}
},
{
"cond": [
{
"when": "detect_result == 'machine'",
"then": [
{
"play": {
"url": "say: You are a machine, goodbye."
}
},
{
"hangup": {}
}
]
},
{
"when": "detect_result == 'human'",
"then": [
{
"play": {
"url": "say: You are a human, hello."
}
},
{
"hangup": {}
}
]
},
{
"when": "detect_result == 'fax'",
"then": [
{
"play": {
"url": "say: You are a fax, goodbye."
}
},
{
"hangup": {}
}
]
},
{
"else": [
{
"play": {
"url": "say: Unable to determine if you are a human, machine, or fax, goodbye. Result was ${detect_result}"
}
},
{
"hangup": {}
}
]
}
]
}
]
}
}