Placing Outbound Calls using Amazon Connect (Part 2)

SARVESH VIRKUD
4 min readMar 28, 2022

--

In the previous blog, I walked you guys through setting up a connect instance and creating a contact flow for inbound calling.

In this blog, we are going to talk about outbound calls from your connect instance to your users/customers.

We are going to make use of the StartOutboundVoiceContact API to make the outbound campaign calls.

Here is a code snippet in python that we can make use of to initiate these outbound calls:

Now, as you can see in the above code, I have an attribute prompt in the attributes sections of the API call. These attributes can be used by our contact flow to deliver custom messages to the user.

So, suppose I need to notify the user about an upcoming reservation in my restaurant at 9 PM in the evening via call, I can make use of the StartOutboundVoiceContact API.

So, In the attributes section above I can pass this message along with any other key-value pairs that I need to make use of in the contact flow. In my case, I use the prompt key with the value “This is an automated call from ABC, this is to remind you of an upcoming dining reservation in our restaurant today at 9 PM for 2 people. Hope you have a delightful experience”.

Any keys that I pass as attributes to the API will be accessible in the contact flow under User Defined attributes. As an enhancement, I can make use of events to notify the user with a call supposedly 5 hours before the booking time.

Note: For placing an outbound call, you will need an Amazon connect phone number. I will make use of the same phone number I claimed in the previous blog.

Contact Flow Changes

So, for this to work, we will have to make one small change in the contact flow that we created previously or we can create a new one quickly. Here are the steps for the same:

1. Navigate into the connect dashboard and in the contact flows section, look for the contact flow we created as a part of the last blog. Once you open the contact flow, double click on the Play Prompt node.

2. In the Play Prompt properties window, select the option “Enter dynamically”. From the type drop-down menu, select “User Defined” and in the attribute property type in “prompt”. “prompt” is the key that we have defined in the code snippet above. Click on Save.

3. Save and Publish the contact flow. Now to actually initiate the outbound call, the StartOutboundVoiceContact API needs 4 things as required parameters.
a) SourcePhoneNumber - The Claimed Connect Phone number
b) DestinationPhoneNumber - The Customer’s Phone number
c) InstanceId - The Connect Instance Id
d) ContactFlowId - The Contact Flow Id

4. To get the InstanceId and the ContactFlowId, you can click on the “Show additional flow information” drop down placed above the connect nodes drawer/below the contact flow name. You can find it in the above image.

The Flow ARN will be something like this arn:aws:connect:region:account_id:instance/instance_id/contact-flow/contact_flow_id. You can take the instance_id and the contact_flow_id from the ARN which maps to InstanceId and the ContactFlowId respectively.

5. Replace all the 4 values in the code snippet given above. Make sure that both the phone numbers use E.164 format i.e. +11234567890. It should not have any spaces and should have the country code prefix (+1).

Testing the code

Now, to test this, I created a lambda function with the required IAM permissions to invoke the StartOutboundVoiceContact API. I copied the code snippet given above and added the source phone number, destination phone number, instance id and the contact flow id in the lambda code.

To test the code out, I created a test event in lambda and clicked on Test. Whatever number you entered as your DestinationPhoneNumber, should receive a phone call with the prompt message that you specified in the Attributes section of the API call for the “prompt” key.

StartOutboundVoiceContact API limits -
RateLimit -
2 requests per second
BurstLimit -
5 requests per second
This is a soft-limit and can be increased by raising a service quotas increase request from the AWS Support Console.

To read more about the StartOutboundVoiceContact API, you can visit the AWS API documentation here. Click here for the boto3 documentation.

Thank you for reading all the way! Have a nice day! :)

--

--

Responses (1)