An AWS Serverless Application Model (AWS SAM) template to deploy a boilerplate AWS Lambda and Amazon Lex V2 bot, enabling interactive message in Amazon Connect chat.
Interactive messages are pre-configured responses that your users can select from, making it easy for your customers to quickly resolve their issues through chat. Interactive messages can be designed using the new Amazon Connect Chat templates, which include several different customer display options (shared below), and are sent by Amazon Connect Chat using Amazon Lex chatbots.
- Amazon Lex V2
- AWS Lambda Runtime:
nodejs18.x
- An AWS Account with access to Lambda, Amazon Connect, and Amazon Lex
- An Amazon Connect instance set up in your account [Guide: Create an Amazon Connect instance]
⚠️ This is example code not intended for production use. Dependencies may contain known vulnerabilities. Please update all dependencies before using in any production environment.
- Log in to the AWS Console.
- Deploy the sample Lambda function by visiting this link and following the deployment instructions.
- Download the
InteractiveMsg_LexBotV2_Export.zip
file. - Navigate to the Amazon Lex page in the AWS Console.
- Click "Action" > "Import" and choose the downloaded ZIP file, named "MyNewLexV2Bot"
- In the AWS Console, open the new bot "MyNewLexV2Bot".
- Go to Aliases > TestBotAlias > Alias language support: English (US).
- Set the source to
serverless-xxxx
and click "Save". - Ensure the InteractiveMessageIntent is linked to the Lambda:
- Go to Versions > DRAFT > All languages > English (US) > Intents
- Check "Use a Lambda function for initialization and validation"
- Build the bot: Versions > DRAFT > English (US) > Build
- Go to the Amazon Connect page in the AWS Console.
- Click on your instance alias to open instance settings.
- Navigate to the "Flows" tab.
- Scroll to "Amazon Lex" and select your bot from the dropdown.
- Download the
InteractiveMsg_ContactFlowLexV2_Export.zip
file. - Log in to your Amazon Connect instance.
- Go to
https://<YOUR-INSTANCE>.my.connect.aws/contact-flows
. - Click "Create" > "Save" dropdown > "Import", named "InteractiveMessaging"
- Import the downloaded ZIP file.
- Edit the "Get customer input" contact flow block:
- Select your Lex bot
- Click "Save contact flow block"
- Click "Publish" to save your entire contact flow.
- Visit
https://<YOUR-INSTANCE>.my.connect.aws/test-chat
. - Open settings and set it to use your new contact flow: "InteractiveMessaging".
- Launch the chat widget and type
help
to test the interaction.
Interactive Message System Diagram
Interactive Message Flow Chart
Interactive Message Chat Experience
- us-east-1 (N. Virginia)
- us-west-2 (Oregon)
- ap-southeast-2 (Sydney)
- ap-northeast-1 (Tokyo)
- eu-central-1 (Frankfurt)
- eu-west-2 (London)
- ap-southeast-1 (Singapore)
- ca-central-1 (Canada)
- ap-northeast-2 (South Korea)
- af-south-1 (Cape Town)
- Install SAM CLI (
brew install aws-sam-cli
) - Access to account:
533267401313
(ask @spenlep-amzn)
git clone https://github.com/amazon-connect/amazon-connect-chat-ui-examples.git
cd amazon-connect-chat-ui-examples
cd samTemplates/amazon-connect-interactive-messages-example-lex-v2
export AWS_ACCESS_KEY_ID="your-access-key-id"
export AWS_SECRET_ACCESS_KEY="your-secret-access-key"
export AWS_SESSION_TOKEN="your-session-token"
-
Make changes to source code locally
-
Bump the version number in
template.yaml
,package.yml
, andpackage.json
- SemanticVersion: 2.0.1 + SemanticVersion: 2.0.2
-
Validate the samTemplate
sam validate --region us-west-2 --lint
sam build
-
Update the
package.yml
by running:sam package --output-template-file packaged.yaml --s3-bucket amazon-connect-interactive-message-blog-assets-lex-v2 --region us-west-2
-
Commit the updated files:
git add package.yml template.yml path-to-my-updated-code
-
Create a pull request
-
Publish the Serverless Application Repository:
sam publish --template packaged.yaml --region us-west-2
This sample code is made available under the MIT-0 license. See the LICENSE file for details.
- Interactive Messages Documentation
- AWS Lambda Documentation
- Amazon Connect Documentation
- Amazon Lex Documentation
For any questions or support, please open an issue in this repository.