One of the key challenges faced by high-volume phone systems is efficiently connecting with customers while minimizing time wasted on answering machines. That's where Answering Machine Detection (AMD) comes into play. In this post, we'll explore the concept of AMD, its benefits, and provide a step-by-step explanation of SignalWire’s Node.js code implementation.
What is Answering Machine Detection?
Answering Machine Detection is a valuable tool for automated phone systems. Its purpose is to screen outbound calls and determine whether a human or a machine has answered the call. By leveraging sophisticated algorithms and voice analysis, AMD can reliably differentiate between human voices and various machine responses such as voicemail systems or Interactive Voice Response (IVR) systems.
Why should you use Answering Machine Detection?
Implementing Answering Machine Detection in your phone system offers several benefits:
Time and Cost Efficiency: By automatically identifying answering machines, you can save valuable time and resources that would otherwise be wasted on leaving messages or navigating through lengthy voicemail prompts.
Improved Agent Productivity: Answering Machine Detection enables your agents to focus their efforts on live conversations with customers, leading to increased productivity and enhanced customer satisfaction.
Enhanced Customer Experience: By reducing the chances of connecting agents to voicemail systems, you increase their availability, resulting in lower response times when customers contact your business, and improving customer retention and loyalty.
Using Answering Machine Detection
If you have not watched our companion video, you can do so to visually see the breakdown of creating a call endpoint and AMD parameters:
Before we look at the code, we assume you have:
Node.js knowledge and a working environment. If you do not know how to code, check out our Call Flow Builder for a no-code/low-code solution instead.
Ngrok knowledge (or an equivalent) to make your server publicly accessible. If you have never used Ngrok, you can follow Ngrok’s Getting Started tutorial.
Starting Ngrok
In order for SignalWire to be able to reach our local environment so we receive the result of the AMD call, we need to start Ngrok, and to do so we just need to run:
ngrok http 3000
Take note of the URL Ngrok gives you, as we will use it shortly.
Installing dependencies
We will need to install Express and the SignalWire Compatibility API, so we can use its RestClient. To do so, we need to run
npm install express @signalwire/compatibility-api
Let's dive into the Node.js code now. You can create an amd.js file and start copying each bit over.
We begin by importing the necessary dependencies, including the Express framework and the SignalWire Compatibility API.
An instance of the Express application is created, and the express.urlencoded middleware is added to parse the incoming request data.
The RestClient is instantiated, passing the required credentials and the SignalWire Space URL. You will need to add your own credentials here, but for a more flexible setup you can get the variables from a .env file.
The client.calls.create method is called to initiate a new outbound call using the Create a Call endpoint. The URL parameter specifies the URL where the AMD determination result will be sent, so you need to replace it with your Ngrok URL. The to and from numbers define the phone numbers for the call (the “to” number must be a SignalWire number you purchased or verified), while machineDetection is set to "DetectMessageEnd" to enable AMD and wait for the end of the machine. The machineDetectionTimeout is set to 45 seconds, allowing ample time for long voicemail prompts.
- We expose a route that listens for a POST request at the root path ("/"). This is the URL where the AMD determination result is received;
Inside the route handler, a new instance of RestClient.LaML.VoiceResponse is created to construct the XML response that will be sent back to SignalWire.
The req.body.AnsweredBy property is examined to determine whether the call was answered by a human or a machine.
If the call was answered by a human, you can customize the instructions or actions to be performed. For example, you can play a greeting message and transfer the call to a live agent.
If the call was answered by a machine, you can define specific instructions such as playing a pre-recorded message or hanging up.
The constructed XML response is then converted to a string and sent back to SignalWire.
Finally, we start the Express server and listen on the PORT set in our .env file, or just use port 3000 if it is not set.
When you run this code, SignalWire will make a call using the specified to/from numbers, and depending on who answers the phone, run different instructions!
SignalWire’s Answering Machine Detection is a powerful tool that streamlines your communication processes, reduces wasted time, and enhances customer interactions. By intelligently identifying and responding to answering machines, you can optimize your outbound call campaigns and improve agent productivity.
The Node.js code provided in this article offers a starting point for implementing AMD using the SignalWire Compatibility API, but understanding AMD’s parameters is crucial to customizing its behavior based on your specific requirements.
By implementing AMD, your business can elevate its communication capabilities and deliver exceptional experiences to customers. Whether you're running a call center or managing a high-volume phone system, AMD empowers you to make the most of every conversation.
Are you ready to embrace efficiency and take your phone system to the next level with SignalWire’s Answering Machine Detection? Give it a try by signing up for a free trial with SignalWire, and unlock the benefits of streamlined communication.
If you need help or have any questions, join our Slack Community or Forum to interact with our team and other customers!