soroush-app / bot-php-sdk

Soroush Messenger Bot Wrapper for PHP
MIT License
18 stars 8 forks source link

how to use the API as a replacement for `webhook`? #5

Closed azerafati closed 5 years ago

azerafati commented 5 years ago

Looking at the examples the only way I can see to access the new messages is through a call to : $messages = $bot->getMessages(); I don't get how I'm supposed to answer the new messages sent by users? The only possible solution is through a repeated call (every 10 seconds at least) to the API and calling the $bot->getMessages(); over and over again? That's going to waste a lot of resources both on bot's server and the API. What is the recommendation here?

amir-gholami commented 5 years ago

In the current architecture of Soroush bots, the SSE protocol is used to receive messages in hopes of providing WebHook capabilities in the near future. Use the methods provided to send messages to users for examples of which you can visit this page.