Invalid Lambda Response: Lambda response provided invalid slot names [slotId]
当 lambda 向 lex 发送响应以elicitSlot
获取未定义插槽的插槽值时,我收到错误消息。
我将 lex 蓝图代码引用如下。
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.`);
}
}
什么可能导致错误?