Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Answering Machine Detection



Answering Machine Detection

answering-machine-detection page anchor

Answering Machine Detection (AMD) enables you to determine the receiving side of an outgoing call and tailor your call flow accordingly. With AMD you can determine if a human, answering machine or fax machine has picked up an outbound voice API call. Once AMD has executed and made its decision, the caller is connected to the callee.

AMD can also be executed asynchronously: the callee is connected immediately and AMD is executed in the background.

Twilio's AMD operates in two modes, depending on whether you need to leave a voicemail as part of your call flow. The default AMD mode tries to balance recognition speed and accuracy. You may also tune the performance of the engine based on your use case via optional API parameters.

Please see the following API parameters for configuring AMD on your outbound calls.


/Calls API parameters

calls-api-parameters page anchor
Parameter NameAllowed ValuesDefault Value
MachineDetectionEnable or DetectMessageEndnone
AsyncAmdtrue or falsefalse
AsyncAmdStatusCallbackMethodPOSTPOST
AsyncAmdStatusCallbackAbsolute or relative URLnone

MachineDetection

machinedetection page anchor

Use Enable if you would like Twilio to return an AnsweredBy value as soon as it identifies the called party. This is useful if you would like to take a specific action — for example, connect to an agent, play a message) — for a human but hang up on a machine.

If you would like to leave a voicemail on an answering machine, specify DetectMessageEnd. In this case, Twilio will return an AnsweredBy immediately when a human is detected but for an answering machine, AnsweredBy is returned only once the end of the greeting is reached, usually indicated by a beep.

Select whether to perform AMD in the background. When this is true, the call is continued while AMD makes its decision in the background. When this is false, which is the default, Twilio blocks the execution of the call until AMD is completed.

AsyncAmdStatusCallbackMethod

asyncamdstatuscallbackmethod page anchor

The HTTP method that we should use to send the results of the AMD.

The absolute or relative URL that we should call using the AsyncAmdStatusCallbackMethod to notify whether the call was answered by a human, machine or fax. When AMD makes a decision, Twilio will make a request to this URL with the following parameters:

ParameterDescription
CallSidA unique identifier for this call, generated by Twilio
AccountSidYour Twilio account ID. It is 34 characters long, and always starts with the letters AC
AnsweredByThe result of answering machine detection. If Enable was specified, results can be: machine_start, human, fax, unknown. If DetectMessageEnd was specified, results can be: machine_end_beep, machine_end_silence, machine_end_other, human, fax, unknown
MachineDetectionDurationTime in milliseconds that AMD took to reach a verdict

Optional API tuning parameters

optional-api-tuning-parameters page anchor

AMD uses an algorithm that isolates human speech audio and measures periods between speech and silence in the greeting, and then uses this data to determine the answering party. Since not all humans and not all voicemail greetings follow similar patterns in answering calls, it's possible that AMD will not always return the right answer. The AMD engine may, for example, interpret a very short two-second voicemail greeting as a human picking up.

With this imperfection in mind, we have provided four optional parameters that allow customers to tune the performance of the AMD engine.

Parameter NameAllowed ValuesDefault Value
MachineDetectionTimeoutBetween 3 and 5930
MachineDetectionSpeechThresholdBetween 1000 and 60002400
MachineDetectionSpeechEndThresholdBetween 500 and 50001200
MachineDetectionSilenceTimeoutBetween 2000 and 100005000

The number of seconds that Twilio should attempt to perform answering machine detection before timing out and returning AnsweredBy as unknown.

Increasing this value will provide the engine more time to make a determination. This can be useful when DetectMessageEnd is provided in the MachineDetection parameter and there is an expectation of long answering machine greetings that can exceed 30 seconds.

Decreasing this value will reduce the amount of time the engine has to make a determination. This can be particularly useful when the Enable option is provided in the MachineDetection parameter and you want to limit the time for initial detection.

The number of milliseconds that is used as the measuring stick for the length of the speech activity. Durations lower than this value will be interpreted as a human, longer as a machine.

Increasing this value will reduce the chance of a False Machine (detected machine, actually human) for a long human greeting (e.g., a business greeting) but increase the time it takes to detect a machine.

Decreasing this value will reduce the chances of a False Human (detected human, actually machine) for short voicemail greetings. The value of this parameter may need to be reduced by more than 1000ms to detect very short voicemail greetings. A reduction of that significance can result in increased False Machine detections. Adjusting the MachineDetectionSpeechEndThreshold is likely the better approach for short voicemails. Decreasing MachineDetectionSpeechThreshold will also reduce the time it takes to detect a machine.

The number of milliseconds of silence after speech activity at which point the speech activity is considered complete.

Increasing this value will typically be used to better address the short voicemail greeting scenarios. For short voicemails, there is typically 1000-2000ms of audio followed by 1200-2400ms of silence and then additional audio before the beep. Increasing the MachineDetectionSpeechEndThreshold to ~2500ms will treat the 1200-2400ms of silence as a gap in the greeting but not the end of the greeting and will result in a machine detection. The downsides of such a change include:

  1. Increasing the delay for human detection by the amount you increase this parameter, e.g., a change of 1200ms to 2500ms increases human detection delay by 1300ms.
  2. Cases where a human has two utterances separated by a period of silence (e.g. a "Hello", then 2000ms of silence, and another "Hello") may be interpreted as a machine.

Decreasing this value will result in faster human detection. The consequence is that it can lead to increased False Human (detected human, actually machine) detections because a silence gap in a voicemail greeting (not necessarily just in short voicemail scenarios) can be incorrectly interpreted as the end of speech.

The number of milliseconds of initial silence after which an unknown AnsweredBy result will be returned.

Increasing this value will result in waiting for a longer period of initial silence before returning an 'unknown' AMD result.

Decreasing this value will result in waiting for a shorter period of initial silence before returning an 'unknown' AMD result.

Create a call with AMD

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_17
// Download the helper library from https://www.twilio.com/docs/node/install
_17
import twilio from "twilio";
_17
_17
// Find your Account SID and Auth Token at twilio.com/console
_17
// and set the environment variables. See http://twil.io/secure
_17
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17
const authToken = process.env.TWILIO_AUTH_TOKEN;
_17
const client = twilio(accountSid, authToken);
_17
_17
const call = await client.calls.create({
_17
from: "+18180000000",
_17
machineDetection: "Enable",
_17
to: "+1562300000",
_17
url: "https://handler.twilio.com/twiml/EH8ccdbd7f0b8fe34357da8ce87ebe5a16",
_17
});
_17
_17
console.log(call.sid);

Output

_38
{
_38
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_38
"annotation": null,
_38
"answered_by": null,
_38
"api_version": "2010-04-01",
_38
"caller_name": null,
_38
"date_created": "Tue, 31 Aug 2010 20:36:28 +0000",
_38
"date_updated": "Tue, 31 Aug 2010 20:36:44 +0000",
_38
"direction": "inbound",
_38
"duration": "15",
_38
"end_time": "Tue, 31 Aug 2010 20:36:44 +0000",
_38
"forwarded_from": "+141586753093",
_38
"from": "+18180000000",
_38
"from_formatted": "(415) 867-5308",
_38
"group_sid": null,
_38
"parent_call_sid": null,
_38
"phone_number_sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"price": "-0.03000",
_38
"price_unit": "USD",
_38
"sid": "CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_38
"start_time": "Tue, 31 Aug 2010 20:36:29 +0000",
_38
"status": "completed",
_38
"subresource_uris": {
_38
"notifications": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Notifications.json",
_38
"recordings": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Recordings.json",
_38
"payments": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Payments.json",
_38
"events": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Events.json",
_38
"siprec": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Siprec.json",
_38
"streams": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Streams.json",
_38
"user_defined_message_subscriptions": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessageSubscriptions.json",
_38
"user_defined_messages": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/UserDefinedMessages.json"
_38
},
_38
"to": "+1562300000",
_38
"to_formatted": "(415) 867-5309",
_38
"trunk_sid": null,
_38
"uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Calls/CAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json",
_38
"queue_time": "1000"
_38
}

AMD results are returned in the AnsweredBy parameter of the webhook issued to the URL you provide in the outbound call request.

ParameterDescription
AnsweredByThe result of answering machine detection.If Enable was specified, results can be:machine_start, human, fax, unknown.If DetectMessageEnd was specified, results can be: machine_end_beep, machine_end_silence, machine_end_other, human, fax, unknown.

Answering Machine Detection will be charged at $.0075 per call where enabled and the called party picks up. Busy or Failed calls may engage our AMD system but will not be charged.


See also: Answering Machine Detection FAQ and Best Practices

The life cycle of a call using AMD is shown below. The user experience of a recipient of a call using AMD is impacted if there is a delay from the time they pick up the phone to the first packet of audio they hear. Twilio has optimized our AMD system to quickly classify calls, but it's also important that you optimize your application to respond quickly.

Twilio AMD Call Progress.

Optimize TwiML responses

optimize-twiml-responses page anchor

To minimize delay, ensure that you benchmark your application to ensure that webhooks from Twilio are processed and responded to in a timely manner. In test applications running in EC2, we can get this time under 150ms. TwiML served from TwiMLBins typically comes in under 100ms.

Cache static TwiML and media for play verbs

cache-static-twiml-and-media-for-play-verbs page anchor

If you are using <Play> verbs, we recommend hosting your media in AWS S3 in us-east-1, eu-west-1, or ap-southeast-2 depending on which Twilio Region you are using. No matter where you host your media files, always ensure that you're setting appropriate Cache Control headers. Twilio uses a caching proxy in its webhook pipeline and will cache media files that have cache headers. Serving media out of Twilio's cache can take 10ms or less. Keep in mind that we run a fleet of caching proxies so it may take multiple requests before all of the proxies have a copy of your file in cache.

Benchmark response time with the Request Inspector

benchmark-response-time-with-the-request-inspector page anchor

To help you benchmark your server's response time to Twilio, we expose the request duration in milliseconds for every request in the Request Inspector. You can view these clicking into the Call Details page in the Console:

Fetch Time with the Request Inspector.

Rate this page: