首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多转对话槽确认在alexa技能?

多转对话槽确认在alexa技能?
EN

Stack Overflow用户
提问于 2018-06-08 07:08:14
回答 1查看 177关注 0票数 1

我在lambda.But中为单个时隙确认编写了这段代码,这不是work.Only --它将调用名称时隙,而不是限定槽。

代码语言:javascript
复制
// Confirm slot: name
                if(intentObj.slots.name.name == "name") {
                    if (intentObj.slots.name.confirmationStatus !== 'CONFIRMED') {
                        if (intentObj.slots.name.confirmationStatus !== 'DENIED') {
                            // slot status: unconfirmed
                            const slotToConfirm = 'name';
                            const speechOutput = 'Your name is ' + intentObj.slots.name.value + ', is that right?';
                            //  const repromptSpeech = speechOutput;
                            this.emit(':confirmSlot', slotToConfirm, speechOutput);
                        } else {
                            // slot status: denied => ask again
                            const slotToElicit = 'name';
                            const speechOutput = 'What is your name?';
                            //const repromptSpeech = 'Please tell me what is your name';
                            const updatedIntent = 'DialogIntent';
                            this.emit(':elicitSlot', slotToElicit, speechOutput, updatedIntent);
                        }
                    }
                }

            // Confirm slot: qualification
            if(intentObj.slots.qualification.qualification == "qualification") {
                    if (intentObj.slots.qualification.confirmationStatus !== 'CONFIRMED') {
                        if (intentObj.slots.qualification.confirmationStatus !== 'DENIED') {
                            // slot status: unconfirmed
                            const slotToConfirm = 'qualification';
                            const speechOutput = 'Your qualification is ' + intentObj.slots.qualification.value + ', is that right?';
                            //  const repromptSpeech = speechOutput;
                            this.emit(':confirmSlot', slotToConfirm, speechOutput);
                        } else {
                            // slot status: denied => ask again
                            const slotToElicit = 'qualification';
                            const speechOutput = 'What is your qualification?';
                            //const repromptSpeech = 'Please tell me what is your qualification';
                            const updatedIntent = 'DialogIntent';
                            this.emit(':elicitSlot', slotToElicit, speechOutput, updatedIntent);
                        }
                    }
                }

请分享有关插槽确认的任何信息。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-08 14:33:54

您的第一个插槽的if语句始终是正确的。

if(intentObj.slots.name.name == "name") {.}

这是因为slots.slotName.name将始终是时隙的名称。这是一个无用的if语句。

您可能希望检查是否设置了插槽,并且值为null。然后你可以稍微改变一下你的逻辑。

代码语言:javascript
复制
if(intentObj.slots.name && intentObj.slots.name.value !== null) { 
    // check if confirmed or not
} else {
    // elicit slot "name"
}

第二个插槽的if语句将始终是假的。

if(intentObj.slots.qualification.qualification ==“资格”){

这是因为在qualification数组中没有slots.slotName键。因此,只需将其更改为与上面的类似,检查是否设置了qualification插槽,该值是否为null。

代码语言:javascript
复制
if(intentObj.slots.qualification && intentObj.slots.qualification.value !== null) { 
    // check if confirmed or not
} else {
    // elicit slot "qualification"
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50755207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档