【发布时间】:2018-04-08 08:05:38
【问题描述】:
当 lambda 使用 elicitSlot 向 lex 发送响应以获取未定义插槽的插槽值时,我收到错误 Invalid Lambda Response: Lambda response provided invalid slot names [slotId]。
我将 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.`);
}
}
什么可能导致错误?
【问题讨论】:
标签: node.js aws-lambda bots aws-lex