Skip to content

Commit a249fcd

Browse files
authored
1 parent b6af2f3 commit a249fcd

35 files changed

+2231
-6
lines changed

.github/workflows/samTemplate-ci.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Validate SAM Template
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
paths:
8+
- 'samTemplates/amazon-connect-interactive-messages-example-lex-v2/**'
9+
10+
jobs:
11+
validate:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: '3.x'
19+
- name: Install SAM CLI
20+
run: |
21+
pip install aws-sam-cli
22+
- name: Validate SAM template
23+
run: |
24+
cd samTemplates/amazon-connect-interactive-messages-example-lex-v2
25+
sam validate --region us-west-2 --lint
26+
- name: Build SAM template
27+
run: |
28+
cd samTemplates/amazon-connect-interactive-messages-example-lex-v2
29+
sam build

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.DS_Store
33
.vscode
44
.idea
5+
.aws-sam
6+
node_modules

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [1.4.4] - 2025-04-08
7+
8+
### Added
9+
- [samTemplates/amazon-connect-interactive-messages-example-lex-v2](./samTemplates/amazon-connect-interactive-messages-example-lex-v2) - new **AWS Serverless Application Model (AWS SAM) template** to deploy an **Amazon Lex V2** bot for interactive messages in Chat.
10+
611
## [1.4.3] - 2023-11-07
712
### Added
813
- [iOSChatExample](mobileChatExamples/iOSChatExample/README.md) - iOS example of the AWS Connect chat widget is designed for easy integration with a focus on customization.

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,22 @@ At the moment, these are the solutions in this repo:
6868
3. **[samTemplates/amazon-connect-interactive-messages-example](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example)**
6969
Interactive messages in Amazon Connect Chat allow contact centers to provide personalized prompts and response options that customers can easily select from. This serverless application is a sample lambda function which implements Amazon Connect interactive message templates (lists, lists with images, and a time picker) as described in the AWS Contact Center blog post [How to enable interactive messages in Amazon Connect chat](https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/).
7070

71-
4. **[customChatWidget](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/customChatWidget)**
71+
4. **[samTemplates/amazon-connect-interactive-messages-example-lex-v2](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2)**
72+
Interactive messages in Amazon Connect Chat allow contact centers to provide personalized prompts and response options that customers can easily select from. This serverless application is a sample lambda function which implements Amazon Connect interactive message templates (lists, lists with images, and a time picker).
73+
74+
5. **[customChatWidget](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/customChatWidget)**
7275
Custom Chat Widget for Amazon Connect, with a Chat Form that can be easily plugged into a webpage. This solution helps customers to have Amazon Connect Custom Chat Widget in their website, by applying simple configuration parameters. It also makes customizing the `amazon-connect-interface.js` file easier, and can be used as an easy way to host custom widget on a webpage.
7376

74-
5. **[connectReactNativeChat](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples/connectReactNativeChat)**
77+
6. **[connectReactNativeChat](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples/connectReactNativeChat)**
7578
React Native demo Chat application for Amazon Connect. This cross-platform solution implements basic Chat JS functionality and is fully customizable. Follow the provided documentation to build with [`amazon-connect-chatjs@^1.5.0`](https://github.com/amazon-connect/amazon-connect-chatjs).
76-
77-
6. **[startChatContactAPILocalProxy](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/startChatContactAPILocalProxy)**
79+
80+
7. **[startChatContactAPILocalProxy](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/startChatContactAPILocalProxy)**
7881
Solution to run local proxy server for the Amazon Connect [StartChatContact](https://docs.aws.amazon.com/connect/latest/APIReference/API_StartChatContact.html) Public API. Can be used during local development when building a custom chat interface, prior to deploying a production CloudFormation chat backend.
7982

80-
6. **[hostedWidgetCustomization](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/hostedWidgetCustomization)**
83+
8. **[hostedWidgetCustomization](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/hostedWidgetCustomization)**
8184
Additional ways to configure the Amazon Connect Hosted Widget on your website and further personalize the branding. This sample code covers several common use cases for customizing the widget snippet code. [Learn more](https://docs.aws.amazon.com/connect/latest/adminguide/add-chat-to-website.html)
8285

83-
7. **[mobileChatExamples](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples)**
86+
9. **[mobileChatExamples](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples)**
8487
These native mobile examples of the AWS Connect chat widget are designed for easy integration with a focus on customization. Out-of-the-box ready yet fully adaptable, they offer developers the perfect starting point for incorporating a chat feature that can be fine-tuned to any customer’s requirements.
8588

8689

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"2019-10-30","StartAction":"8b2f025e-cd00-4ffe-821a-76a3f9dda572","Metadata":{"entryPointPosition":{"x":14.4,"y":20},"ActionMetadata":{"b0dd1051-e4f0-4bae-9f09-2c1ba82ca30d":{"position":{"x":1493.6,"y":13.6}},"36eb2181-5b9d-4e15-97cb-25b338280e30":{"position":{"x":1765.6,"y":242.4}},"cb0a54b8-6407-44b2-b507-f8401de864c0":{"position":{"x":1208,"y":12},"parameters":{"QueueId":{"displayName":"BasicQueue"}},"queue":{"text":"BasicQueue"}},"057134d9-a78e-4910-80f6-406a24ed68ca":{"position":{"x":680,"y":345.6}},"8b2f025e-cd00-4ffe-821a-76a3f9dda572":{"position":{"x":162.4,"y":13.6}},"3b2f3727-4eb7-4422-95c2-50798429f382":{"position":{"x":685.6,"y":12},"conditions":[],"conditionMetadata":[{"id":"841b4357-b5b8-4132-aee4-e1bcfae4073a","operator":{"name":"Equals","value":"Equals","shortDisplay":"="},"value":"Continue to agent"},{"id":"7230f710-6910-48eb-bfc6-5ad9db8825dc","operator":{"name":"Equals","value":"Equals","shortDisplay":"="},"value":"End chat"}]},"b701c222-ed08-4fb2-84ff-b91f0fae04b9":{"position":{"x":420.8,"y":12.8},"useLexBotDropdown":true,"conditionMetadata":[]}},"Annotations":[],"name":"InteractiveMessaging","description":"","type":"contactFlow","status":"published","hash":{}},"Actions":[{"Parameters":{},"Identifier":"b0dd1051-e4f0-4bae-9f09-2c1ba82ca30d","Type":"TransferContactToQueue","Transitions":{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30","Errors":[{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30","ErrorType":"QueueAtCapacity"},{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30","ErrorType":"NoMatchingError"}]}},{"Parameters":{},"Identifier":"36eb2181-5b9d-4e15-97cb-25b338280e30","Type":"DisconnectParticipant","Transitions":{}},{"Parameters":{"QueueId":"arn:aws:connect:us-west-2:990999614922:instance/7f18d5d6-8e42-4613-9014-84503d17e7da/queue/48e235a6-546b-43a8-aa4c-9a8d04e45ad1"},"Identifier":"cb0a54b8-6407-44b2-b507-f8401de864c0","Type":"UpdateContactTargetQueue","Transitions":{"NextAction":"b0dd1051-e4f0-4bae-9f09-2c1ba82ca30d","Errors":[{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30","ErrorType":"NoMatchingError"}]}},{"Parameters":{"Text":"Sorry I did not understand that. Please try again later."},"Identifier":"057134d9-a78e-4910-80f6-406a24ed68ca","Type":"MessageParticipant","Transitions":{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30"}},{"Parameters":{"FlowLoggingBehavior":"Enabled"},"Identifier":"8b2f025e-cd00-4ffe-821a-76a3f9dda572","Type":"UpdateFlowLoggingBehavior","Transitions":{"NextAction":"b701c222-ed08-4fb2-84ff-b91f0fae04b9"}},{"Parameters":{"ComparisonValue":"$.Lex.Slots.action"},"Identifier":"3b2f3727-4eb7-4422-95c2-50798429f382","Type":"Compare","Transitions":{"NextAction":"cb0a54b8-6407-44b2-b507-f8401de864c0","Conditions":[{"NextAction":"cb0a54b8-6407-44b2-b507-f8401de864c0","Condition":{"Operator":"Equals","Operands":["Continue to agent"]}},{"NextAction":"36eb2181-5b9d-4e15-97cb-25b338280e30","Condition":{"Operator":"Equals","Operands":["End chat"]}}],"Errors":[{"NextAction":"cb0a54b8-6407-44b2-b507-f8401de864c0","ErrorType":"NoMatchingCondition"}]}},{"Parameters":{"Text":"Edit this message in the \"Get customer input\" block in Flows\n\nType help to get help!","LexBot":{"Name":"InteractiveMessageBot","Region":"us-west-2","Alias":"latest"}},"Identifier":"b701c222-ed08-4fb2-84ff-b91f0fae04b9","Type":"ConnectParticipantWithLexBot","Transitions":{"NextAction":"057134d9-a78e-4910-80f6-406a24ed68ca","Errors":[{"NextAction":"3b2f3727-4eb7-4422-95c2-50798429f382","ErrorType":"NoMatchingCondition"},{"NextAction":"057134d9-a78e-4910-80f6-406a24ed68ca","ErrorType":"NoMatchingError"}]}}]}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
11+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
12+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
13+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# Lambda forAmazon Connect Chat Interactive Messaging [Lex V2]
2+
3+
An AWS [Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) (AWS SAM) template to deploy a boilerplate **AWS Lambda** and **Amazon Lex** V2 bot, enabling interactive message in Amazon Connect chat.
4+
5+
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.
6+
7+
![Interactive Messages Thumbnail](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/AmazonConnectLexLambdaArchitecture.png)
8+
9+
## Specifications
10+
11+
- Amazon Lex V2
12+
- AWS Lambda Runtime: `nodejs18.x`
13+
14+
## Prerequisites
15+
16+
- An [AWS Account](https://aws.amazon.com/console/) with access to Lambda, Amazon Connect, and Amazon Lex
17+
- An **Amazon Connect** instance set up in your account [[Guide: Create an Amazon Connect instance](https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-instances.html)]
18+
19+
## Setup Instructions
20+
21+
> #### Security Notice
22+
> ⚠️ This is example code not intended for production use. Dependencies may contain known vulnerabilities. Please update all dependencies before using in any production environment.
23+
24+
### 1. Deploy Sample Lambda Function
25+
26+
1. Log in to the [AWS Console](https://console.aws.amazon.com/console/home).
27+
2. Deploy the sample Lambda function by visiting [this link](https://serverlessrepo.aws.amazon.com/applications/us-west-2/533267401313/amazon-connect-interactive-messages-example-lex-v2) and following the deployment instructions.
28+
29+
### 2. Create Amazon Lex Bot
30+
31+
1. Download the [`InteractiveMsg_LexBotV2_Export.zip`](./InteractiveMsg_LexBotV2_Export.zip) file.
32+
2. Navigate to the Amazon Lex page in the AWS Console.
33+
3. Click "Action" > "Import" and choose the downloaded ZIP file, named "MyNewLexV2Bot"
34+
35+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
36+
37+
### 3. Associate Lex Bot with Lambda Function
38+
39+
1. In the AWS Console, open the new bot "MyNewLexV2Bot".
40+
2. Go to Aliases > TestBotAlias > Alias language support: English (US).
41+
3. Set the source to `serverless-xxxx` and click "Save".
42+
4. Ensure the InteractiveMessageIntent is linked to the Lambda:
43+
- Go to Versions > DRAFT > All languages > English (US) > Intents
44+
- Check "Use a Lambda function for initialization and validation"
45+
5. Build the bot: Versions > DRAFT > English (US) > Build
46+
47+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
48+
49+
### 4. Link Lex Bot to Amazon Connect Instance
50+
51+
1. Go to the Amazon Connect page in the AWS Console.
52+
2. Click on your instance alias to open instance settings.
53+
3. Navigate to the "Flows" tab.
54+
4. Scroll to "Amazon Lex" and select your bot from the dropdown.
55+
56+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
57+
58+
### 5. Create Contact Flow
59+
60+
1. Download the [`InteractiveMsg_ContactFlowLexV2_Export.zip`](./InteractiveMsg_ContactFlowLexV2_Export.json) file.
61+
2. Log in to your Amazon Connect instance.
62+
3. Go to `https://<YOUR-INSTANCE>.my.connect.aws/contact-flows`.
63+
4. Click "Create" > "Save" dropdown > "Import", named "InteractiveMessaging"
64+
5. Import the downloaded ZIP file.
65+
6. Edit the "Get customer input" contact flow block:
66+
- Select your Lex bot
67+
- Click "Save contact flow block"
68+
7. Click "Publish" to save your entire contact flow.
69+
70+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
71+
72+
### 6. Test the Setup
73+
74+
1. Visit `https://<YOUR-INSTANCE>.my.connect.aws/test-chat`.
75+
2. Open settings and set it to use your new contact flow: "InteractiveMessaging".
76+
3. Launch the chat widget and type `help` to test the interaction.
77+
78+
![Lex Bot Message on Test Chat Page](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/TestChatPageExample.png)
79+
80+
## Diagrams
81+
82+
Interactive Message System Diagram
83+
84+
![Interactive Message System Diagram](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/interactive-message-diagram.png)
85+
86+
Interactive Message Flow Chart
87+
88+
![Interactive Message Flow Chart](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageUIExample_FlowChart.png)
89+
90+
Interactive Message Chat Experience
91+
92+
![Interactive Message Chat Experience](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageChatFlow.png)
93+
94+
## Supported Regions
95+
96+
- us-east-1 (N. Virginia)
97+
- us-west-2 (Oregon)
98+
- ap-southeast-2 (Sydney)
99+
- ap-northeast-1 (Tokyo)
100+
- eu-central-1 (Frankfurt)
101+
- eu-west-2 (London)
102+
- ap-southeast-1 (Singapore)
103+
- ca-central-1 (Canada)
104+
- ap-northeast-2 (South Korea)
105+
- af-south-1 (Cape Town)
106+
107+
## [Maintainers Only] Publish New Serverless Application Repository Version
108+
109+
### Prerequisites
110+
111+
- Install SAM CLI (`brew install aws-sam-cli`)
112+
- Access to account: `533267401313` (ask @spenlep-amzn)
113+
114+
### Installation
115+
116+
```sh
117+
git clone https://github.com/amazon-connect/amazon-connect-chat-ui-examples.git
118+
cd amazon-connect-chat-ui-examples
119+
cd samTemplates/amazon-connect-interactive-messages-example-lex-v2
120+
export AWS_ACCESS_KEY_ID="your-access-key-id"
121+
export AWS_SECRET_ACCESS_KEY="your-secret-access-key"
122+
export AWS_SESSION_TOKEN="your-session-token"
123+
```
124+
125+
### Steps
126+
127+
1. Make changes to source code locally
128+
129+
2. Bump the version number in `template.yaml`, `package.yml`, and `package.json`
130+
```diff
131+
- SemanticVersion: 2.0.1
132+
+ SemanticVersion: 2.0.2
133+
```
134+
135+
3. Validate the samTemplate
136+
137+
```bash
138+
sam validate --region us-west-2 --lint
139+
sam build
140+
```
141+
142+
4. Update the `package.yml` by running:
143+
```bash
144+
sam package --output-template-file packaged.yaml --s3-bucket amazon-connect-interactive-message-blog-assets-lex-v2 --region us-west-2
145+
```
146+
147+
5. Commit the updated files:
148+
```bash
149+
git add package.yml template.yml path-to-my-updated-code
150+
```
151+
152+
6. Create a pull request
153+
154+
7. Publish the **Serverless Application Repository**:
155+
```bash
156+
sam publish --template packaged.yaml --region us-west-2
157+
```
158+
159+
## License
160+
161+
This sample code is made available under the MIT-0 license. See the [LICENSE](LICENSE) file for details.
162+
163+
## Additional Resources
164+
165+
- [Interactive Messages Documentation](https://docs.aws.amazon.com/connect/latest/adminguide/interactive-messages.html)
166+
- [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/)
167+
- [Amazon Connect Documentation](https://docs.aws.amazon.com/connect/)
168+
- [Amazon Lex Documentation](https://docs.aws.amazon.com/lex/)
169+
170+
For any questions or support, please open an issue in this repository.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"requestAttributes": {
3+
"x-amz-lex:accept-content-types": "PlainText"
4+
},
5+
"sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3",
6+
"inputTranscript": "help",
7+
"interpretations": [
8+
{
9+
"intent": {
10+
"slots": {
11+
"action": null,
12+
"appointment": null,
13+
"department": null,
14+
"interactiveOption": null
15+
},
16+
"confirmationState": "None",
17+
"name": "InteractiveMessageIntent",
18+
"state": "InProgress"
19+
},
20+
"nluConfidence": 1
21+
},
22+
{
23+
"intent": {
24+
"slots": {},
25+
"confirmationState": "None",
26+
"name": "FallbackIntent",
27+
"state": "InProgress"
28+
}
29+
}
30+
],
31+
"responseContentType": "text/plain; charset=utf-8",
32+
"sessionState": {
33+
"sessionAttributes": {},
34+
"activeContexts": [],
35+
"intent": {
36+
"slots": {
37+
"action": null,
38+
"appointment": null,
39+
"department": null,
40+
"interactiveOption": null
41+
},
42+
"confirmationState": "None",
43+
"name": "InteractiveMessageIntent",
44+
"state": "InProgress"
45+
},
46+
"originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824"
47+
},
48+
"invocationSource": "DialogCodeHook",
49+
"messageVersion": "1.0",
50+
"bot": {
51+
"aliasName": "TestBotAlias",
52+
"aliasId": "TSTALIASID",
53+
"name": "interactive-messaging-lexv2",
54+
"version": "DRAFT",
55+
"localeId": "en_US",
56+
"id": "VGKIKY0S9G"
57+
},
58+
"inputMode": "Text"
59+
}

0 commit comments

Comments
 (0)