How to use ngrok to test telegram api locally?

The easiest way to test the telegram api integration is through the webhook return. But developing locally, we have no way of testing this return, unless we had a valid IP, or deploying the application and testing remotely, right?

It would be, if there was no ngrok

The easiest way to install it is via snap (for more options visit the website)

 snap install ngrok

With ngrok installed, type the command (substitute the 80 if it’s not your default web port)

ngrok http 80

If everything goes well, the screen above should open in your terminal. Notice the forwarding line, this is the address you should point the telegram webhook to, as it refers to your root.

If your local server endpoint is http://localhost/telegram/webhook, you must register on your telegram endpoint.

Registering the telegram webhook

To create 1 bot, just talk to @botfather and follow the instructions. Once this is done, go to the browser and paste the url you token here but without the less and greather sign but leave the bot string%3E/setWebhook?url=

Notice: ob_end_flush(): failed to send buffer of zlib output compression (0) in /home/samu/public_html/blog/wp-includes/functions.php on line 5277