Skip to content

create samTemplate Lex V2 interactive msg lambda hook #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spenlep-amzn
Copy link
Collaborator

@spenlep-amzn spenlep-amzn commented Mar 4, 2024

Description

Adding a new SAM template for chat interactive messages w/ Lex V2 support. The current template only supports Lex V1

I copy/pasted the existing template and made minor refactors to support Lex V2 (mainly interactive-messaging-lex-codehook/app.js). Since we don't have a blog post for this setup, I added detailed instructions to the README (preview it here).

Background

Customers that use Amazon Connect chat (both Hosted Widget and Customer builder) want to enhance the chat experience with interactive messages and Lex bots. To configure this, they need to integrate a lambda code-hook to handle dynamic conversations (e.g. "help", "talk to agent", "view flight plans").

They can one-click deploy this AWS Lamba and follow instructions to configure interactive messages. They will add this to an Amazon Lex V2 bot and a chat-based Amazon Connect contact flow.

We already have a sample and blog article for Amazon Lex V1, but that will reach end of life on September 15, 2025. We want to support onboarding customers using Amazon Lex V2 (around since Jan 22, 2021)

Testing

Everything has been deployed+tested (on 4/7/2025)

TestChatPageExample

Checklist

Links

@spenlep-amzn spenlep-amzn changed the title add samTemplate for interactive msg lex v2 assets create samTemplate for interactive msg lex v2 assets Mar 5, 2024
@spenlep-amzn spenlep-amzn self-assigned this Mar 5, 2024
@spenlep-amzn spenlep-amzn changed the title create samTemplate for interactive msg lex v2 assets create samTemplate Lex V2 interactive msg lambda hook Mar 5, 2024
@spenlep-amzn spenlep-amzn force-pushed the spenlep/interactive-msg-lex-v2-assets branch 2 times, most recently from 931a124 to 7f60e85 Compare March 5, 2024 00:42
@spenlep-amzn spenlep-amzn requested a review from efh365 March 5, 2024 00:42
@spenlep-amzn spenlep-amzn marked this pull request as ready for review March 5, 2024 00:47
@spenlep-amzn spenlep-amzn requested a review from a team as a code owner March 5, 2024 00:47
@spenlep-amzn spenlep-amzn requested review from mliao95 and mhiaror and removed request for a team and efh365 March 5, 2024 00:47
@spenlep-amzn spenlep-amzn added the 🚀 Feature New feature implementation label Mar 5, 2024
@spenlep-amzn spenlep-amzn removed the 🚀 Feature New feature implementation label Apr 7, 2025
@spenlep-amzn spenlep-amzn force-pushed the spenlep/interactive-msg-lex-v2-assets branch 3 times, most recently from 9be498a to 7ec9fa6 Compare April 7, 2025 23:24
@spenlep-amzn spenlep-amzn requested review from a team, jagadeeshaby, agarwhi and chauhuynh97 and removed request for mliao95, mhiaror, a team, jagadeeshaby and agarwhi April 7, 2025 23:27
@spenlep-amzn spenlep-amzn force-pushed the spenlep/interactive-msg-lex-v2-assets branch 2 times, most recently from 4080405 to ec9cd60 Compare April 8, 2025 21:46
@spenlep-amzn spenlep-amzn requested a review from efh365 April 8, 2025 21:50
@spenlep-amzn
Copy link
Collaborator Author

Notes: adding a new path

  1. Update the lambda (see lambda.diff) and deploy
  2. Update the slot types
  • Navigate to Lex > Bots > Bot: Interactiv... > Versions > Version: DRAFT > All languages > Language: English (US) > Slot types > Slot type: InteractiveOption
  • Add value "View flight options" (matching TEST_INTERACTIVE_OPTIONS.MY_PICKER_NAME)
  1. Update the intent
  • Navigate to Lex > Bots > Bot: Interactiv... > Versions > Version: DRAFT > All languages > Language: English (US) > Slot types
  • Add slot type "Blank type", named "FlightOptions", add values matching TEST_INTERACTIVE_OPTIONS_TEMPLATES.MY_TEMPLATE.content.elements
  1. Navigate to Lex > Bots > Bot: Interactiv... > Versions > Version: DRAFT > All languages > Language: English (US) > Intents > InteractiveMessageIntent
  2. Add slot { name: 'flightOptions', slotType: FlightOptoins, prompt: 'View our popular destinations' }
  3. Save intent, build & test
// lambda.diff
index dec63fe..7a7b60f 100644
--- 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
@@ -2,9 +2,8 @@
 const TEMPLATE_TYPES = {
   LISTPICKER: "ListPicker",
   TIMEPICKER: "TimePicker",
+  QUICK_REPLY: "QuickReply",
+  CAROUSEL: "Carousel",
 };
 
 /*IMAGES USED FOR INTERACTIVE MESSAGES*/
@@ -31,6 +30,8 @@ const SLOTS = {
   ACTION: "action",
   INTERACTIVE_OPTION: "interactiveOption",
   DEPARTMENT: "department",
+  QUICK_REPLY: "quickReply",
+  FLIGHT_OPTIONS_CAROUSEL: "flightOptions",
   APPOINTMENT: "appointment"
 };
 
@@ -52,6 +53,8 @@ const ACTIONS = {
 /*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"
 };
 
@@ -59,6 +62,8 @@ const TEST_INTERACTIVE_OPTIONS = {
 /*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
@@ -147,6 +152,83 @@ const TEST_INTERACTIVE_OPTIONS_TEMPLATES = {
       },
     },
   },
+  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"
+                  }
+                ]
+              }
+            }
+          }
+        ]
+      }
+    }
+  }
 };

@spenlep-amzn spenlep-amzn force-pushed the spenlep/interactive-msg-lex-v2-assets branch from 078ad49 to 5d5d8cb Compare April 11, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants