Skip to content

Commit 7ec9fa6

Browse files
committed
1 parent 432317b commit 7ec9fa6

35 files changed

+2291
-60
lines changed

Diff for: CHANGELOG.md

+7-2
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.3] - 2025-04-07
7+
8+
### Added
9+
- [samTemplates/amazon-connect-interactive-messages-example-lex-v2](./samTemplates/amazon-connect-interactive-messages-example-lex-v2) - boilerplate setup with **Amazon Lex V2** bot and Amazon Connect Chat integration for interactive message feature.
10+
611
## [1.4.3] - 2023-11-07
712
### Added
813
- [iOSChatExample](./iOSChatExample/README.md) - iOS example of the AWS Connect chat widget is designed for easy integration with a focus on customization.
@@ -50,8 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5055
- Custom Chat Widget - bump dependencies
5156

5257
## [1.2.3] - 2021-09-22
53-
### Changed
54-
- Updated runtime to `node14.x` in all solutions
58+
### Changed
59+
- Updated runtime to `node14.x` in all solutions
5560

5661
## [1.2.2] - 2021-09-22
5762
### Changed

Diff for: README.md

+91-56
Large diffs are not rendered by default.
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 2020 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,166 @@
1+
# Lambda for Amazon Connect Chat Interactive Messaging [Lex V2]
2+
3+
A 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+
![](./docs/AmazonConnectLexLambdaArchitecture.png)
8+
9+
## Prerequisites
10+
11+
- An [AWS Account](https://aws.amazon.com/console/) with access to Lambda, Amazon Connect, and Amazon Lex
12+
- 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)]
13+
14+
## Setup Instructions
15+
16+
> #### Security Notice
17+
> ⚠️ This is example code not intended for production use. Dependencies may contain known vulnerabilities. Please update all dependencies before using in any production environment.
18+
19+
### 1. Deploy Sample Lambda Function
20+
21+
1. Log in to the [AWS Console](https://console.aws.amazon.com/console/home).
22+
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.
23+
24+
### 2. Create Amazon Lex Bot
25+
26+
1. Download the [`InteractiveMsg_LexBotV2_Export.zip`](./InteractiveMsg_LexBotV2_Export.zip) file.
27+
2. Navigate to the Amazon Lex page in the AWS Console.
28+
3. Click "Action" > "Import" and choose the downloaded ZIP file, named "MyNewLexV2Bot"
29+
30+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
31+
32+
### 3. Associate Lex Bot with Lambda Function
33+
34+
1. In the AWS Console, open the new bot "MyNewLexV2Bot".
35+
2. Go to Aliases > TestBotAlias > Alias language support: English (US).
36+
3. Set the source to `serverless-xxxx` and click "Save".
37+
4. Ensure the InteractiveMessageIntent is linked to the Lambda:
38+
- Go to Versions > DRAFT > All languages > English (US) > Intents
39+
- Check "Use a Lambda function for initialization and validation"
40+
5. Build the bot: Versions > DRAFT > English (US) > Build
41+
42+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
43+
44+
### 4. Link Lex Bot to Amazon Connect Instance
45+
46+
1. Go to the Amazon Connect page in the AWS Console.
47+
2. Click on your instance alias to open instance settings.
48+
3. Navigate to the "Flows" tab.
49+
4. Scroll to "Amazon Lex" and select your bot from the dropdown.
50+
51+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
52+
53+
### 5. Create Contact Flow
54+
55+
1. Download the [`InteractiveMsg_ContactFlowLexV2_Export.zip`](./InteractiveMsg_ContactFlowLexV2_Export.json) file.
56+
2. Log in to your Amazon Connect instance.
57+
3. Go to `https://<YOUR-INSTANCE>.my.connect.aws/contact-flows`.
58+
4. Click "Create" > "Save" dropdown > "Import", named "InteractiveMessaging"
59+
5. Import the downloaded ZIP file.
60+
6. Edit the "Get customer input" contact flow block:
61+
- Select your Lex bot
62+
- Click "Save contact flow block"
63+
7. Click "Publish" to save your entire contact flow.
64+
65+
<!-- TODO: add screenshot (like the LexV1 blog: https://aws.amazon.com/blogs/contact-center/easily-set-up-interactive-messages-for-your-amazon-connect-chatbot/ )-->
66+
67+
### 6. Test the Setup
68+
69+
1. Visit `https://<YOUR-INSTANCE>.my.connect.aws/test-chat`.
70+
2. Open settings and set it to use your new contact flow: "InteractiveMessaging".
71+
3. Launch the chat widget and type `help` to test the interaction.
72+
73+
![Lex Bot Message on Test Chat Page](./docs/TestChatPageExample.png)
74+
75+
## Diagrams
76+
77+
Interactive Message System Diagram
78+
79+
![Interactive Message System Diagram](./docs/interactive-message-diagram.png)
80+
81+
Interactive Message Flow Chart
82+
83+
![Interactive Message Flow Chart](./docs/InteractiveMessageUIExample_FlowChart.png)
84+
85+
Interactive Message Chat Experience
86+
87+
![Interactive Message Chat Experience](./docs/InteractiveMessageChatFlow.png)
88+
89+
## Specifications
90+
91+
- Lex Bot V2
92+
- Node v18+
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+
npm install
121+
export AWS_ACCESS_KEY_ID="your-access-key-id"
122+
export AWS_SECRET_ACCESS_KEY="your-secret-access-key"
123+
export AWS_SESSION_TOKEN="your-session-token"
124+
125+
# Test if you have access to the SAM repo S3 bucket
126+
sam package --output-template-file packaged.yaml --s3-bucket amazon-connect-interactive-message-blog-assets-lex-v2 --no-execute-changeset
127+
```
128+
129+
### Steps
130+
131+
1. Make changes to source code locally
132+
133+
2. Bump the version number in `template.yaml`
134+
```yaml
135+
SemanticVersion: 1.0.1
136+
```
137+
138+
3. Update the `package.yml` by running:
139+
```bash
140+
sam package --output-template-file packaged.yaml --s3-bucket amazon-connect-interactive-message-blog-assets-lex-v2 --no-execute-changeset
141+
```
142+
143+
4. Commit the updated files:
144+
```bash
145+
git add package.yml template.yml path-to-my-updated-code
146+
```
147+
148+
5. Create a pull request
149+
150+
6. Publish the **Serverless Application Repository**:
151+
```bash
152+
sam publish --template packaged.yaml --region us-west-2
153+
```
154+
155+
## License
156+
157+
This sample code is made available under the MIT-0 license. See the [LICENSE](LICENSE) file for details.
158+
159+
## Additional Resources
160+
161+
- [Interactive Message Documentation](https://docs.aws.amazon.com/connect/latest/adminguide/interactive-messages.html)
162+
- [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/)
163+
- [Amazon Connect Documentation](https://docs.aws.amazon.com/connect/)
164+
- [Amazon Lex Documentation](https://docs.aws.amazon.com/lex/)
165+
166+
For any questions or support, please open an issue in this repository.
Loading
Loading
Loading
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"requestAttributes": {
3+
"x-amz-lex:accept-content-types": "PlainText"
4+
},
5+
"sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3",
6+
"inputTranscript": "Check self-service options",
7+
"interpretations": [
8+
{
9+
"intent": {
10+
"slots": {
11+
"action": {
12+
"shape": "Scalar",
13+
"value": {
14+
"originalValue": "Check self-service options",
15+
"resolvedValues": [
16+
"Check self-service options"
17+
],
18+
"interpretedValue": "Check self-service options"
19+
}
20+
},
21+
"appointment": null,
22+
"department": null,
23+
"interactiveOption": null
24+
},
25+
"confirmationState": "None",
26+
"name": "InteractiveMessageIntent",
27+
"state": "InProgress"
28+
},
29+
"nluConfidence": 1
30+
},
31+
{
32+
"intent": {
33+
"slots": {},
34+
"confirmationState": "None",
35+
"name": "FallbackIntent",
36+
"state": "InProgress"
37+
}
38+
}
39+
],
40+
"responseContentType": "text/plain; charset=utf-8",
41+
"sessionState": {
42+
"sessionAttributes": {},
43+
"activeContexts": [],
44+
"intent": {
45+
"slots": {
46+
"action": {
47+
"shape": "Scalar",
48+
"value": {
49+
"originalValue": "Check self-service options",
50+
"resolvedValues": [
51+
"Check self-service options"
52+
],
53+
"interpretedValue": "Check self-service options"
54+
}
55+
},
56+
"appointment": null,
57+
"department": null,
58+
"interactiveOption": null
59+
},
60+
"confirmationState": "None",
61+
"name": "InteractiveMessageIntent",
62+
"state": "InProgress"
63+
},
64+
"originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824"
65+
},
66+
"invocationSource": "DialogCodeHook",
67+
"messageVersion": "1.0",
68+
"bot": {
69+
"aliasName": "TestBotAlias",
70+
"aliasId": "TSTALIASID",
71+
"name": "interactive-messaging-lexv2",
72+
"version": "DRAFT",
73+
"localeId": "en_US",
74+
"id": "VGKIKY0S9G"
75+
},
76+
"inputMode": "Text"
77+
}

0 commit comments

Comments
 (0)