2
votes

I have created custom slot type in Amazon Lex bot. Now I need to add few validations for that slot type. I need to do that in lambda function. I am using NodeJS for Lambda. Is there any way to fetch custom slot type values in lambda function. I referred blueprint function (OrderFlowers, BookAppointment). But there they are not fetching slot types values in lambda.

Thanks, Ganesh

1

1 Answers

0
votes

Your event coming from Lex into Lambda will look something like the JSON object below. The example is for a bot called "TimerTest". The intent that was matched was called "MATCHED_INTENT_NAME". The slot is called "Name". If you want to run validation for the slot called "Name", you can reference the slot value as event.currentIntent.slots.Name in Lambda to run your validation code.

{
	"messageVersion": "1.0",
	"invocationSource": "FulfillmentCodeHook",
	"userId": "UNIQUE_USER_ID",
	"sessionAttributes": {},
	"requestAttributes": null,
	"bot": {
		"name": "TimerTest",
		"alias": "$LATEST",
		"version": "$LATEST"
	},
	"outputDialogMode": "Text",
	"currentIntent": {
		"name": "MATCHED_INTENT_NAME",
		"slots": {
			"Name": "test"
		},
		"slotDetails": {
			"Name": {
				"resolutions": [],
				"originalValue": "test"
			}
		},
		"confirmationStatus": "None"
	},
	"inputTranscript": "test"
}

Additional information can be found here: https://docs.aws.amazon.com/lex/latest/dg/lambda-input-response-format.html

Hope this helps.