1

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.`);
    }
}

什么可能导致错误?

4

1 回答 1

-1

您无需使用该语句

插槽[ ${validationResult.violatedSlot}] = null;

将槽值分配给 null 并不是一个好习惯。

删除此声明。我希望你不会得到那个错误。

于 2018-04-30T05:02:20.000 回答