diff --git a/.github/workflows/samTemplate-ci.yml b/.github/workflows/samTemplate-ci.yml new file mode 100644 index 0000000..e919e5a --- /dev/null +++ b/.github/workflows/samTemplate-ci.yml @@ -0,0 +1,29 @@ +name: Validate SAM Template + +on: + pull_request: + branches: + - master + paths: + - 'samTemplates/amazon-connect-interactive-messages-example-lex-v2/**' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install SAM CLI + run: | + pip install aws-sam-cli + - name: Validate SAM template + run: | + cd samTemplates/amazon-connect-interactive-messages-example-lex-v2 + sam validate --region us-west-2 --lint + - name: Build SAM template + run: | + cd samTemplates/amazon-connect-interactive-messages-example-lex-v2 + sam build diff --git a/.gitignore b/.gitignore index 555ae7e..42543ee 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store .vscode .idea +.aws-sam +node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4d8f1..9ad28be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.4.4] - 2025-04-08 + +### Added + - [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. + ## [1.4.3] - 2023-11-07 ### Added - [iOSChatExample](mobileChatExamples/iOSChatExample/README.md) - iOS example of the AWS Connect chat widget is designed for easy integration with a focus on customization. diff --git a/README.md b/README.md index 313f238..acbda8e 100644 --- a/README.md +++ b/README.md @@ -68,19 +68,22 @@ At the moment, these are the solutions in this repo: 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)** 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/). -4. **[customChatWidget](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/customChatWidget)** +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)** + 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). + +5. **[customChatWidget](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/customChatWidget)** 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. -5. **[connectReactNativeChat](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples/connectReactNativeChat)** +6. **[connectReactNativeChat](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples/connectReactNativeChat)** 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). - -6. **[startChatContactAPILocalProxy](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/startChatContactAPILocalProxy)** + +7. **[startChatContactAPILocalProxy](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/startChatContactAPILocalProxy)** 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. -6. **[hostedWidgetCustomization](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/hostedWidgetCustomization)** +8. **[hostedWidgetCustomization](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/hostedWidgetCustomization)** 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) -7. **[mobileChatExamples](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples)** +9. **[mobileChatExamples](https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/mobileChatExamples)** 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. diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_ContactFlowLexV2_Export.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_ContactFlowLexV2_Export.json new file mode 100644 index 0000000..ac3a481 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_ContactFlowLexV2_Export.json @@ -0,0 +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"}]}}]} \ No newline at end of file diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_LexBotV2_Export.zip b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_LexBotV2_Export.zip new file mode 100644 index 0000000..4761a0c Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/InteractiveMsg_LexBotV2_Export.zip differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/LICENSE.txt b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/LICENSE.txt new file mode 100644 index 0000000..e2fe190 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/LICENSE.txt @@ -0,0 +1,14 @@ +Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/README.md b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/README.md new file mode 100644 index 0000000..59049f7 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/README.md @@ -0,0 +1,170 @@ +# Lambda forAmazon Connect Chat Interactive Messaging [Lex V2] + +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. + +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. + +![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) + +## Specifications + +- Amazon Lex V2 +- AWS Lambda Runtime: `nodejs18.x` + +## Prerequisites + +- An [AWS Account](https://aws.amazon.com/console/) with access to Lambda, Amazon Connect, and Amazon Lex +- 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)] + +## Setup Instructions + +> #### Security Notice +> ⚠️ This is example code not intended for production use. Dependencies may contain known vulnerabilities. Please update all dependencies before using in any production environment. + +### 1. Deploy Sample Lambda Function + +1. Log in to the [AWS Console](https://console.aws.amazon.com/console/home). +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. + +### 2. Create Amazon Lex Bot + +1. Download the [`InteractiveMsg_LexBotV2_Export.zip`](./InteractiveMsg_LexBotV2_Export.zip) file. +2. Navigate to the Amazon Lex page in the AWS Console. +3. Click "Action" > "Import" and choose the downloaded ZIP file, named "MyNewLexV2Bot" + + + +### 3. Associate Lex Bot with Lambda Function + +1. In the AWS Console, open the new bot "MyNewLexV2Bot". +2. Go to Aliases > TestBotAlias > Alias language support: English (US). +3. Set the source to `serverless-xxxx` and click "Save". +4. 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" +5. Build the bot: Versions > DRAFT > English (US) > Build + + + +### 4. Link Lex Bot to Amazon Connect Instance + +1. Go to the Amazon Connect page in the AWS Console. +2. Click on your instance alias to open instance settings. +3. Navigate to the "Flows" tab. +4. Scroll to "Amazon Lex" and select your bot from the dropdown. + + + +### 5. Create Contact Flow + +1. Download the [`InteractiveMsg_ContactFlowLexV2_Export.zip`](./InteractiveMsg_ContactFlowLexV2_Export.json) file. +2. Log in to your Amazon Connect instance. +3. Go to `https://.my.connect.aws/contact-flows`. +4. Click "Create" > "Save" dropdown > "Import", named "InteractiveMessaging" +5. Import the downloaded ZIP file. +6. Edit the "Get customer input" contact flow block: + - Select your Lex bot + - Click "Save contact flow block" +7. Click "Publish" to save your entire contact flow. + + + +### 6. Test the Setup + +1. Visit `https://.my.connect.aws/test-chat`. +2. Open settings and set it to use your new contact flow: "InteractiveMessaging". +3. Launch the chat widget and type `help` to test the interaction. + +![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) + +## Diagrams + +Interactive Message System Diagram + +![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) + +Interactive Message Flow Chart + +![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) + +Interactive Message Chat Experience + +![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) + +## Supported Regions + +- 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) + +## [Maintainers Only] Publish New Serverless Application Repository Version + +### Prerequisites + +- Install SAM CLI (`brew install aws-sam-cli`) +- Access to account: `533267401313` (ask @spenlep-amzn) + +### Installation + +```sh +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" +``` + +### Steps + +1. Make changes to source code locally + +2. Bump the version number in `template.yaml`, `package.yml`, and `package.json` + ```diff + - SemanticVersion: 2.0.1 + + SemanticVersion: 2.0.2 + ``` + +3. Validate the samTemplate + + ```bash + sam validate --region us-west-2 --lint + sam build + ``` + +4. Update the `package.yml` by running: + ```bash + sam package --output-template-file packaged.yaml --s3-bucket amazon-connect-interactive-message-blog-assets-lex-v2 --region us-west-2 + ``` + +5. Commit the updated files: + ```bash + git add package.yml template.yml path-to-my-updated-code + ``` + +6. Create a pull request + +7. Publish the **Serverless Application Repository**: + ```bash + sam publish --template packaged.yaml --region us-west-2 + ``` + +## License + +This sample code is made available under the MIT-0 license. See the [LICENSE](LICENSE) file for details. + +## Additional Resources + +- [Interactive Messages Documentation](https://docs.aws.amazon.com/connect/latest/adminguide/interactive-messages.html) +- [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/) +- [Amazon Connect Documentation](https://docs.aws.amazon.com/connect/) +- [Amazon Lex Documentation](https://docs.aws.amazon.com/lex/) + +For any questions or support, please open an issue in this repository. diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/AmazonConnectLexLambdaArchitecture.png b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/AmazonConnectLexLambdaArchitecture.png new file mode 100644 index 0000000..5b090e8 Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/AmazonConnectLexLambdaArchitecture.png differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageChatFlow.png b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageChatFlow.png new file mode 100644 index 0000000..0cfe098 Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageChatFlow.png differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageUIExample_FlowChart.png b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageUIExample_FlowChart.png new file mode 100644 index 0000000..3658461 Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/InteractiveMessageUIExample_FlowChart.png differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/TestChatPageExample.png b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/TestChatPageExample.png new file mode 100644 index 0000000..511eae9 Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/TestChatPageExample.png differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/interactive-message-diagram.png b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/interactive-message-diagram.png new file mode 100644 index 0000000..071a68a Binary files /dev/null and b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/docs/interactive-message-diagram.png differ diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1-help.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1-help.json new file mode 100644 index 0000000..d9ba17e --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1-help.json @@ -0,0 +1,59 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "help", + "interpretations": [ + { + "intent": { + "slots": { + "action": null, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": null, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1-CheckSelfServiceOptions.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1-CheckSelfServiceOptions.json new file mode 100644 index 0000000..c6d5026 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1-CheckSelfServiceOptions.json @@ -0,0 +1,73 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "Check self-service options", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1-ChooseADepartment.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1-ChooseADepartment.json new file mode 100644 index 0000000..9756b1c --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1-ChooseADepartment.json @@ -0,0 +1,87 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "Choose a department", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_1-Billing.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_1-Billing.json new file mode 100644 index 0000000..2f10a53 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_1-Billing.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "Billing", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "Billing", + "resolvedValues": ["Billing"], + "interpretedValue": "Billing" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "Billing", + "resolvedValues": ["Billing"], + "interpretedValue": "Billing" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_2-NewService.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_2-NewService.json new file mode 100644 index 0000000..c90bf94 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_2-NewService.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "New Service", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "New Service", + "resolvedValues": ["New Service"], + "interpretedValue": "New Service" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "New Service", + "resolvedValues": ["New Service"], + "interpretedValue": "New Service" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_3-Cancellation.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_3-Cancellation.json new file mode 100644 index 0000000..2da6a2d --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_1_3-Cancellation.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "Cancellation", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "Cancellation", + "resolvedValues": ["Cancellation"], + "interpretedValue": "Cancellation" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": { + "shape": "Scalar", + "value": { + "originalValue": "Cancellation", + "resolvedValues": ["Cancellation"], + "interpretedValue": "Cancellation" + } + }, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Choose a department", + "resolvedValues": ["Choose a department"], + "interpretedValue": "Choose a department" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2-ScheduleAMeeting.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2-ScheduleAMeeting.json new file mode 100644 index 0000000..f48e1d9 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2-ScheduleAMeeting.json @@ -0,0 +1,87 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "Schedule a meeting with an agent", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824", + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": null, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + } + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_1-2020-10-15-T1300.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_1-2020-10-15-T1300.json new file mode 100644 index 0000000..50f190f --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_1-2020-10-15-T1300.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "2020-10-15T13:00+00:00", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-15T13:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-15T13:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-15T13:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-15T13:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_2-2020-10-15-T1600.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_2-2020-10-15-T1600.json new file mode 100644 index 0000000..3bd3ed7 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_2-2020-10-15-T1600.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "2020-10-15T16:00+00:00", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-15T16:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-15T16:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-15T16:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-15T16:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_3-2020-10-31-T1800.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_3-2020-10-31-T1800.json new file mode 100644 index 0000000..a28148f --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_1_2_3-2020-10-31-T1800.json @@ -0,0 +1,101 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "5d11c7ca-6eb1-48d1-b5f2-58510e9ae6c3", + "inputTranscript": "2020-10-31T18:00+00:00", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-31T18:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-31T18:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Check self-service options", + "resolvedValues": ["Check self-service options"], + "interpretedValue": "Check self-service options" + } + }, + "appointment": { + "shape": "Scalar", + "value": { + "originalValue": "2020-10-31T18:00+00:00", + "resolvedValues": [], + "interpretedValue": "2020-10-31T18:00+00:00" + } + }, + "department": null, + "interactiveOption": { + "shape": "Scalar", + "value": { + "originalValue": "Schedule a meeting with an agent", + "resolvedValues": ["Schedule a meeting with an agent"], + "interpretedValue": "Schedule a meeting with an agent" + } + } + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "abc2cbc8-4e60-4649-83c7-c317d4d21824" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_2-TalkToAnAgent.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_2-TalkToAnAgent.json new file mode 100644 index 0000000..676089b --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_2-TalkToAnAgent.json @@ -0,0 +1,73 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "cf9a0e0d-91aa-4de3-b905-944083198864", + "inputTranscript": "Talk to an agent", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Talk to an agent", + "resolvedValues": ["Talk to an agent"], + "interpretedValue": "Talk to an agent" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "Talk to an agent", + "resolvedValues": ["Talk to an agent"], + "interpretedValue": "Talk to an agent" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "a58c4a95-5474-4060-9c35-c9b3f74202a4" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "inputMode": "Text", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_3-EndChat.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_3-EndChat.json new file mode 100644 index 0000000..d252012 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/events/1_3-EndChat.json @@ -0,0 +1,73 @@ +{ + "requestAttributes": { + "x-amz-lex:accept-content-types": "PlainText" + }, + "sessionId": "7675eb4f-acfb-4f00-b73e-a313f00d13f7", + "inputTranscript": "End chat", + "interpretations": [ + { + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "End chat", + "resolvedValues": ["End chat"], + "interpretedValue": "End chat" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "nluConfidence": 1 + }, + { + "intent": { + "slots": {}, + "confirmationState": "None", + "name": "FallbackIntent", + "state": "InProgress" + } + } + ], + "responseContentType": "text/plain; charset=utf-8", + "sessionState": { + "sessionAttributes": {}, + "activeContexts": [], + "intent": { + "slots": { + "action": { + "shape": "Scalar", + "value": { + "originalValue": "End chat", + "resolvedValues": ["End chat"], + "interpretedValue": "End chat" + } + }, + "appointment": null, + "department": null, + "interactiveOption": null + }, + "confirmationState": "None", + "name": "InteractiveMessageIntent", + "state": "InProgress" + }, + "originatingRequestId": "ce8438dd-244d-4646-946f-d23d04ce1c81" + }, + "invocationSource": "DialogCodeHook", + "messageVersion": "1.0", + "bot": { + "aliasName": "TestBotAlias", + "aliasId": "TSTALIASID", + "name": "interactive-messaging-lexv2", + "version": "DRAFT", + "localeId": "en_US", + "id": "VGKIKY0S9G" + }, + "inputMode": "Text" +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/README.md b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/README.md new file mode 100644 index 0000000..f489284 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/README.md @@ -0,0 +1,337 @@ +# Package structure of the Lambda function code hook for Amazon Connect Chat Interactive Messaging + +* A handler method named handleRequest is defined in `app.js`. The handler method takes an event and context object as input and returns a response. +* All the application constants are kept in `constants/interactive_options.js` for easy reference. +* Inputs provided by the user are handleded in `util/user_input_handler.js` +* Responses with Interactive Message Templates are generated in `util/response_handler.js` + +Amazon Connect chat currently supports the following Interactive Message Template types: +* Panel - A panel prompts the user to select an item. Items can include only text. +* List Picker - A list picker prompts the user to select an item. Items can include title, subtitle, and image. List Picker supports images at high level title as well as items while Panel does not. +* Time Picker - A time picker prompts the user to choose an available time slot, such as to schedule a meeting or appointment. +* QuickReply - A quick reply prompts the user with easy-to-click reply options. Items can include only text. +* Carousel - A horizontal scroll list of nested Panel or List Pickers templates + +You can find additional information 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/). + +A structured response template for Interactive Messaging consists of the following elements: + +``` +templateType: the type of the template. valid values: Panel, ListPicker, TimePicker +version: the version of the template +data object: + title: title of the response card + subtitle: subtitle of the response card + imageType: the type of the image. Valid Value: URL + imageData: url of the image. + elements: + title: title of the item + subtitle: subtitle of the item + imageType: the type of the image. Valid Value: URL + imageData: url of the image. + timeslots: + date: available date-time for a meeting or appointment. Valid Value can be any date, but it need to be specifically in the format shown in the exmaple below. + duration: duration of the meeting or appointment +``` + +Here is an example of a `List Picker` template: + +```json +{ + "templateType":"ListPicker", + "version":"1.0", + "data":{ + "content":{ + "title":"Which department do you want to select?", + "subtitle":"Tap to select option", + "imageType":"URL", + "imageData":"https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/company.jpg", + "elements":[ + { + "title":"Billing", + "subtitle":"Request billing information", + "imageType":"URL", + "imageData":"https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/billing.jpg" + }, + { + "title":"New Service", + "subtitle":"Set up a new service", + "imageType":"URL", + "imageData":"https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/new_service.jpg" + }, + { + "title":"Cancellation", + "subtitle":"Request a cancellation", + "imageType":"URL", + "imageData":"https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/cancel.jpg" + } + ] + } + } +} +``` +Here is an example of a `Time Picker` template: + +```json +{ + "templateType":"TimePicker", + "version":"1.0", + "data":{ + "content":{ + "title":"Schedule appointment", + "subtitle":"Tap to select option", + "timeslots":[ + { + "date":"2020-10-31T18:00+00:00", + "duration":60 + }, + { + "date":"2020-10-15T13:00+00:00", + "duration":60 + }, + { + "date":"2020-10-15T16:00+00:00", + "duration":60 + } + ] + } + } +} +``` + +Here is an example of a `Panel` template: + +```json +{ + "templateType": "Panel", + "version": "1.0", + "data": { + "content": { + "title": "How can I help you?", + "subtitle": "Tap to select option", + "imageType": "URL", + "imageData": + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/company.jpg", + "elements": [ + { + "title": "Check self-service options", + }, + { + "title": "Talk to an Agent", + }, + { + "title": "End chat", + }, + ], + }, + }, +} +``` + +Here is an example of a `Time Picker` template: + +```json +{ + "templateType": "Panel", + "version": "1.0", + "data": { + "content": { + "title": "How can I help you?", + "subtitle": "Tap to select option", + "imageType": "URL", + "imageData": + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/company.jpg", + "elements": [ + { + "title": "Check self-service options", + }, + { + "title": "Talk to an Agent", + }, + { + "title": "End chat", + }, + ], + }, + }, +} +``` + +Here is an example of a `QuickReply` template: + +```json +{ + "templateType": "QuickReply", + "version": "1.0", + "data": { + "content": { + "title": "How was your experience?", + "elements": [ + { + "title": "Lorem ipsum" + }, + { + "title": "Lorem ipsum" + }, + { + "title": "Lorem ipsum dolor sit amet" + }, + { + "title": "Ipsum" + } + ] + } + } +} +``` + +Here is an example of a `Carousel` template: + +```json +{ + "templateType": "Carousel", + "version": "1.0", + "data": { + "content": { + "title": "Select a destination:", + "elements": [ + { + "templateType": "ListPicker", + "templateIdentifier": "8c0a55c8-1c37-41c2-b22a-62b2aaa7f1ac", + "version": "1.0", + "data": { + "content": { + "title": "Explore our travel options:", + "subtitle": "Select an option:", + "imageType": "URL", + "imageData": + "https://www.usnews.com/object/image/00000173-fe24-d76b-a773-fe3679d20000/200817-planesky-stock.jpg?update-time=1597696716591&size=responsive640", + "elements": [ + { + "title": "Purchase Ticket", + }, + { + "title": "View All Destinations", + }, + { + "title": "Learn More", + "type": "hyperlink", + "url": "https://github.com/amazon-connect/amazon-connect-chat-interface", + }, + ], + }, + }, + }, + { + "templateType": "ListPicker", + "templateIdentifier": "2c0a55c8-3c37-41c2-b22a-62b2aaa7f1ac", + "version": "1.0", + "data": { + "content": { + "title": "Explore Hotel destinations", + "subtitle": "Select an option:", + "imageType": "URL", + "imageData": + "https://dynamic-media-cdn.tripadvisor.com/media/photo-o/22/a1/9c/80/essentia-luxury-hotel.jpg?w=700&h=-1&s=1", + "elements": [ + { + "title": "Book Room", + }, + { + "title": "View All Listings", + }, + { + "title": "Learn More", + "type": "hyperlink", + "url": "https://github.com/amazon-connect/amazon-connect-chat-interface", + }, + ], + }, + }, + }, + { + "templateType": "ListPicker", + "templateIdentifier": "3c0a55c8-3c37-41c2-b22a-62b2aaa7f1ac", + "version": "1.0", + "data": { + "content": { + "title": "Explore dining options", + "subtitle": "Select an option:", + "imageType": "URL", + "imageData": + "https://t3.ftcdn.net/jpg/02/27/62/24/360_F_227622470_sJ3yEaz44RK7UrWNaGdSn7azgeRu9UDs.jpg", + "elements": [ + { + "title": "Book Table", + }, + { + "title": "View Popular Entrees", + }, + { + "title": "Learn More", + "type": "hyperlink", + "url": "https://github.com/amazon-connect/amazon-connect-chat-interface", + }, + ], + }, + }, + }, + { + "templateType": "ListPicker", + "templateIdentifier": "4c0a55c8-3c37-41c2-b22a-62b2aaa7f1ac", + "version": "1.0", + "data": { + "content": { + "title": "Explore our travel options:", + "subtitle": "Select an option:", + "imageType": "URL", + "imageData": + "https://media.istockphoto.com/photos/young-woman-pulling-suitcase-in-airport-terminal-copy-space-picture-id1173736603?b=1&k=20&m=1173736603&s=612x612&w=0&h=1V_XBSWHppXzMQIzkyG6drqgrEl_prEogWXjbN7Gxwo=", + "elements": [ + { + "title": "Purchase Ticket", + }, + { + "title": "View All Destinations", + }, + { + "title": "Learn More", + "type": "hyperlink", + "url": "https://github.com/amazon-connect/amazon-connect-chat-interface", + }, + ], + }, + }, + }, + { + "templateType": "ListPicker", + "templateIdentifier": "6c0a55c8-3c37-41c2-b22a-62b2aaa7f1ac", + "version": "1.0", + "data": { + "content": { + "title": "Hotel Gabonzo Suite", + "subtitle": "Select an option:", + "imageType": "URL", + "imageData": + "https://media.istockphoto.com/id/929135598/photo/santorini-greece-picturesq-view-of-traditional-cycladic-santorini-houses-on-small-street-with.jpg?s=612x612&w=0&k=20&c=Z8R8IPtjYfk8gc5Q-1Q4jD1coUgqu5vuTezM2ONRUPA=", + "elements": [ + { + "title": "Book Tour", + }, + { + "title": "View Ratings", + }, + { + "title": "Open Gallery", + "type": "hyperlink", + "url": "https://github.com/amazon-connect/amazon-connect-chat-interface", + }, + ], + }, + }, + }, + ], + }, + }, +} +``` \ No newline at end of file diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/app.js b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/app.js new file mode 100644 index 0000000..c0ac863 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/app.js @@ -0,0 +1,52 @@ +const { + FULFILLMENT_STATES, + TEST_INTERACTIVE_OPTIONS, +} = require("./constants/interactive_options"); +const { formTerminalResponse } = require("./util/response_handler"); +const { + handleElicitAction, + handleActionResponse, + handleInteractiveOptionResponse, + handleOtherResponse, +} = require("./util/user_input_handler"); + +/* MAIN HANDLER */ +exports.lambdaHandler = async (event, context) => { + try { + console.log(`Request received: ${JSON.stringify(event)}`); + let response = handleRequest(event); + console.log(`Returning response: ${JSON.stringify(response)}`); + return response; + } catch (err) { + console.error(`Error processing Lex request:`, err); + return formTerminalResponse( + FULFILLMENT_STATES.FAILED, + "Error in Lex Lambda" + ); + } +}; + +/* PROCESS INBOUND MESSAGE */ +function handleRequest(request) { + let input = request.inputTranscript; + let recent_intent = request.sessionState.intent; + request.currentIntent = request.interpretations[0].intent; + let current_intent = request.currentIntent.name; + let initialPrompt = request.inputTranscript; + + /* HANDLE INTENT 'InteractiveMessageIntent' */ + if (current_intent === 'InteractiveMessageIntent' && (recent_intent === null || initialPrompt === 'help')) { + /* console.log(recent_intent.slots.action); */ + return handleElicitAction(request); + } else if (current_intent === 'InteractiveMessageIntent' && !(Object.values(TEST_INTERACTIVE_OPTIONS).includes(input)) && recent_intent.slots.interactiveOption === null) { + return handleActionResponse(input, request); + } else if (current_intent === 'InteractiveMessageIntent' && Object.values(TEST_INTERACTIVE_OPTIONS).includes(input) && recent_intent.slots.interactiveOption !== null) { + return handleInteractiveOptionResponse(input, request); + } + /* (optional) HANDLE OTHER INTENTS */ + + /* HANDLE FULFILLED INTENT */ + else { + return handleOtherResponse(input, request); + } +} \ No newline at end of file diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/constants/interactive_options.js b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/constants/interactive_options.js new file mode 100644 index 0000000..1c9a310 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/constants/interactive_options.js @@ -0,0 +1,243 @@ +/*AMAZON CONNECT TEMPLATE TYPES FOR INTERACTIVE MESSAGING*/ +// Documentation: https://docs.aws.amazon.com/connect/latest/adminguide/interactive-messages.html#panel +const TEMPLATE_TYPES = { + LISTPICKER: "ListPicker", + TIMEPICKER: "TimePicker", + QUICK_REPLY: "QuickReply", + CAROUSEL: "Carousel", + // PANEL: "Panel" same as ListPicker but up to 10 elements +}; + +/*IMAGES USED FOR INTERACTIVE MESSAGES*/ +//Image urls need to be changed after we get a new S3 bucket in prod to host images and other resources +const IMAGE_URLS = { + BILLING: + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/billing.jpg", + NEW_SERVICE: + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/new_service.jpg", + CANCELLATION: + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/cancel.jpg", + COMPANY: + "https://amazon-connect-interactive-message-blog-assets.s3-us-west-2.amazonaws.com/interactive-images/company.jpg", +}; + +/*FULFILLMENT STATES FOR AMAZON LEX BOT INTENTS*/ +const FULFILLMENT_STATES = { + FULFILLED: "Fulfilled", + FAILED: "FAILED", +}; + +/*SLOTS SUPPORTED IN AMAZON LEX CHAT BOT*/ +const SLOTS = { + ACTION: "action", + INTERACTIVE_OPTION: "interactiveOption", + DEPARTMENT: "department", + QUICK_REPLY: "quickReply", + FLIGHT_OPTIONS_CAROUSEL: "flightOptions", + APPOINTMENT: "appointment" +}; + + +/*VALUES SUPPORTED IN THE DEPARTMENT SLOT*/ +const DEPARTMENT_SLOT = { + BILLING: "Billing", + CANCELLATION: "Cancellation", + NEW_SERVICE: "New Service", +}; + +/*ACTIONS THAT A USER CAN TAKE */ +const ACTIONS = { + TEST_INTERACTIVE: "Check self-service options", + CONTINUE_TO_AGENT: "Talk to an agent", + END_CHAT: "End chat", +}; + +/*SELF-SERVICE OPTIONS WHEN USER SELECTS "CHECK SELF-SERVICE OPTIONS" AS AN ACTION*/ +const TEST_INTERACTIVE_OPTIONS = { + DEPARTMENT_WITH_MULTIPLE_IMAGES: "Choose a department", + SIMPLE_QUICK_REPLY_PICKER: "Rate my experience", + FLIGHT_OPTIONS_CAROUSEL_PICKER: "View flight options", + SIMPLE_TIMEPICKER: "Schedule a meeting with an agent" +}; + + +/*MAPPING SELF-SERVICE OPTIONS TO AMAZON LEX BOT SLOTS*/ +const TEST_INTERACTIVE_OPTIONS_SLOTS = { + DEPARTMENT_WITH_MULTIPLE_IMAGES: SLOTS.DEPARTMENT, + SIMPLE_QUICK_REPLY_PICKER: SLOTS.QUICK_REPLY, + FLIGHT_OPTIONS_CAROUSEL_PICKER: SLOTS.FLIGHT_OPTIONS_CAROUSEL, + SIMPLE_TIMEPICKER: SLOTS.APPOINTMENT, + INVALID: SLOTS.DEPARTMENT, + DEPARTMENT_LISTPICKER: SLOTS.DEPARTMENT +}; + +/*MAPPING SELF-SERVICE OPTIONS TO INTERACTIVE MESSAGE TEMPLATES*/ +const TEST_INTERACTIVE_OPTIONS_TEMPLATES = { + INVALID: {}, + DEPARTMENT_LISTPICKER: { + templateType: TEMPLATE_TYPES.LISTPICKER, + version: "1.0", + data: { + content: { + title: "Which department would you like?", + subtitle: "Tap to select option", + elements: [ + { + title: DEPARTMENT_SLOT.BILLING, + subtitle: "For billing issues", + }, + { + title: DEPARTMENT_SLOT.NEW_SERVICE, + subtitle: "For new service", + }, + { + title: DEPARTMENT_SLOT.CANCELLATION, + subtitle: "For new service requests", + }, + ], + }, + }, + }, + SIMPLE_TIMEPICKER: { + templateType: TEMPLATE_TYPES.TIMEPICKER, + version: "1.0", + data: { + content: { + title: "Schedule appointment", + subtitle: "Tap to select option", + timeslots: [ + { + date: "2020-10-31T18:00+00:00", + duration: 60, + }, + { + date: "2020-10-15T13:00+00:00", + duration: 60, + }, + { + date: "2020-10-15T16:00+00:00", + duration: 60, + }, + ], + }, + }, + }, + DEPARTMENT_WITH_MULTIPLE_IMAGES: { + templateType: TEMPLATE_TYPES.LISTPICKER, + version: "1.0", + data: { + content: { + title: "Which department do you want to select?", + subtitle: "Tap to select option", + imageType: "URL", + imageData: IMAGE_URLS.COMPANY, + elements: [ + { + title: DEPARTMENT_SLOT.BILLING, + subtitle: "Request billing information", + imageType: "URL", + imageData: IMAGE_URLS.BILLING, + }, + { + title: DEPARTMENT_SLOT.NEW_SERVICE, + subtitle: "Set up a new service", + imageType: "URL", + imageData: IMAGE_URLS.NEW_SERVICE, + }, + { + title: DEPARTMENT_SLOT.CANCELLATION, + subtitle: "Request a cancellation", + imageType: "URL", + imageData: IMAGE_URLS.CANCELLATION, + }, + ], + }, + }, + }, + SIMPLE_QUICK_REPLY_PICKER: { + templateType: TEMPLATE_TYPES.QUICK_REPLY, + version: "1.0", + data: { + content: { + title: "How was your experience?", + subtitle: "Tap to select option", + buttons: [ + { + text: "Good", + }, + { + text: "Bad", + }, + { + text: "Neutral", + }, + ], + }, + }, + }, + FLIGHT_OPTIONS_CAROUSEL_PICKER: { + "templateType": "Carousel", + "version": "1.0", + "data": { + "content": { + "title": "View our popular destinations", + "elements": [ + { + "templateIdentifier": "template0", + "templateType": "Panel", + "version": "1.0", + "data": { + "content": { + "title": "California", + "subtitle": "Tap to select option", + "elements": [ + { + "title": "Book flights" + }, + { + "title": "Book hotels" + }, + { + "title": "Talk to agent" + } + ] + } + } + }, + { + "templateIdentifier": "template1", + "templateType": "Panel", + "version": "1.0", + "data": { + "content": { + "title": "New York", + "subtitle": "Tap to select option", + "elements": [ + { + "title": "Book flights" + }, + { + "title": "Book hotels" + }, + { + "title": "Talk to agent" + } + ] + } + } + } + ] + } + } + } +}; + +module.exports = { + FULFILLMENT_STATES, + SLOTS, + TEMPLATE_TYPES, + ACTIONS, + TEST_INTERACTIVE_OPTIONS, + TEST_INTERACTIVE_OPTIONS_SLOTS, + TEST_INTERACTIVE_OPTIONS_TEMPLATES, +}; diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/package.json b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/package.json new file mode 100644 index 0000000..79e763b --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/package.json @@ -0,0 +1,16 @@ +{ + "name": "lex_codehook", + "version": "2.0.1", + "description": "Amazon Lex Code Hook sample for Amazon Connect Interactive Messages", + "main": "app.js", + "homepage": "https://serverlessrepo.aws.amazon.com/applications/us-west-2/533267401313/amazon-connect-interactive-messages-example-lex-v2", + "repository": "https://github.com/amazon-connect/amazon-connect-chat-ui-examples/amazon-connect-interactive-messages-example-lex-v2", + "author": "SAM CLI", + "license": "MIT", + "dependencies": { + }, + "scripts": { + }, + "devDependencies": { + } +} diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/response_handler.js b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/response_handler.js new file mode 100644 index 0000000..132c771 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/response_handler.js @@ -0,0 +1,80 @@ +/* response_handler.js HANDLES CREATION OF RESPONSES TO THE LEX BOT */ + +/* CREATE A RESPONSE BASED ON INITIAL USER UTTERANCE */ +function formElicitSlotWithTemplateResponse( + intentName, + slots, + slotToElicit, + template, + sessionAttributes +) { + return { + sessionState: { + sessionAttributes, + dialogAction: { + type: "ElicitSlot", + slotToElicit, + }, + intent: { + name: intentName, + slots, + } + }, + messages: [ + { + contentType: "CustomPayload", + content: JSON.stringify(template), + } + ] + }; +} + +/* CREATE A RESPONSE BASED TERMINATION UTTERANCE FROM THE USER */ +function formTerminalResponse(sessionAttributes,fulfillmentState, intent, messageText) { + return { + sessionState: { + sessionAttributes, + dialogAction: { + type: "Close", + }, + intent: { + confirmationState: "Confirmed", + name: intent, + state: fulfillmentState + }, + }, + messages: [ + { + contentType: "PlainText", + content: messageText, + } + ] + }; +} + +/* CLEAR THE RECENT INTENT HISTORY TO LET USER START OVER IN THE CHAT*/ +function formElicitIntentResponse(sessionAttributes,intentName, messageText) { + return { + sessionState: { + sessionAttributes, + dialogAction: { + type: "ElicitIntent", + }, + intent: { + name: intentName, + }, + }, + messages: [ + { + contentType: "PlainText", + content: messageText, + } + ] + }; +} + +module.exports = { + formElicitSlotWithTemplateResponse, + formTerminalResponse, + formElicitIntentResponse, +}; diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/user_input_handler.js b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/user_input_handler.js new file mode 100644 index 0000000..5d1b474 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/interactive-messaging-lex-codehook/util/user_input_handler.js @@ -0,0 +1,114 @@ +/* user_input_hander.js HANDLES INPUTS PROVIDED BY THE USER TO THE CHAT */ + +const { + formElicitSlotWithTemplateResponse, + formTerminalResponse, + formElicitIntentResponse, +} = require("./response_handler"); + +const { + FULFILLMENT_STATES, + SLOTS, + TEMPLATE_TYPES, + ACTIONS, + TEST_INTERACTIVE_OPTIONS, + TEST_INTERACTIVE_OPTIONS_SLOTS, + TEST_INTERACTIVE_OPTIONS_TEMPLATES, +} = require("../constants/interactive_options"); + +/* HANDLE INITIAL UTTERANCE INPUT */ +function handleElicitAction(request) { + let template = createSimpleListPickerFromOptions( + "How can I help you?", + Object.values(ACTIONS) + ); + return formElicitSlotWithTemplateResponse( + request.currentIntent.name, + request.currentIntent.slots, + SLOTS.ACTION, + template, + request.sessionAttributes + ); +} + +/* HANDLE ACTION INPUT */ +function handleActionResponse(input, request) { + if (ACTIONS.CONTINUE_TO_AGENT === input || ACTIONS.END_CHAT === input ) { + return formTerminalResponse( + request.sessionAttributes, + FULFILLMENT_STATES.FULFILLED, + request.currentIntent.name, + `Received '${input}'` + ); + } else if (ACTIONS.TEST_INTERACTIVE === input) { + let template = createSimpleListPickerFromOptions( + "What would you like to do?", + Object.values(TEST_INTERACTIVE_OPTIONS) + ); + var outputSessionAttributes = request.sessionAttributes || {}; + return formElicitSlotWithTemplateResponse( + request.currentIntent.name, + request.currentIntent.slots, + SLOTS.INTERACTIVE_OPTION, + template, + outputSessionAttributes + ); + } else { + throw new Error(`Invalid action recieved: ${input}`); + } +} + +/* HANDLE INTERACTIVE OPTION INPUT */ +function handleInteractiveOptionResponse(input, request) { + console.log("handleInteractiveOptionResponse"); + let interactionOptionKey = Object.entries(TEST_INTERACTIVE_OPTIONS).filter( + (entry) => entry[1] == input + )[0][0]; + console.log(interactionOptionKey); + let template = TEST_INTERACTIVE_OPTIONS_TEMPLATES[interactionOptionKey]; + let elicitSlot = TEST_INTERACTIVE_OPTIONS_SLOTS[interactionOptionKey]; + + return formElicitSlotWithTemplateResponse( + request.currentIntent.name, + request.currentIntent.slots, + elicitSlot, + template, + request.sessionAttributes + ); +} + +/* HANDLE OTHER RESPONSES */ +function handleOtherResponse(input, request) { + let message = `Received '${input}'\n\nPlease send 'help' to start again`; + return formElicitIntentResponse( + request.sessionAttributes, + request.currentIntent.name, + message + ); +} + +/* CREATE A LIST PICKER */ +function createSimpleListPickerFromOptions(title, options) { + let elements = options.map((option) => { + return { title: option }; + }); + + return { + templateType: TEMPLATE_TYPES.LISTPICKER, + version: "1.0", + data: { + content: { + title: title, + subtitle: "Tap to select option", + elements: elements, + }, + }, + }; +} + +module.exports = { + handleElicitAction, + handleActionResponse, + handleInteractiveOptionResponse, + handleOtherResponse, +}; diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/packaged.yaml b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/packaged.yaml new file mode 100644 index 0000000..de029fc --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/packaged.yaml @@ -0,0 +1,49 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 +Metadata: + AWS::ServerlessRepo::Application: + Name: amazon-connect-interactive-messages-example-lex-v2 + Description: Creates AWS Lambda function to be used as an initialization and validation + code hook in Amazon Lex Bot (v2) for enabling interactive messages in Amazon + Connect Chat. + Author: Amazon Connect Messaging + SpdxLicenseId: MIT-0 + LicenseUrl: s3://amazon-connect-interactive-message-blog-assets-lex-v2/b974f276fb24c64a763c529eb1fd9a05 + ReadmeUrl: s3://amazon-connect-interactive-message-blog-assets-lex-v2/55deff029765dcc1c4918a9573e3b6d7 + Labels: + - connect + - chat + - interactive-messaging + - contact-center + - lambda + - lex + - bot + - lex-v2 + HomePageUrl: https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2 + SemanticVersion: 2.0.1 + SourceCodeUrl: https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2 +Globals: + Function: + Timeout: 30 +Resources: + InteractiveMessagingLambdaFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: s3://amazon-connect-interactive-message-blog-assets-lex-v2/b4a4ab219d54e6c1daf877f8ad1c43ac + Handler: app.lambdaHandler + Runtime: nodejs18.x + Metadata: + SamResourceId: InteractiveMessagingLambdaFunction +Outputs: + InteractiveMessagingLambdaFunction: + Description: Interactive Messaging Lex Lambda Function ARN + Value: + Fn::GetAtt: + - InteractiveMessagingLambdaFunction + - Arn + InteractiveMessagingFunctionIamRole: + Description: Implicit IAM Role created for Interactive Messaging Lex Lambda Function + Value: + Fn::GetAtt: + - InteractiveMessagingLambdaFunctionRole + - Arn diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/samconfig.toml b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/samconfig.toml new file mode 100644 index 0000000..8e255b1 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/samconfig.toml @@ -0,0 +1,10 @@ +version = 2.0 +[default] +[default.deploy] +[default.deploy.parameters] +stack_name = "amazon-connect-interactive-messaging-sar" +s3_bucket = "aws-sam-cli-managed-default-samclisourcebucket-1tuyzwxytd29d" +s3_prefix = "amazon-connect-interactive-messaging-sar" +region = "us-west-2" +confirm_changeset = true +capabilities = "CAPABILITY_IAM" diff --git a/samTemplates/amazon-connect-interactive-messages-example-lex-v2/template.yaml b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/template.yaml new file mode 100644 index 0000000..5701995 --- /dev/null +++ b/samTemplates/amazon-connect-interactive-messages-example-lex-v2/template.yaml @@ -0,0 +1,35 @@ +AWSTemplateFormatVersion: '2010-09-09' +Transform: AWS::Serverless-2016-10-31 + +Metadata: + AWS::ServerlessRepo::Application: + Name: amazon-connect-interactive-messages-example-lex-v2 + Description: Creates AWS Lambda function to be used as an initialization and validation code hook in Amazon Lex Bot (v2) for enabling interactive messages in Amazon Connect Chat. + Author: Amazon Connect Messaging + SpdxLicenseId: MIT-0 + LicenseUrl: LICENSE.txt + ReadmeUrl: README.md + Labels: ['connect', 'chat', 'interactive-messaging', 'contact-center', 'lambda', 'lex', 'bot', 'lex-v2'] + HomePageUrl: https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2 + SemanticVersion: 2.0.1 + SourceCodeUrl: https://github.com/amazon-connect/amazon-connect-chat-ui-examples/tree/master/samTemplates/amazon-connect-interactive-messages-example-lex-v2 + +Globals: + Function: + Timeout: 30 + +Resources: + InteractiveMessagingLambdaFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: interactive-messaging-lex-codehook/ + Handler: app.lambdaHandler + Runtime: nodejs18.x + +Outputs: + InteractiveMessagingLambdaFunction: + Description: "Interactive Messaging Lex Lambda Function ARN" + Value: !GetAtt InteractiveMessagingLambdaFunction.Arn + InteractiveMessagingFunctionIamRole: + Description: "Implicit IAM Role created for Interactive Messaging Lex Lambda Function" + Value: !GetAtt InteractiveMessagingLambdaFunctionRole.Arn diff --git a/samTemplates/amazon-connect-interactive-messages-example/README.md b/samTemplates/amazon-connect-interactive-messages-example/README.md index b6b7743..5e779ac 100644 --- a/samTemplates/amazon-connect-interactive-messages-example/README.md +++ b/samTemplates/amazon-connect-interactive-messages-example/README.md @@ -1,3 +1,10 @@ +> ### **📢 Annoucement:** Amazon Lex V1 will reach end of life on September 15, 2025. +> Please switch to the Lex V2 samTemplate: [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) or follow this migration guide: https://docs.aws.amazon.com/lexv2/latest/dg/migration.html +> +> ![Maintenance](https://img.shields.io/badge/Maintenance-Deprecating_Soon-yellow) + +--- + # A Lambda function code hook for Amazon Connect Chat Interactive Messaging [Lex V1] Set up this AWS Lambda code hook to provide interactive message responses to an Amazon Lex chat bot