Business Productivity

Build custom chat bots for Amazon Chime

In 2017, Amazon Chime released incoming web-hooks, allowing users to send automated messages into Chime chat rooms. Today, we take chat integrations a step further, announcing the availability of bi-directional chat bot support. With chat bots, users can send and receive information from custom-built bots in Chime chat rooms.

When many people think of chat bots, they think of automated chat interfaces on websites that aim to help them understand products and services, or to provide support. Those of us working in the tech industry might be more likely to think of DevOps use cases. However, the usefulness of chat bots extends well beyond these common use cases, with many scenarios being specific to how a particular organization or team works.

If you, like many Chime administrators, are a builder, you are eager to utilize AWS to empower your users with more convenience, more efficiency, and more data. You aim to remove barriers that inhibit users’ ability to get work done and allow them to focus on their work. With chat bots in Amazon Chime, you are enabled to build the right bot integration for your needs. Adding a bot to Amazon Chime only requires either an HTTPS endpoint or a direct integration with Lambda, and the ability to echo back a challenge. Once you have created a bot in a Chime account, it can be added by room administrators to any chat room created by members of your account. Depending on what you build, these bots can provide users with a single interface through which they can preform any number of tasks, receive notifications, or search data. Everything is easily accessible, and interactions happen rapidly.

In this post, I share the basic steps to get a bot up and running, and add it to a Chime chat room. This bot was created with use cases we hear about from customers where quick access to information is needed by employees that are not sitting in front of their computers. This is frequently the case in industries like retail or manufacturing, where computers are not provided. Similar use cases are also seen across industries in Sales or Account Management roles where employees may have computers, but need to be ready to take calls even when they aren’t sitting at their desk. Our rough proof of concept utilizes Amazon Connect, Amazon Lex, AWS Lambda, and Amazon Chime to route a call from a customer with a question to an associate on a retail sales floor. This associate has been assigned a phone number through Chime’s Business Calling feature, and uses a bot integration in a Chime chat room to query inventory and answer the caller’s questions.

This is a simplified proof of concept, utilizing just a few AWS services. Production versions of bots may use more AWS Services, or connect with internal knowledge stores, or third party systems.


To complete this tutorial, you will need write access to the AWS Console and the services used, including Amazon Chime, Amazon Connect, AWS Lex, and AWS Lambda. You will also need to make sure you have Setup AWS CLI credentials, and have an enterprise Amazon Chime account with at least one user. You can optionally assign this user a phone number in Chime with Business calling, but any phone number will work.

In addition to the AWS CLI, your system will need Node.js, npm, and Git installed.

Creating the chat bot and adding it to your Chime account

Step one: downloading the sample project

Download the sample project used for this tutorial from the aws-samples Github repository. Open you terminal and enter this command.

$git clone && \
cd amazon-chime-private-bot-demo/examples/private-bot

Step two: Create Bot empty Lambda and API Gateway

Use npm to create a new Lambda function and API gateway.

$npm run config -- \
--account-id=<accountId> \
--bucket-name=<bucketName> \
--function-name=<functionName> \
--cloudformation-stack-name=<stack_name> && \
npm run setup

When this completes you will have an empty Lambda function and a new API gateway.

Step Three: Get Bot’s Gateway Invoke URL

Open up the list of APIs in the AWS Console.
Choose the PrivateBotsDemo API > Stages > Demo
Copy and save the Invoke URL at the top of the page

Step Four: Create the bot

To create your bot, you will need to replace the Lambda function with the contents of the bot_command_handler.js file. To keep things simple for this tutorial, the Lambda contains not just the necessary functions to respond to users, but also a table with a few products in it.

Commands available to users include:

  • check-inventory – Searches inventory, using product and brand.
    • Example: @<bot_name> check-inventory product:Funtainer brand:Thermos
  • find-in-store: Searches stores for a specific product using SKU.
    • Example: @<bot_name> find-in-store sku:therfun034dl

Step Five: Integrate the bot with your Chime account

Use the AWS CLI to create a bot under your Chime enterprise account.

$aws chime create-bot —account-id "<account_id>" —display-name "<bot_name>" —domain "<domain_name>"

The returned response includes a bot-id, which you will need to use in the next step, configuring the bot event configuration.

"Bot": {
        "CreatedTimestamp": "<timeStamp>",
        "DisplayName": "ExampleBot",
        "Disabled": exampleBotFlag,
        "UserId": "<userId>",
        "BotId": "<botId>",
        "UpdatedTimestamp": "<timeStamp>",
        "BotType": "ChatBot",
        "SecurityToken": "<securityToken>",
        "BotEmail": "<botEmail>"

Step Six: Put the bot event configuration to API Gateway

Use the AWS CLI to complete the event configuration for the bot created in the previous step. Use your own account ID, bot ID, and HTTPS endpoint.

$aws chime put-events-configuration --account-id "<account_id>" --bot-id "<bot_id>" --outbound-events-https-endpoint "<http_endpoint>"

Response includes BotID and http endpoint that bot uses to forward event to.

    "EventsConfiguration": {
        "BotId": "ExampleBotId", 
        "OutboundEventsHTTPSEndpoint": ""

Step Seven: Adding the bot to a chat room

Open the desired chat room in the Chime on Windows, Mac, or the web.
Choose the gear icon → manage web-hooks and bots → Add bot
Enter the bot’s email address created when you integrated it with Chime
Once added, you will see the bot added to the roster, and a welcome message is displayed in the room.

Trying the bot

At this point, you have the bot set up and can use it. Use check-inventory or find-in-store to query the sample product list.

In Chime, try entering:

@outdoor-store-bot (Bot) find-in-store sku:therfun034dl


@outdoor-store-bot (Bot) check-inventory product:Funtainer brand:Thermos

Business Calling, Amazon Connect and Amazon Lex

It is possible to use the bot without doing anything else. As an extra step, you can enable a call flow from a phone number to an associate. This requires making sure the user has been assigned a Business Calling number, configuring an Amazon Connect call flow, and creating a Lambda with Lex integration.

Full details on creating this flow can be found on Github.


Amazon Chime now lets you use custom chat bots in your chat rooms. Utilize the power of Amazon Lex, AWS Lambda, and other AWS services to build custom conversational interfaces that streamline collaborative workflows, enabling your users to complete common tasks involving multiple tools without switching context. Adding a bot you have created to your Enterprise Chime Account is as simple as providing a bot name and an HTTPS endpoint or by integrating directly through AWS Lambda. Once added to your Chime account, room administrators can add your bot using the bot’s assigned email address, and room members interact with the bot through @ mentions.

Ryan McHarg

Ryan McHarg

Ryan is a Senior Product Manager for the Amazon Chime SDK, a set of real-time communications components that developers can use to quickly add messaging, audio, video, and screen sharing capabilities to their web or mobile applications. Ryan has worked for Amazon Web Services since 2016.