Voicemail in Amazon Connect (part 2) - Sending voicemail to queue

In part 1 of this article, I gave an example of how to use Voicemail for Amazon Connect solution to be able to send voicemail from IVR to group email or to group cell phone as SMS.

Now I would like to show how to add the ability to send voicemail messages to Queue.

The idea is that we will piggyback on the Voicemail solution built by Amazon:

  • Whenever their solution does voicemail transcription it adds this information to DynamoDB table.
  • We will create Lambda function that is triggered when a new record is added to this table.
  • This lambda function in turn will gather all the available information about voicemail (voicemail timestamp, contact phone number,  queue name, voicemail transcript, URL to voicemail message)
  • It will then generate a Task that will have all this information and will send it to the queue.
  • An agent will receive a Task contact with all the available information about voicemail including transcript and link to a voicemail message that can be played back in the browser.

Here is how it is going to look like for agent:

1) Agent receives Task with title Voicemail
2) Agent accepts the task

3) Task contains all relevant info about the voicemail message
  • Contact Phone number         - caller id
  • Datetime - time when the client left a voicemail 
  • QueueName
  • QueueID  - this is a technical field that is required for the proper work of this solution
  • Voicemail Transcript
  • URL to the actual voicemail message

4) When Agent clicks on URL  - it will open player in the separate browser window, which gives agent option to listen to the actual voicemail message. 

5) Agent can also click on contactPhoneNumber and that will automatically initiate an outbound call.

Extra bonuses:
  • Since we already sent a voicemail to the queue it means that all the contact center stats and features (real-time reports, historical reports, contact search, Contact Lens) - will be automatically available
  • You can use all the available Amazon Connect KPIs  for voicemail
  • In the contact search you will see a voicemail transcript
  • If needed you can still be able to send voicemail by Email/SMS at the same time

If that is something that might be of interest to you - please follow this guide.

Step 1.

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

We will start by implementing an official Voicemail for Amazon Connect solution.
It is fairly simple - just need to follow this implementation guide. It usually takes about 1 hour


After it is implemented you need to test it and make sure it works, make sure that you can log in to Amazon Connect Voicemail Management Portal and can actually receive voicemail.

Step 2.

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

Now we will create a "fake" agent account that will be used as a group voicemail box

  • First name = "VM"
  • Last name = must be equal to Name of Queue (for example "Tech_support")
  • Login name = must be equal to VM.<Name of the queue> (example VM.Tech_support)
  • Emal address - group email address that will be used to receive voicemails

Other parameters for this user can be anything you want because you would not need to log in to Amazon Connect with this user.


For this solution to work correctly Login name must be in the following format
VM.<Name of the queue> (example VM.Tech_support)

Step 3.

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

Now you need to login into your Amazon Connect Voicemail Management Portal.

1) Click on SYNC AGENTS button and your new user should appear in the list
2) Click on your VM user and configure it as required.
3) First thing you need to assign any extension that will be used to reference this agent in IVR.
In my case I assigned extension 7000.
4) Now you need to make sure to enable the following options:
  • Transcribe
  • Encrypt
  • Delivery Options - Email

This is required for the correct work of the solution. If you do not want to receive email notifications - you can assign to user a non-existent email address, but the delivery option must be enabled.

Step 4.

The next step is to create a new contact flow SendTask that is required to send tasks to the queue.

At first, we need to assign a working queue using Set working queue block.
  • Select Use attribute option.  
  • Type - User Defined
  • Attribute - QueueID


and after that our flow uses Transfer to queue block to actually transfer task to the queue.

You can download this flow from my GitHub:

Before we can move to the next step - you need to get Contact Flow ID that will be required in future steps.

  • Click on Show additional flow information.
  • In the ARN string Flow ID is the last 36 characters after contact-flow/

Step 5.

1. Go to AWS Management Console
2. Select DynamoDB
3. In the list of tables find 2 tables that have ContactVoicemailTable and UsersTable in the name.
These tables are automatically created when you install Voicemail solution.

In my case they have the following names: 
  • Amazon-Connect-Voicemail-VoicemailStack-1O9JZHZJ8ZD7Y-UsersTable-4DLIYWATXZ7T
  • Amazon-Connect-Voicemail-VoicemailStack-1O9JZHZJ8ZD7Y-ContactVoicemailTable-10UMQELMDZKAJ

Record their names, they will be required in future steps.

Step 6.

Now we will need to add lambda function create_Voicemail_Task that actually creates Task with voicemail info. This function is written in Python 3.9.

How it works:

  • gets info from ContactVoicemailTable. this table is used by Voicemail to keep results of voicemail transcription
  • if the transcription is completed it starts gathering data that will be added to Amazon Connect Task
      • contact phone number 
      • timestamp
      • queue name
      • queue id
      • URL to voicemail wav file
      • voicemail transcript
  • creates Amazon Connect Task

Source code available on my GitHub:

You need to modify it before adding it to your instance:

In the lambda_handler function  provide info that is right for you: 

   # Region name of Amazon S3 and Amazon Transcribe
    # Amazon Connect InstanceId
    # FlowId of SendTask flow 
    #name of DynamoDB table that is used by Voicemail to store voicemail users


After you add this lambda function I recommend increasing default timeout  (by default it is 3 seconds) to 10 seconds to give our function enough time to complete execution.
  • In AWS Management console open Lambda
  • Go to your function
  • Go to Configuration - General configuration
  • Click edit and change timeout to 10 seconds

Step 7. 

Before we can continue you have to add enough rights to the Role under which you will be running your lambda function.

Here is an example of a policy that I added to the role under which lambda function create_Voicemail_Task is running.

Before applying it you need to modify it for your case:
  • On line 8 - you need to specify ARN of your S3 bucket that is used for storing voicemails:
           "Resource": "arn:aws:s3:::amazon-connect-voicemail-vo-audiorecordingsbucket-z3v6jf3t44e7/*"
  • You can connect to S3 from the management console and find a bucket that has voicemail-vo-audiorecordingsbucket in the name.

Example 1 -- Role that is used for my lambda function

Example 2 -- Permissions for this role:

Step 8.

Now we need to add a trigger to our lambda function create_Voicemail_Task.
It will be triggered every time there is a new record added to ContactVoicemailTable table.
How to do it:
1) Go to Lambda and open our function create_Voicemail_Task
2) Click Add Trigger and create a new DynamoDB trigger

  • Trigger configuration - DynamoDB
  • DynamoDB table - find your ContactVoicemailTable
  • Batch size = 10
  • Starting position = TRIM_HORIZON
  • other configuration - by default
3) Save it
This is how it looks in my case.

Step 9. 

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

Now we will create a module that will be doing all the magic of recording voicemail message and sending it to Email/SMS.

You can download this module from my GitHub:


Import it to your Amazon Connect instance.

Step 10.

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

Now we can use our module in any IVR flow.

I created a simple VoicemailDemo flow. It emulates a situation when you want to offer client to leave a voicemail during non-working hours.

How it works.

1) At first I play the message "Our contact center is currently closed, please call us tomorrow. If you want to leave us a voicemail press 1".

2) If a client enters 1 

* First we need to add Set contact attributes block and assign voicemail user extension 7000 to user-defined attribute extensionNumber

* second - I invoke module Transfer_to_VM

And it is done. Transfer_to_VM module will do the rest.

Here is a full screenshot of VoicemailDemo flow

You can download it from my GitHub:


Step 11 (optional) .

It is the same step that we had to do in part 1 of this article. So if you already did it in part 1 - no need to do it again.

In steps 9 and 10 I gave you examples of how to offer the voicemail option in IVR before the call was transferred to queue.

What if you want to offer voicemail for the call that is already waiting in the queue?

I created another demo flow WaitInQueue_with_VM that demonstrates how to do it.


1) This is Customer queue flow so in order to use it you have to use Set customer queue flow in your main IVR before call is transferred to queue.

2) Amazon Connect does not allow to use of modules in Customer queue flows (hopefully this functionality would be added in the future). So I had to copy all the blocks from my module directly to customer queue flow.

3) Again, you have to assign an extension to extensionNumber attribute using Set contact attributes block like we did it before.

You can download this flow from my Github



This solution is a little bit more complicated than my previous articles. So if you have any questions do not hesitate to contact me either in the comments or using the contact form on my site.

No comments:

Post a Comment