How to test telegram bot webhook on local machine?

Danil Pyatnitsev picture Danil Pyatnitsev · Apr 20, 2016 · Viewed 12.5k times · Source

I developing a Telegram bot and I want to use Webhooks instead of polling to get messages from Telegram server.
I'm developing and testing the app on localhost which is not a reachable web host, so I can't set it as Webhook URL.

Now I was wondering how I could get real messages from Telegram on my local machine though Webhooks?

Answer

Forgotmyusernameandpassword picture Forgotmyusernameandpassword · Apr 20, 2016

You could use ngrok if you just needed a quick public URL to your webapp without a bunch of hassle.

So you'd just run something like ngrok.exe http 192.168.10.10:80 -host-header=test.app it'll return a custom domain

Forwarding http://449ee26d.ngrok.io -> 192.168.10.10:80

And you just point Telegram's webhook to http://449ee26d.ngrok.io/your-endpoint

ngrok