2017-09-23 111 views
1

我已經分享了我的代碼以及下面彈出的錯誤。基本上,我遵循教程http://www.girliemac.com/blog/2017/01/06/facebook-apiai-bot-nodejs/和另一個。我的chatbot適用於smalltalk,但不適用於天氣api的東西。我正在努力讓聊天機器人給我答覆不同城市的天氣。我完全按照教程。使用api.ai和heroku的Facebook Messenger聊天機器人中的OAuth異常(node.js)

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' } 

//從只是天氣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 
      } 
     }); 
     } 
    }) 
    } 

}); 

index.js代碼如何解決這個問題?

回答

1

錯誤是因爲您使用recipient.id中的消息發送的頁範圍ID無效。假設您已經從教程中正確地設置了sendMessage()函數,最有可能的問題是您正在使用與bot聊天的Facebook帳戶沒有適當的角色。

如果機器人不公開(即尚未提交和批准),則用於向機器人發送消息的Facebook帳戶必須在您的應用設置中被授予管理員,開發人員或測試人員角色。

相關問題