AWS Contact Center

Request service using Amazon Connect and AWS IoT

Introduction

Smartphones have become the standard method of communication for consumers, with an estimated 6.8 billion users worldwide in 2023. The World Health Organization reported an estimated 1.3 billion people living with a disability. A portion of this population may not be able to use smartphones easily in their daily lives. This results in the need for businesses to ensure digital accessibility for customers with disabilities.

The use of Amazon Connect with an accessible, connected AWS IoT Button can help businesses achieve digital accessibility. Based on the user’s clicking pattern, their request will be routed to the right place. For example, one click sends a text to a family member. Two clicks create a task for a pharmacy to refill a medication. A long press calls a pharmacist for medication questions.

This blog post shows how to integrate Amazon Connect with AWS IoT Core using AWS Lambda to route user requests to contact center agents or individual phone numbers based on user’s click patterns.

Solution overview

Figure 1: Solution architecture

Following steps explain how the preceding solution works:

  1. User clicks the AWS IoT Button.
  2. AWS IoT button forwards the click events to the AWS IoT Core service.
  3. AWS IoT Core rules invoke a Lambda and pass the click events to the Lambda.
  4. Lambda queries Amazon DynamoDB using the AWS IoT button serial number as partition key for the following attributes: user’s phone number, family member phone number, text message to be sent to family member, pharmacy phone number, and the message to be displayed in the task.
  5. Lambda processes the events:
    1. One Click – Lambda invokes Amazon Pinpoint to send a text message to a family member’s mobile phone.
    2. Two Clicks – Lambda calls the Amazon Connect StartTaskContact API to invoke an Amazon Connect flow. The flow initiates an Amazon Connect Task for a pharmacy technician to process a prescription.
    3. Long Press – Lambda calls the Amazon Connect StartOutboundVoiceContact API to call the user’s phone and runs an Amazon Connect Flow to connect the user with a pharmacist.

Prerequisites

Select an AWS Region that supports all the required services in this post. We have validated this solution in AWS us-east-1. Refer to AWS Regional Services for more details on AWS Services availability per AWS Region.

Here are the prerequisites for this solution:

Walkthrough

In the Amazon Connect console, you will create an inbound flow to route tasks and calls to agents based on the Channel value, either VOICE or TASK. In the Amazon Pinpoint console, you will register a toll-free number and set up an SMS channel. You will also use CloudFormation to build and deploy AWS resources such as Lambda, Amazon DynamoDB, and required IAM roles and policies. Finally, in the AWS IoT Core console, you will configure rules to call your Lambda endpoint. You will use the AWS IoT Core MQTT test client to test your solution.

Deployment steps

The following instructions assume a working knowledge of Amazon Connect, AWS IoT Core, Amazon Pinpoint, AWS CloudFormation, and Amazon DynamoDB. Refer to the following links for more details on these topics:

Import the Amazon Connect flow into your Amazon Connect instance and attach it to your claimed number:

  1. Download the Medication Refill And Question flow by selecting this link.
  2. Sign into your Amazon Connect instance.
  3. Navigate to the Routing tab.
  4. Select Contact flows.
  5. Choose Create contact flow.
  6. Select the dropdown menu (arrow) next to Save and select Import flow (beta).
  7. Choose Select and choose the file Medication Refill And Question downloaded from step 1.
  8. Choose Save.
  9. Choose Publish.
  10. Attach the claimed phone number to the Medication Refill And Question flow.

Make note of the Medication Refill And Question flow ID and BasicQueue ID to be used in later steps:

  1. In the flow designer for Medication Refill And Question flow, expand Show additional flow information.
  2. Under the Amazon Resource Name (ARN) section, copy everything after contact-flow/ to a text editor.Figure 2 Amazon Connect Flow ARN
  3. Navigate to the Routing tab.
  4. Select Queues.
  5. Choose BasicQueue and expand the Show additional queue information.
  6. Under the ARN section, copy everything after queue/ to a text editor.Figure 3 Amazon Connect Queue ARN

Configure Amazon Pinpoint for text messaging:

  1. Request a toll-free number.
  2. Register your toll-free number. It can take up to 15 days for registration to be processed.
  3. Set up the SMS channel. For the purpose of this blog, you can select Promotional for the Default message type and keep all other preselected entries as default.
  4. Select Save Changes.
  5. Note down the Project ID of the Amazon Pinpoint project to use in the next step.Figure 4 Amazon Pinpoint Project ID

Deploy the AWS resources, Lambda, DynamoDB, and IAM roles:

  1. Launch this CloudFormation.
  2. Provide a descriptive Stack name.
  3. Enter the following parameters.
  4. Choose Next.
  5. Keep all default entries for the stack and select Next to move through each screen.
  6. Accept the notice regarding new IAM resources being created and AWS CloudFormation requiring capability CAPABILITY_AUTO_EXPAND.
  7. Select Create.

Add user data into DynamoDB:

  1. From the DynamoDB console, select Tables.
  2. Select the table deployed in the previous step and choose Explore Items.
  3. Enter the following JSON with View DynamoDB JSON toggled off.
    {
     "serialNumber": "<< Replace with your AWS IoT Button serial number here>>",
     "familyContact": "<<Replace with family contact phone number in E.164 format>>",
     "familyContactMessage": "I need your help, please come to the house today.",
     "userName": "John Doe",
     "userPhoneNum": "<<Replace with user/subscriber contact phone number in E.164 format>>”
    }

    Figure 6 Amazon DynamoDB Create item

  4. Select Create item.

Configure AWS IoT Core Rules:

  1. In the AWS IoT Core console, from the left-hand side panel, select Message routing.
  2. Select Rules.
  3. Select Create rule.
  4. Input a descriptive name for your rule in the Rule name field.
  5. Select Next.
  6. Make sure to select 2016-03-23 in the SQL version field.
  7. Input the following Select statement into the SQL statement section.SELECT serialNumber as serialNumber, clickType as clickType FROM ‘device/+/data’Figure 9 AWS IoT Core Rules SQL statement.
  8. Select Next.
  9. Select Lambda in the Rule actions Action 1 field.
  10. Choose the Lambda that you have deployed previously via CloudFormation.
  11. Select Next.Figure 10 AWS IoT Core Rules actions
  12. Review your Rule configuration in the Review and create section.
  13. Select Create.

Test the solution

The solution as deployed is for a fictional home user that needs to contact their family member and pharmacy via button clicks. However, this solution can be applied to any other use case where a user needs to request service by clicking a button. For testing purposes, we are using the same agent to simulate the pharmacy technician and pharmacist. Optionally, you can create two agent ids, and use those to test as the pharmacy technician and pharmacist. Finally, instead of an AWS IoT button, we will use the AWS IoT Core MQTT test client to generate click messages.

Validate your test results by going to the associated Amazon CloudWatch Logs Log Group for the Lambda deployed in the previous steps.

  1. In the MQTT test client section, select Subscribe to a topic.
  2. Input device/1/data as the Topic filter.
  3. Choose Subscribe. This enables you to see all events sent to this topic in the Subscriptions section.Figure 11 AWS IoT Core MQTT test client – Subscribe to a topic
  4. In the MQTT test client section, select Publish to a topic.
  5. Input device/1/data as the Topic name.
  6. Input {“serialNumber”: ”<button_serial_number>“, ”clickType”: ”SINGLE”} as the Message payload.
  7. Choose Publish. This simulates a one click action.
  8. Replace the <button_serial_number> value with the serialNumber value input in the DynamoDB table from previous steps.Figure 12 AWS IoT Core MQTT test client SINGLE click - Publish to a topic
  9. You will also see this event in the Subscriptions section for device/1/data.Figure 13 AWS IoT Core MQTT test client SINGLE click - Subscriptions
  10. Verify that a text message is received on the family member’s mobile device with the text “I need your help, please come to the house today”.Figure 14 Family member's text message
  11. As the pharmacy technician, Log in the Amazon Connect Control Panel (CCP) and change your agent status to Available.
  12. In the MQTT test client section, input {“serialNumber”: ”<button_serial_number>“, ”clickType”: ”DOUBLE”} as the Message payload.
  13. Choose Publish. This simulates a double-click action.Figure 15 AWS IoT Core MQTT test client double-click - Publish to a topic
  14. Verify that a task is queued to the pharmacy technician.
  15. After picking up the task, notice the task displayed as “Please refill medication for John Doe for delivery tomorrow”.Figure 18 Pharmacy Technician CCP
  16. Select End task and change your agent status to Available.
  17. In the MQTT test client section, input {“serialNumber”: ”<button_serial_number>“, ”clickType”: ”LONG”} as the Message payload.
  18. Choose Publish. This simulates a long press action.Figure 17 AWS IoT Core MQTT test client LONG click - Publish to a topic
  19. Verify that you receive a call on the patient phone and that a call is ringing in the pharmacist’s CCP. As the pharmacist, select Accept call.

Figure 19 Pharmacist's CCP

Cleaning up

To avoid incurring future charges:

  1. Delete the rules created in AWS IoT Rules via the AWS IoT Core console Rules section.
  2. From the CloudFormation console, select the deployed CloudFormation stack and choose Delete to delete the deployed services and IAM roles.
  3. Delete the Amazon Connect flows imported for this blog by using Archiving and deleting flows.
  4. Release the phone number from your Amazon Pinpoint SMS account.
  5. If you had to claim a new Amazon Connect phone number, release this phone number.

Conclusion

In this post, we have implemented a solution to help businesses achieve their digital accessibility objective by enabling service and help requests via click button patterns.

If your use case requires connecting users to different agent groups based on their click patterns, add additional routing logic to the Amazon Connect flows. If you have specific IoT devices for your use case, review Connecting devices to AWS IoT to connect these devices to AWS IoT Core. Ensure that the Rules, Lambda, and DynamoDB from the blog are updated to support your device message format. If your use case requires additional security, explore Security in AWS IoT.

To learn more about Amazon Connect, go to About Amazon Connect. To learn more about AWS IoT Core, go to How AWS IoT works.

Ready to transform your customer service experience with Amazon Connect and AWS IoT? Contact us.