Skip to content

Commit 72a6d5a

Browse files
authored
Create answer-machine-detection.md
implement answer machine detection documentation
1 parent aef8091 commit 72a6d5a

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Building Answer Machine Detection
3+
titleSuffix: An Azure Communication Services concept document
4+
description: Learn how to
5+
author: Kunaal
6+
ms.service: azure-communication-services
7+
ms.subservice: call-automation
8+
ms.topic: conceptual
9+
ms.date: 03/07/2025
10+
ms.author: kpunjabi
11+
ms.custom: public_preview
12+
---
13+
14+
# Implementing Answer Machine Detection with Call Automation
15+
16+
Answer Machine Detection (AMD) helps contact centers identify whether a call is answered by a human or an answering machine. This guide will show you how to implement a simple AMD solution using Dual-Tone Multi-Frequency (DTMF) tones with Azure Communication Services existing play and recognize APIs.
17+
18+
To achieve this developers can implement a logic that uses the call connected event and plays an automated message requesting the callee to press a specific key verifying that they are a human before connecting them to an agent or playing a more specific message.
19+
20+
## Step-by-step guide
21+
1. Create an outbound call. If you're not familiar with creating outbound calls you can review our [quickstart](../../quickstarts/call-automation/quickstart-make-an-outbound-call.md).
22+
2. Once the call is answered you will get a `CallConnected` event. This lets your application know that the call has been answered, at this stage it could be a human or an answer machine.
23+
3. After receiving the `CallConnected` event your application should use the [recognize API](./recognize-action.md) and play a message to the callee requesting them to press a number on their dial pad to validate they're human, for example your application might say "This is a call from [your company name] regarding [reason for call]. Please press 1 to be connected to an agent."
24+
4. If the user presses a key on the dialpad, Azure Communication Services will send a `RecognizeCompleted` event to your application. This indicates that a human has answered the call and you should continue with your regular workflow.
25+
5. If no DTMF input is received, Azure Communication Services will send a `RecognizeFailed` event to your application. This indicates that this call has gone to voicemail and you should follow your voicemail flow for this call.
26+
27+
## Example code
28+
29+
```csharp
30+
//... rest of your code
31+
32+
var ttsMessage = "This is a call from [your company name] regarding [reason for call]. Please press 1 to be connected to an agent.";
33+
var playSource = new TextSource(ttsMessage)
34+
{
35+
PlaySourceId = "playSourceId"
36+
};
37+
38+
var playOptions = new PlayOptions
39+
{
40+
Loop = false
41+
};
42+
43+
callConnection.Play(playSource, playOptions);
44+
45+
var recognizeOptions = new RecognizeOptions(new DtmfOptions(new[] { DtmfTone.One }))
46+
{
47+
InterruptPrompt = false,
48+
InitialSilenceTimeout = TimeSpan.FromSeconds(5),
49+
PlayPrompt = playSource
50+
};
51+
52+
var recognizeResult = callConnection.Recognize(recognizeOptions);
53+
54+
// Handle the recognition result
55+
if (recognizeResult.Status == RecognizeResultStatus.Recognized && recognizeResult.RecognizedTone == DtmfTone.One)
56+
{
57+
// Connect the call to an agent
58+
Console.WriteLine("Human detected. Connecting to an agent...");
59+
// Add your logic to connect the call to an agent
60+
}
61+
else
62+
{
63+
// Classify the call as an answering machine
64+
Console.WriteLine("No response detected. Classifying as an answering machine...");
65+
// Add your logic to handle answering machine
66+
}
67+
68+
//... rest of your code
69+
```
70+
71+
## Next steps
72+
- Learn more about [Call Automation](../../concepts/call-automation/call-automation.md) and its features.
73+
- Learn more about [Play action](../../concepts/call-automation/play-action.md).
74+
- Learn more about [Recognize action](../../concepts/call-automation/recognize-action.md).

0 commit comments

Comments
 (0)