【问题标题】:Wit.ai: How to send a message when confidence below a certain level?Wit.ai:当信心低于一定水平时如何发送消息?
【发布时间】:2016-10-13 09:52:32
【问题描述】:

我正在玩 Wit.ai Facebook Messenger 示例 (https://github.com/wit-ai/node-wit/blob/master/examples/messenger.js)

有没有办法在用户的消息不理解时发送预设响应。当信心低于某个阈值时,我正在考虑以某种方式停止机智对话。

非常感谢任何帮助。谢谢。

【问题讨论】:

    标签: node.js facebook-messenger wit.ai


    【解决方案1】:

    如果您想要更精细的控制,您可以直接使用Wit API并跳过所有ui。

    function getIntent(message) {
      var serviceResult = {};
      var url = 'https://api.wit.ai/message?v=20161006&q='+message;
      var options = {
        uri: url,
        qs: {},
        method: 'POST',
        headers: {},
        auth: {'bearer': process.env.WIT_TOKEN},
        json: true
      };
      request(options, function(error, response, body) {
        if(!error) {
          serviceResult.result = "success";
          // Check for entities
          if(body.entities.contact) {
            serviceResult.entity = body.entities.contact[0].value;
            serviceResult.entityConfidence = body.entities.contact[0].confidence;
          }
          // Check for intent
          if(body.entities.intent) {
            serviceResult.intent = body.entities.intent[0].value;
            serviceResult.intentConfidence = body.entities.intent[0].confidence;
          }
        }
        else {
          serviceResult.result = "fail";
        }
      });
    }
    

    您的机器人可以根据置信度值决定它想要做什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 2022-11-18
      • 1970-01-01
      • 2018-07-25
      • 2020-07-01
      • 2019-08-13
      • 1970-01-01
      相关资源
      最近更新 更多