【问题标题】:Invalid Lambda Response: Lambda response provided invalid slot names [slotId]无效的 Lambda 响应:Lambda 响应提供了无效的插槽名称 [slotId]
【发布时间】: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


    【解决方案1】:

    你不需要使用语句

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-05
      • 2021-10-23
      • 2018-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多