Skip to content

Commit d991050

Browse files
Merge pull request #295994 from valindrae/valindrae-answer-machine-detection
Valindrae answer machine detection
2 parents 997872a + 7449955 commit d991050

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-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 article describes how to implement an AMD solution using Dual-Tone Multi-Frequency (DTMF) tones with Azure Communication Services existing play and recognize APIs.
17+
18+
To achieve this goal, developers can implement logic that uses the call connected event and plays an automated message. This message requests the callee to press a specific key to verify they're 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. For more information about creating outbound calls, see [Make an outbound call using Call Automation](../../quickstarts/call-automation/quickstart-make-an-outbound-call.md).
22+
2. Once the call is answered, you get a `CallConnected` event. This event lets your application know that the call is 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]. Press 1 to be connected to an agent."
24+
4. If the user presses a key on the dialpad, Azure Communication Services sends a `RecognizeCompleted` event to your application. This indicates that a human answered the call and you should continue with your regular workflow.
25+
5. If no DTMF input is received, Azure Communication Services sends a `RecognizeFailed` event to your application. This indicates that this call went 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).

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,8 @@ items:
998998
href: how-tos/call-automation/play-action.md
999999
- name: Gather user input with recognize action
10001000
href: how-tos/call-automation/recognize-action.md
1001+
- name: Implement Answer Machine Detection
1002+
href: concepts/call-automation/answer-machine-detection.md
10011003
- name: Call recording
10021004
items:
10031005
- name: Call recording overview

0 commit comments

Comments
 (0)