如何在对话流中获得回退响应 [英] How to get the fallback response in dialogflow
问题描述
我正在使用 dialogflow 和 actions-on-google 构建一个开放式聊天机器人.如果用户输入的响应不属于任何训练短语,则它属于后续回退意图.但由于用户可以在开放式对话中输入任何内容,我想阅读用户输入的内容.这怎么可能?
I am building an open ended chatbot using dialogflow and actions-on-google. If the response entered by the user does not fall into any of the training phrases it falls into the followup-fallback intent. But as the user can enter anything in an open-ended conversation, I want to read what the user has entered. How is this possible?
这是我的代码:
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');
}
}
});
我在这个后续回退意图中写了什么来读取响应:
What do I write in this followup-fallback intent to read the response:
app.intent('First - fallback', (conv) => {
});
以下是意图图像:
第一"意图:
第一个"意图上下文:
第一回退意图:
第二个"意图:
推荐答案
要从用户那里获取原始文本,您可以使用 query
属性> 对象.所以你可能有这样一行:
To get the raw text from the user, you can use the query
attribute in the conv
object. So you might have a line such as:
const userSaid = conv.query;
这篇关于如何在对话流中获得回退响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!