aws-samples / aws-lex-web-ui

Sample Amazon Lex chat bot web interface
Other
736 stars 469 forks source link

ImageResponseCard not working (with Voice Input) #541

Closed fjaviermoradiaz closed 1 year ago

fjaviermoradiaz commented 1 year ago

I know that this is a repeat issue but I can't solve this problem. This is a response from my lex bot (v2):

{
   "sessionState": {
      "activeContexts": [
         {
            "name": "intentContext",
            "contextAttributes": {},
            "timeToLive": {
               "timeToLiveInSeconds": 600,
               "turnsToLive": 1
            }
         }
      ],
      "sessionAttributes": {
         "localTimeZone": "\"Europe/Madrid\"",
         "currentInvoice": "{\"code\": null}",
         "invoice_pagination": 2
      },
      "dialogAction": {
         "type": "ElicitSlot",
         "slotToElicit": "invoice_number"
      },
      "intent": {
         "confirmationState": "None",
         "name": "ListadoFacturas",
         "state": "Fulfilled"
      }
   },
   "messages": [
      {
         "content": "Select option",
         "contentType": "PlainText"
      },
      {
         "contentType": "ImageResponseCard",
         "content": "card title",
         "imageResponseCard": {
            "title": "Select item",
            "subtitle": "Select item",
            "imageUrl": "string",
            "buttons": [
               {
                  "text": "19/01/2022 33.38 €",
                  "value": "2022-01-11-00.38.00.217065"
               },
               {
                  "text": "19/02/2022 43.38 €",
                  "value": "2022-02-11-00.38.00.217080"
               },
               {
                  "text": "19/03/2022 45.02 €",
                  "value": "2022-03-11-00.38.00.217090"
               },
               {
                  "text": "19/04/2022 41.12 €",
                  "value": "2022-04-11-00.38.00.217099"
               },
               {
                  "text": "Mostrar más",
                  "value": "Show more"
               }
            ]
         }
      }
   ]
}

When I try with input text , it's working fine...

With text input:

Screenshot 2023-08-30 at 17 52 50

With voice: is calling to "utterance" (not text)

Screenshot 2023-08-30 at 17 54 04

I have also sent in session attributes:

Screenshot 2023-08-30 at 18 49 21

I'm sending responseCard as I seen in previous posts, but not work:

Example of data returned in my session_attributes:

{
  "localTimeZone": "\"Europe/Madrid\"",
  "currentInvoice": "{\"code\": null}",
  "invoice_pagination": "2",
  "appContext": "{\"altMessages\": {\"ssml\": \"Seleccione una opción\"}, \"responseCard\": {\"version\": \"1\", \"contentType\": \"application/vnd.amazonaws.card.generic\", \"genericAttachments\": [{\"title\": \"\", \"buttons\": [{\"text\": \"yes\", \"value\": \"yes\"}, {\"text\": \"no\", \"value\": \"no\"}]}]}}"
}
fjaviermoradiaz commented 1 year ago

Finally works, but I have needed to comment this block in record-handlers.js

 // handle being interrupted by text
  /*if (context.state.lex.dialogState !== 'Fulfilled' &&
      !context.state.recState.isConversationGoing
  ) {
    return Promise.resolve();
  }*/