DialogFlow 不需要的响应:关键字 "Negative" 总是触发 "Okay, cancelled."

DialogFow unwanted response: the keyword "Negative" always triggers "Okay, cancelled."

Chatbot: Are you emotionally feeling positive, negative, neutral? \User: negative.
(Unwanted response) Chatbot: okay, cancelled.
(Wanted response) Chatbot: you are feeling negative. Can you tell me more?

我使用槽位填充来提取用户的响应:{negative, positive, neutral}。 “积极”“中性”被很好地捕捉到了。如果用户说“否定”,它总是会触发“好的,已取消”响应。

根据这个documentation,当最终用户说出任何退出短语,如“取消”、“停止它”、“否定”等时,Dialogflow代理将回复 “好的,已取消” 消息并清除槽填充上下文。有时,除了显示 “确定取消” 消息外,其他类似消息也可能显示为 “好的,已取消”、“没问题,正在取消”等等

为避免这种情况,您可以使用 “低”、“不好” 等类似的负面词来代替“负面”,您会得到想要的回应。

您可以参考以下聊天机器人回复截图:

1.您面临的问题:

2。其他类似回复:

3。使用类似于“否定”一词的短语:

Dialogflow 代理响应:“你情绪低落。你能告诉我更多吗”

有几个词,如 "stop,abort,negative,exit" 等,在 Dialogflow 中用作退出短语。取消短语列表类似于预构建的 smalltalk 代理的“取消”意图。要找到它,请转到 Prebuilt Agents -> Small Talk -> Import. Then navigate to that agent and find the intent "smalltalk.cancellation.cancel" 查看短语列表。

如果您想在回复中添加 negative 这个词,可以通过 Fulfillment Webhook 回复来实现。

您可以参考以下步骤:

  1. 创建意图情感
  2. 创建一个自定义实体情绪,添加文字积极、消极、中性
  3. 向意图添加训练短语,如
 "feeling positive"
 "feeling negative"
 "feeling neutral"

这些词将映射到自定义实体 @emotions

  1. 为“情感”意图启用实现:
 1. enable Webhook call for this intent
 2. Enable Webhook call for slot filling
  1. 编写您的 Fulfillment Webhook 代码:

我已经使用 node.js 10

编写了代码

index.js

 
'use strict';
 
const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
 
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
 
exports.slot = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));
 

  function emo(agent){
    
    const emotions=agent.parameters[`emotions`];
    agent.add(`you are feeling ` +   emotions + `,Can you tell me more?`);
  }
  
  

  let intentMap = new Map();
  
  intentMap.set('emotional', emo);
  
  agent.handleRequest(intentMap);
});


package.json:

{
  "name" : "slot",
 "description": "This is the webhook",
 "version": "0.0.1",
 "private": true,
 "license": "Apache Version 2.0",
 "author": "Google Inc.",
 "engines": {
   "node": "10"
 },
  "dependencies": {
   "actions-on-google": "^2.2.0",
   "firebase-admin": "^5.13.1",
   "firebase-functions": "^2.0.2",
   "dialogflow": "^0.6.0",
   "dialogflow-fulfillment": "^0.6.1"
 }
}

输出:

user : "hi"

response(Default welcome Intent) :  "Are you emotionally feeling positive, negative, neutral?"

user : "i am feeling negative"

response : "you are feeling negative,Can you tell me more?"