首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用api.ai和heroku的Facebook messenger聊天机器人中的OAuth异常(node.js)

使用api.ai和heroku的Facebook messenger聊天机器人中的OAuth异常(node.js)
EN

Stack Overflow用户
提问于 2017-09-23 13:00:30
回答 1查看 306关注 0票数 1

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

代码语言:javascript
复制
  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的代码仅用于天气应用编程接口

代码语言:javascript
复制
 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
          }
        });
      }
    })
  }

});

如何修复此错误?

EN

回答 1

Stack Overflow用户

发布于 2017-09-26 12:25:45

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46376224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档