2017-09-23 7 views
1

私のコードとその下にポップアップしたエラーを共有しました。基本的には、チュートリアルhttp://www.girliemac.com/blog/2017/01/06/facebook-apiai-bot-nodejs/と別のものを辿った。私のchatbotはsmalltalkで動作しますが、天気予報のものでは動作しません。私は、チャットボットに私が別の都市の天気予報を返すようにしようとしています。私はチュートリアルを正確に続けました。ちょうど天気APIのものapi.aiとheroku(node.js)を使用したFacebookのメッセンジャーチャットボットのOAuth例外

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から

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

が//コードは、どのように私はこのエラーを修正しますか?

答えて

1

エラーは、recipient.idにメッセージとともに送信しているページスコープのIDが無効であるためです。チュートリアルからsendMessage()関数を丁寧に設定したと仮定すると、おそらく問題は、あなたがボットとチャットを使用しているFacebookアカウントに適切な役割がないことです。

ボットが公開されていない(送信されていない、承認されていない)場合は、ボットにメッセージを送信するために使用しているFacebookアカウントに、管理者、開発者、またはテスターの役割が付与されている必要があります。

関連する問題