如何处理与实体值不匹配的值?
How to handle values that don't match entity value?
您好,我在 dialogflow 中创建了一个名为 answers
的实体,该实体包含了我问答游戏的所有问题答案。
我从我的数据库中获取问题,然后检查给出的答案是否正确。
app.intent('answer-question', (conv, {answer})=> {
if(answer == ((conv.data.answers)[0])){
//stuff}
else{
conv.close('you lose');
}
});
不过,此功能只有在用户答对的情况下才有效。如果用户回答错误,我会收到以下错误:
"Question Master isn't responding right now. Try again soon."
MalformedResponse
'final_response' must be set.
所以我的问题是,我如何才能满足用户可能给出的无数错误答案的选择?
干杯!
你应该在后备意图中处理它。新的 Dialogflow 代理带有默认值:https://dialogflow.com/docs/intents/default-intents#default_fallback_intent
您还应该考虑使用上下文,以便后备意图知道您在期待答案,并在不需要答案时提供不同的响应。
您好,我在 dialogflow 中创建了一个名为 answers
的实体,该实体包含了我问答游戏的所有问题答案。
我从我的数据库中获取问题,然后检查给出的答案是否正确。
app.intent('answer-question', (conv, {answer})=> {
if(answer == ((conv.data.answers)[0])){
//stuff}
else{
conv.close('you lose');
}
});
不过,此功能只有在用户答对的情况下才有效。如果用户回答错误,我会收到以下错误:
"Question Master isn't responding right now. Try again soon."
MalformedResponse
'final_response' must be set.
所以我的问题是,我如何才能满足用户可能给出的无数错误答案的选择?
干杯!
你应该在后备意图中处理它。新的 Dialogflow 代理带有默认值:https://dialogflow.com/docs/intents/default-intents#default_fallback_intent
您还应该考虑使用上下文,以便后备意图知道您在期待答案,并在不需要答案时提供不同的响应。