如何在dialogflow中获取回退响应

问题描述

我正在使用dialogflow和Google动作构建一个开放式聊天机器人。如果用户输入的响应未落入任何训练短语中,则属于后续回退意图。但是由于用户可以在开放式对话中输入任何内容,因此我想阅读用户输入的内容。这怎么可能?

这是我的代码

app.intent('First',(conv,{number}) => {

    const rating = number;
    
    if(type[0] === 'rating'){
        if(rating >= 1 && rating <= 5){
            senddata[0] =  qstion[0] + rating;
            conv.ask(qstion[1]);
        }
        else{
            conv.ask('Please enter a number between 1 and 5');
        }
    }

});

我如何按照这种跟踪后备意图写出内容以读取响应:

app.intent('First - fallback',(conv) => {

});

以下是意图图像:

“第一”意图:

enter image description here

“第一”意图上下文:

enter image description here

初次备用意图:

enter image description here

“第二个”意图:

enter image description here

解决方法

要从用户那里获取原始文本,可以在conv对象中使用query属性。因此,您可能会有如下一行:

const userSaid = conv.query;