I am currently working on an AWS Lex chatbot which will integrate with Lambda. The chatbot's goal is to provide the distance between two cities and return an amount. Here is an example of a chat: Chat example
However, I keep getting "Intent is fulfilled".
Here is a copy of the Lambda code:
import json
import boto3
from boto3.dynamodb.conditions import Key
def lambda_handler(event, context):
destination = event["sessionState"]["intent"]["slots"]["Destination"]["value"]["interpretedValue"]
source = event["sessionState"]["intent"]["slots"]["Source"]["value"]["interpretedValue"]
distance = get_distance(source, destination)
return {
"sessionState": {
"dialogAction": {
"type": "Close"
},
"intent": {
"name": "DistanceIntent"
"state": "Fulfilled"
},
"messages": [
{
"contentType": "PlainText",
"content": f"{distance}"
}
]
}
}
Could you please explain what is wrong?
It would appear that you have yet linked your intent to the Lambda function. There are two steps that are necessary.
This will now ensure that Lex defers all fulfillment to the Lambda function.
An important difference between v1 and v2 of Lex is that you can only configure 1 Lambda function for the entire bot in Lex v2. You will need to consider using a router function for more flexibility. Take a look at the following guide: https://docs.aws.amazon.com/lexv2/latest/dg/lambda-attach.html