简体   繁体   中英

Webhook with Laravel - receiving hits of repeated messages

I'm using Laravel 5.3 as webhook to test Facebook's and Telegram's ChatBot's API separately . The problem is that when I send a message to my bot (in both platforms) my server receives lots of hits, which already received messages from the user (checked the unique message ID's, they are really repeated). Because of that, if I want to answer every message that I receive from their APIs, I'll flood the chat. Is that normal? Should I check if a user sent a message myself?

Facebook's API works normally when I select an item from persistent menu.

In the Telegram docs they have mentioned:

In case of an unsuccessful request, we will give up after a reasonable amount of attempts.

So maybe you don't return OK to receiving updates and telegram thought your server has some internal errors. Then It sends updates again.

Also in case of duplicate receiving updates you can use the update_id . Take a look at the Telegram docs :

The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM