I get the error Invalid Lambda Response: Lambda response provided invalid slot names [slotId]
when lambda sends response to lex using elicitSlot
to get slot values for undefined slot.
I referred the lex blueprint code as following.
const handleOrder = async (intentRequest, callback) => {
const source = intentRequest.invocationSource
const id = intentRequest.currentIntent.slots.slotId
if (source === 'DialogCodeHook') {
// Perform basic validation on the supplied input slots. Use the elicitSlot dialog action to re-prompt for the first violation detected.
const slots = intentRequest.currentIntent.slots
const validationResult = validateOrderRequest(id)
if (!validationResult.isValid) {
//reset the slot value
slots[`${validationResult.violatedSlot}`] = null
callback(elicitSlot(intentRequest.sessionAttributes, intentRequest.currentIntent.name, slots, validationResult.violatedSlot, validationResult.message))
return;
}
const outputSessionAttributes = intentRequest.sessionAttributes || {}
callback(delegate(outputSessionAttributes, intentRequest.currentIntent.slots))
return;
}
...
}
function validateOrderRequest(id) {
if(!id){
return buildValidationResult(false, 'slotId', `Tell me the ID.`);
}
}
What could be giving the error?