Lex v2 fulfillment with Lambda function - issue with message to return to user

0

I have a Lex v2 bot which uses a Lambda function (Nodejs 16) for fulfillment. I can confirm that the bot is setup to call the function, the function itself is called as I can see log entries in the Cloudwatch tail, the response is sent back without error to the Lex bot however the message that I have defined in the response JSON does not play. Not sure what I'm doing wrong, the format of the response message appears fine and I get no errors thrown from Lex when testing - the only issue is that I just get the default message that the intent is fulfilled, I don't see the response message that I'm setting. I'm attaching the response JSON below. Do I need to do something special within the configuration of the Lex fulfillment messages to reference a variable?? (Note: both fulfillment and closing are active in the bot, however I do not have custom messages defined for either)

JSON I'm sending back:

{
  "sessionState": {
    "dialogAction": {
      "type": "Delegate"
    },
    "intent": {
      "confirmationState": "Confirmed",
      "name": "LexIntent",
      "state": "Fulfilled"
    }
  },
  "messages": [
    {
      "contentType": "PlainText",
      "content": "Hello World from my Lambda function"
    }
  ]
}

asked 7 months ago586 views
1 Answer
0
Accepted Answer

Hello,

I understand that you have a LEX bot invoking your lambda function and function is returning Json back to LEX bot and you are not able to receive the configured message and getting the default message which states that the intent is fulfilled.

From the AWS documentation, I found this point “state – The state can only be ‘ReadyForFulfillment’ if dialogAction.type is Delegate.

[+] https://docs.aws.amazon.com/lexv2/latest/dg/lambda-response-format.html

From the JSON response shared by you I could see that you are configuring state as {“state”: “Fulfilled”}. Could you please try to modify this to {“state": "ReadyForFulfillment”} and check if it works for you and I would also request you to refer the above article for additional information regarding the response format. Please note that response field information is case sensitive.

Further if you have any queries please reach out to AWS Premium Support.

Thank you

likhita
answered 7 months ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions