Monitor the health of phone numbers in Amazon Connect
When managing your contact center, knowing if your claimed phone number is customer reachable in Amazon Connect instead of a busy signal or a “not in service” message is crucial to your business. Your phone number(s) might become unreachable due to various unforeseen circumstances like carrier issue, release of phone number, and others.
This blog post shows how to leverage AWS services to check the reachability of your phone number and send a status message via SMS to your mobile phone on a schedule basis.
The following architecture diagrams shows how the use of an AWS Lambda function to execute an outbound contact flow dialing into an Amazon Connect phone number that play a series of DTMF tones back to confirm if your phone number is working. Once confirmed, a text message is sent to your mobile number of the result.
- A scheduled AWS EventBridge rule execute the AWS Lambda function to make the outbound call using Amazon Connect.
- Amazon Connect makes an outbound call to the inbound phone number that you want to check if it is working with a specific caller id.
- The Amazon Connect inbound phone number executes a contact flow to look for specific caller id and playback specific DTMF tones sequence.
- The Outbound Contact Flow receive the DTMF digits and update a contact attributes on the call.
- The AWS Lambda function wait 10 seconds for the contact attributes to be set and retrieve the value using GetContactAttributes.
- Check if the collected digits are valid or not to determine what status message to send via AWS SNS.
- The designated mobile phone number would get the status message.
By using the Amazon Connect StartOutboundVoiceContact API with an Amazon Connect Contact Flow to make an outbound call to get a status update on the reachability of your Amazon Connect’s phone numbers.
For this walkthrough, you should have the following prerequisites:
- An AWS account
- An existing Amazon Connect instance with inbound and outbound telephony capability
- Access to the following AWS services:
- AWS Simple Notification Services
- AWS Lambda with access to create functions
- Access to software that can generate a wav file with DTMF tone. Audacity is used as an example in this blog post
Create a DTMF wav file using Audacity
- Install and launch Audactiy
- In the menu, choose Generate -> DTMF Tones…
- Put in the sequence of digits with a hashtag to use for verification like this “31642#”
- Amplitude: 0.8
- Duration: 5 seconds
- Take the default for the rest, and it should look like this:
- Click OK to generate the wav
- From the menu, choose File -> Export -> Export Audio…
- Name your file and for “Save as type”, choose “WAV (Microsoft) signed 16 bit PCM”
Upload the wav file to Amazon Connect as a prompt
- Login to your Amazon Connect instance and follow the instructions “To create a prompt”
- Upload the wav file that you generated when creating the prompt
Claim a new phone number for outbound dialing purposes
- Login to your Amazon Connect instance and follow the instructions “Claim a phone number in your country”
Add logic in your current Contact Flow that is associated to the phone number that you want to check for reachability
- Find and edit your Contact Flow that handles the inbound phone number that you would like to check for reachability
- Add “Check contact attributes”, “Play prompt”, “Disconnect” block at the beginning of your flow and connect them like below
- In “Check contact attributes” put in the phone number you just claim from step 3 for outbound purposes so the Contact Flow play the DTMF prompt when it has a match. For example, you claimed +13334445555, and it would look like the following:
- In “Play prompts”, choose the prompt you create and uploaded that contains the DTMF tones you generated using Audacity like the following:
Create a new Contact Flow for outbound dialing to retrieve the DTMF digits
- Login to your Amazon Connect instance and create a Contact Flow by importing this flow
- After publishing the contact flow, get the contact flow ID by click on “Show additional flow information” and copy the contact flow id to be used later as shown below:
Deploy the AWS Cloudformation stack:
Launch the AWS CloudFormation stack here:
- Enter the name you want to give under Stack Name, this has to be unique.
- Enter the name of your Amazon Connect Instance ID, follow this link to learn how
- Enter the Contact Flow ID you copied down from step 5
- Enter the phone that you want to check with the modified Contact Flow from step 4 above as the Destination Number
- Take the default AWS EventBridge rule name PhoneHealthCheck-Rule or change it.
- Enter the mobile phone number to get the status message in PageNumber
- Enter the cron expression to schedule the health check time, the default value schedule is to execute this check everyday at 3:00 PM UTC
- Enter the claimed number for outbound use from step 3
- Enter the sequence of numbers entered from step 1 without the hashtag symbol as the SuccessCode
Testing the solution
- To manually test your phone number using AWS Lambda, open AWS Lambda function call PhoneHealthCheck which got created when running your AWS Cloudformation Stack:
- In AWS Lambda function, choose Select a test event configure test events as follow
- Edit the different values as follow:
CF_ID: Replace this with the contact flow id you saved earlier
DEST_NUMBER: The phone number you want to check for reachability
INSTANCE_ID: The Amazon Connect instance ID that makes the outbound call
PAGE_NUMBER: The mobile phone number where the AWS Lambda function sends the text message to.
SOURCE_NUMBER: The newly claimed phone number for outbound calling purposes that you input into the “Check contact attributes” earlier
SUCCESS_CODE: the 5 digits code you created as a prompt earlier
- And invoke your AWS Lambda function to perform the test.
To avoid incurring charges, you can either disable the AWS EventBridge Rule or delete the AWS Cloudformation stack that was created. In Amazon Connect, remove the two Contact Flow blocks you added into your main flow and release the phone number you claimed for outbound dialing purposes.
You have now created a solution to get a status of your Amazon Connect’s phone number reachability so you can react and take action on a schedule. You can create more AWS EventBridge rules using the PhoneHealthCheck AWS Lambda function to test if you have more than one phone number.