I have a lex bot which triggers lambda where slot conditions are checked(eg:phone number should be 10 digit) and it returns a closing response of text.
function closeresponse(intent_request, session_attributes, fulfillment_state, message) {
return {
"sessionState": {
"sessionAttributes": session_attributes,
"dialogAction": {
"type": "Close"
},
"intent": {
'name': intent_request[ENTITY.sessionState][ENTITY.intent][ENTITY.name],
'state': fulfillment_state
}
},
"messages": [message],
"sessionId": intent_request["sessionId"],
"requestAttributes": intent_request[ENTITY.requestAttributes] ? intent_request[ENTITY.requestAttributes] : {}
}
}
after closing response i am not able trigger any function
i need to trigger another intent which has yes or no response card in same lambda function
2
Answers
If you want to confirm this intent dialogAction have to be confirmIntent.
If you want to call another intent from this intent the dialogAction have to be elicitIntent.
The dialogAction
Close
indicates that there will not be a response from the user. In other words, this type doesn’t take any further input and will end the entire intent. Therefore, Lex doesn’t expect further input from the user.For your case, you need to accept further input from the user so
Close
isn’t the right dialogAction here. As Jinen said, try changing the dialogAction type toConfirmIntent
orElicitSlot
.If you need the intent to end after the user responds with yes/no, I think
ConfirmIntent
is right in line with what you’re looking to do. For this one, Lex asks the user a yes or no question on if the intent is complete and ready to be fulfilled.This piece of documentation explains the different types of dialogAction. It’s a useful reference for if you get stuck 🙂