2016-08-25 19 views
0

私はFacebook Messenger Bot APIを使用しています。HerokuがホストしているNode.jsボットを自分のFacebookアカウント(admin)とFacebookアカウントを追加してテストしていますテスターとして。私がChatBotにメッセージを送るたびに、Chatbotは私に返信することができます。しかし、私がHerokuのログを確認すると、ボットが受信した1つのメッセージに対して2つのメッセージを送信していることがわかりました。私はボットから1つの返信しか受信していませんが、ボットが2番目のメッセージを送信している理由は何ですか? Facebook Messenger Bot API複数のメッセージを送信してエラーを表示する

この

は、ポストのウェブフックとsendMessage関数の両方のコードです

app.post('/webhook', function (req, res) { 
var events = req.body.entry[0].messaging; 
for (i = 0; i < events.length; i++) { 
    var event = events[i]; 
    var sender = event.sender.id 
    if (event.message && event.message.text) { 
     sendMessage(sender, {text: "Hey, did you just say: " + event.message.text}); 
     console.log("sent message to: " + sender); 
    } 
} 
res.sendStatus(200); 
}); 

function sendMessage(recipientId, message) { 
request({ 
    url: 'https://graph.facebook.com/v2.6/me/messages', 
    qs: {access_token: process.env.PAGE_ACCESS_TOKEN}, 
    method: 'POST', 
    json: { 
     recipient: {id: recipientId}, 
     message: message, 
    } 
}, function(error, response, body) { 
    if (error) { 
     console.log('Error sending message: ', error); 
    } else if (response.body.error) { 
     console.log('Error: ', response.body.error); 
    } 
}); 
}; 

私はHerokuの中で私のチャットボットアプリを構築し、私は私の管理者アカウントから私のメッセージを送ったとき、これはログです

2016-08-25T21:16:02.303705+00:00 heroku[web.1]: Restarting 
2016-08-25T21:16:02.304448+00:00 heroku[web.1]: State changed from up to  starting 
2016-08-25T21:16:03.588649+00:00 heroku[web.1]: Starting process with command `node index.js` 
2016-08-25T21:16:05.731964+00:00 heroku[web.1]: Stopping all processes with SIGTERM 
2016-08-25T21:16:06.609304+00:00 heroku[web.1]: Process exited with status 143 
2016-08-25T21:16:07.266798+00:00 heroku[web.1]: State changed from starting to up 
2016-08-25T21:16:39.746253+00:00 app[web.1]: sent message to: 1160285130676682 
2016-08-25T21:16:40.082592+00:00 app[web.1]: sent message to: 284635001929051 
2016-08-25T21:16:40.206265+00:00 app[web.1]: Error: { message: '(#100) No matching user found', 
2016-08-25T21:16:40.206267+00:00 app[web.1]: type: 'OAuthException', 
2016-08-25T21:16:40.206268+00:00 app[web.1]: code: 100, 
2016-08-25T21:16:40.206268+00:00 app[web.1]: fbtrace_id: 'BSxdusFbWB6' } 
2016-08-25T21:16:39.756640+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=7035f788-f103-49d7-99ec-21cf58d30674 fwd="69.63.188.113" dyno=web.1 connect=1ms service=66ms status=200 bytes=196 
2016-08-25T21:16:40.265285+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=71deb2ab-f1db-40cc-a5d1-af926a35b6de fwd="173.252.120.112" dyno=web.1 connect=0ms service=8ms status=200 bytes=196 
2016-08-25T21:16:40.084913+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=61be8207-456c-4337-8c2b-ced6ff742f52 fwd="66.220.158.102" dyno=web.1 connect=0ms service=7ms status=200 bytes=196 

これは私が私のダミーのアカウント(テスター)

2016-08-25T21:16:44.788335+00:00 app[web.1]: sent message to: 1107394752663896 
2016-08-25T21:16:45.195498+00:00 app[web.1]: sent message to: 284635001929051 
2016-08-25T21:16:45.307382+00:00 app[web.1]: Error: { message: '(#100) No matching user found', 
2016-08-25T21:16:45.307384+00:00 app[web.1]: type: 'OAuthException', 
2016-08-25T21:16:45.307385+00:00 app[web.1]: code: 100, 
2016-08-25T21:16:45.307385+00:00 app[web.1]: fbtrace_id: 'GKqZtMZawEv' } 
2016-08-25T21:16:45.194037+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=fce94f53-bd7e-4020-a0b0-ff05638e0b25 fwd="173.252.120.121" dyno=web.1 connect=0ms service=12ms status=200 bytes=196 
2016-08-25T21:16:44.786566+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=3d650955-c9db-47c2-8b69-b919e70bb94e fwd="173.252.120.100" dyno=web.1 connect=2ms service=4ms status=200 bytes=196 
2016-08-25T21:16:45.515394+00:00 heroku[router]: at=info method=POST path="/webhook" host=warm-depths-81393.herokuapp.com request_id=f497c7b2-a9ee-4f9c-83b9-c23a2e358cc1 fwd="66.220.158.111" dyno=web.1 connect=0ms service=2ms status=200 bytes=196 
から別のメッセージを送ったことを示しているログの2番目の部分です

編集:ボットが繰り返しメッセージを送信している2番目のユーザーが実際にチャットボットのFacebookページそのものであることが判明しました。チャットボットが自分自身にもメッセージを送信する理由はありますか?

答えて

-1

問題は、ウェブフックが配信メッセージなどに登録されていたことです。

関連する問題