aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

DialogAction marshalls message incorrectly when send from lambda to lex

Open takealot38-github opened this issue 5 years ago • 4 comments

DialogAction marshalls message incorrectly when send from lambda to lex

Describe the bug

The message and message content type should be enclosed in a separate json token called "message" as per https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html and they are not - they are enclosed in token DialogAction directly.

Expected Behavior

Should marshalls as follows: "dialogAction": { "type": "ElicitSlot", "message": { "contentType": "PlainText or SSML or CustomPayload", "content": "Message to convey to the user. For example, What size pizza would you like?" }, "intentName": "intent-name", "slots": { "slot-name": "value", "slot-name": "value", "slot-name": "value"
}, "slotToElicit" : "slot-name", "responseCard": { "version": integer-value, "contentType": "application/vnd.amazonaws.card.generic", "genericAttachments": [ { "title":"card-title", "subTitle":"card-sub-title", "imageUrl":"URL of the image to be shown", "attachmentLinkUrl":"URL of the attachment to be associated with the card", "buttons":[ { "text":"button-text", "value":"Value sent to server on button click" } ] } ] } }

Current Behavior

{"dialogAction":{"type":"ElicitSlot","intentName":"CaptureRentroll","slots":{"month":"May","address":"25 Obama Str},"slotToElicit":"RENT1","message":"What is the rent1?","message Format":"PlainText"}}

takealot38-github avatar May 11 '20 07:05 takealot38-github

Hi @janrb please provide more context on the issue you are running into:

  • Are you using a custom lambda function? Can you provide its code?
  • Can you provide a sample, reproducible code where the Lex Client uses the response from the Lambda function?
  • What are the error messages you're seeing?
  • What version of the Java SDK are you using?

debora-ito avatar May 12 '20 21:05 debora-ito

Hi debora-ito

Thank you for looking into it

I zipped the entire lambda project to https://github.com/janrb/TestManageBotLambda. In the root of the zip you will find a screenshot detailing how to configure the lex bot.

The error message is: An error has occurred: Invalid Lambda Response: Received invalid response from Lambda: Can not construct instance of Message: no String-argument constructor/factory method to deserialize from String value ('Hello peter, my name is Worf') at [Source: {"dialogAction":{"type":"ElicitSlot","intentName":"Hi","slots":{"response":null,"name":"peter"},"slotToElicit":"response","message":"Hello peter, my name is Worf","messageFormat":"PlainText"},"sessionAttributes":{}}; line: 1, column: 133]

I believe it is due to the bot expecting the message and messageFormat strings enclosed inside "message" inside "dialogAction" instead of being at the root of "dialogAction"

I am using java8.

Regards Rudolph Buhrmann

takealot38-github avatar May 13 '20 18:05 takealot38-github

@janrb so it is your lambda function that is sending the response in the wrong format, isn't it? I don't see what is the issue with the SDK in this case.

debora-ito avatar Jun 03 '20 17:06 debora-ito

@debora-ito I do not agree. Please explain to me what I am doing wrong here? I instantiate object DialogAction expecting it to unmarshall the message information to

"dialogAction": { "type": "ElicitSlot", "message": { "contentType": "PlainText or SSML or CustomPayload", "content": "Message to convey to the user. For example, What size pizza would you like?" },


}

Instead it unmarshalls to "dialogAction":{"type":"ElicitSlot","intentName":"Hi","slots":{"response":null,"name":"peter"},"slotToElicit":"response","message":"Hello peter, my name is Worf","messageFormat":"PlainText"},"sessionAttributes":{}}

What am I doing wrong here? I suppose you can let it rest as I came right elsewhere.

Regards, RudolphB

takealot38-github avatar Jun 08 '20 06:06 takealot38-github

Hi @takealot38-github

I apologize but I didn't have the chance to troubleshoot this further. We are closing old v1 issues before going into Maintenance Mode, so I recommend you check if this issue still persists in v2 and open a new issue in the v2 repo if it's the case.

debora-ito avatar Jun 19 '24 00:06 debora-ito

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.

github-actions[bot] avatar Jun 19 '24 00:06 github-actions[bot]