【问题标题】:OAuth Exception in Facebook messenger chatbot using api.ai and heroku(node.js)使用 api.ai 和 heroku(node.js) 的 Facebook Messenger 聊天机器人中的 OAuth 异常
【发布时间】:2018-03-04 17:05:50
【问题描述】:

我已经分享了我的代码和下面弹出的错误。基本上,我遵循了教程http://www.girliemac.com/blog/2017/01/06/facebook-apiai-bot-nodejs/ 和另一个教程。我的聊天机器人适用于 smalltalk,但不适用于天气 api 的东西。我试图让聊天机器人给我关于不同城市天气的答案。我完全按照教程进行操作。

  Error:  { message: '(#100) No matching user found',
  type: 'OAuthException',
   code: 100,
  error_subcode: 2018001,
   fbtrace_id: 'DeubaTWU6Gg' }
 Error:  { message: '(#100) No matching user found',
   type: 'OAuthException',
   code: 100,
   error_subcode: 2018001,
   fbtrace_id: 'FSiMes3IwHv' }

//index.js 中的代码只用于天气 api 的东西

 app.post('/ai', (req, res) => {
  //console.log('*** Webhook for api.ai query ***');
  //console.log(req.body.result);

  if (req.body.result.action === 'weather') {
 //  console.log('*** weather ***');
    let city = req.body.result.parameters['geo-city'];
    let restUrl = 'http://api.openweathermap.org/data/2.5/weather?APPID='+process.env.WEATHER_API_KEY+'&q='+city;

    request.get(restUrl, (err, response, body) => {
      if (!err && response.statusCode == 200) {
        let json = JSON.parse(body);
       // console.log(json);
        let tempF = ~~(json.main.temp * 9/5 - 459.67);
        let tempC = ~~(json.main.temp - 273.15);
        let msg = 'The current condition in ' + json.name + ' is ' + json.weather[0].description + ' and the temperature is ' + tempF + ' ℉ (' +tempC+ ' ℃).'
        return res.json({
          speech: msg,
          displayText: msg,
          source: 'weather'
        });
      } else {
        let errorMessage = 'I failed to look up the city name.';
        return res.status(400).json({
          status: {
            code: 400,
            errorType: errorMessage
          }
        });
      }
    })
  }

});

如何解决此错误?

【问题讨论】:

    标签: node.js facebook heroku dialogflow-es facebook-chatbot


    【解决方案1】:

    错误是因为您与recipient.id 中的消息一起发送的页面范围 ID 无效。假设您已正确设置教程中的 sendMessage() 功能,问题很可能是您使用聊天机器人的 Facebook 帐户没有正确的角色。

    如果机器人未公开(即尚未提交和批准),则必须在您的应用设置中为您用于向机器人发送消息的 Facebook 帐户授予管理员、开发人员或测试人员角色。

    【讨论】:

      猜你喜欢
      • 2016-08-14
      • 2019-01-03
      • 1970-01-01
      • 2020-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-30
      相关资源
      最近更新 更多