Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 当信心低于一定水平时,如何发送信息?_Node.js_Facebook Messenger_Wit.ai - Fatal编程技术网

Node.js 当信心低于一定水平时,如何发送信息?

Node.js 当信心低于一定水平时,如何发送信息?,node.js,facebook-messenger,wit.ai,Node.js,Facebook Messenger,Wit.ai,我在玩Wit.ai Facebook Messenger示例() 当用户的信息不被理解时,是否有方法发送预设响应。我在想,当信心低于某个临界值时,如何停止机智的对话 非常感谢您的帮助。谢谢。如果需要更精细的控制,您可以直接使用Wit API并跳过所有ui function getIntent(message) { var serviceResult = {}; var url = 'https://api.wit.ai/message?v=20161006&q='+message

我在玩Wit.ai Facebook Messenger示例()

当用户的信息不被理解时,是否有方法发送预设响应。我在想,当信心低于某个临界值时,如何停止机智的对话


非常感谢您的帮助。谢谢。

如果需要更精细的控制,您可以直接使用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";
    }
  });
}

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

如果您想要更精细的控制,您可以直接使用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";
    }
  });
}
您的机器人可以根据置信值决定它想要做什么