Trouble with Fulfillment response from Lambda for Lex V2 Bot

0

Hello I am working on a pretty simple Lex V2 bot that recommends movies based off of the slot genre and the connected lambda function hitting an API and returning the top 5 in the genre.

In Lex: One of my utterances is "Suggest a good {genre} movie". When I type that in to test the bot, it responds with "Intent RecommendMovieIntent is fulfilled"

Output of Lex JSON:

**{ "botAliasId": "TSTALIASID", "botId": "770QE6HMIH", "localeId": "en_US", "text": "Suggest a good horror movie", "sessionId": "221398301550540" }

{ "sessionState": { "dialogAction": { "type": "Close" }, "intent": { "name": "RecommendMovieIntent", "slots": { "genre": { "value": { "originalValue": "horror", "interpretedValue": "Horror", "resolvedValues": [ "Horror" ] } } }, "state": "ReadyForFulfillment", "confirmationState": "None" }, "sessionAttributes": {}, "originatingRequestId": "ef5552bd-c4ad-43dd-a34c-ef6a134e42cf" }, "interpretations": [ { "nluConfidence": { "score": 1 }, "intent": { "name": "RecommendMovieIntent", "slots": { "genre": { "value": { "originalValue": "horror", "interpretedValue": "Horror", "resolvedValues": [ "Horror" ] } } }, "state": "ReadyForFulfillment", "confirmationState": "None" }, "interpretationSource": "Lex" }, { "intent": { "name": "FallbackIntent", "slots": {} }, "interpretationSource": "Lex" } ], "sessionId": "221398301550540" }**

And here is the response from my Lambda:

**Test Event Name MovieRecommendationEvent

Response { "sessionState": { "dialogAction": { "type": "Delegate" }, "intent": { "confirmationState": "Confirmed", "name": "RecommendMovieIntent", "state": "ReadyForFulfillment" }, "sessionAttributes": {} }, "messages": [ { "contentType": "PlainText", "content": "Here are some popular Horror movies: \nThe OctoGames\nThe Exorcism of Hannah Stevenson\nDeep Fear\nHaunting of the Queen Mary\nThe Farm" } ], "requestAttributes": {} }

Function Logs START RequestId: f0f00b2d-e28f-411c-9060-913823e0e846 Version: $LATEST [INFO] 2024-02-09T20:46:16.185Z f0f00b2d-e28f-411c-9060-913823e0e846 Received genre: Horror END RequestId: f0f00b2d-e28f-411c-9060-913823e0e846 REPORT RequestId: f0f00b2d-e28f-411c-9060-913823e0e846 Duration: 48.48 ms Billed Duration: 49 ms Memory Size: 128 MB Max Memory Used: 50 MB

Request ID f0f00b2d-e28f-411c-9060-913823e0e846**

Does anyone know why this may be happening?

asked 8 months ago224 views
1 Answer
0

When you use Delegate then the message you send from the lambda will not be used, instead it will use any pre-defined ones in your bot configuration (if any).

What you instead want to do is to set the dialogAction to Close and the state to Fulfilled

{
  "sessionState": {
    "dialogAction": {
      "type": "Close"
    },
    "intent": {
      "confirmationState": "Confirmed",
      "name": "RecommendMovieIntent",
      "state": "Fulfilled"
    },
    "sessionAttributes": {}
  },
  "messages": [
    {
      "contentType": "PlainText",
      "content": "Here are some popular Horror movies: \nThe OctoGames\nThe Exorcism of Hannah Stevenson\nDeep Fear\nHaunting of the Queen Mary\nThe Farm"
    }
  ],
  "requestAttributes": {}
}
AWS
Gillian
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 6 months 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