Telegram bot using

Posted:   |  More posts about lua telegram webscript

Telegram recently released their official Bot API. It make writing bot so easy compared to building your own client using the client API.

The only requirement for your bot is that an HTTPS endpoint that you can tell TG where to forward the incoming message from user. Being an HTTPS endpoint, it mean you need to have a valid SSL cert for your domain (if you haven't got one yet).

Another option is to use free hosting that provide you with HTTPS endpoint. There are a number of them. Among others:-

  • Heroku - Provide HTTPS endpoint for
  • Openshift -
  • Google App Engine -

To test directly from your laptop, use service such as

But in this post I want to mention another alternative that is using script as endpoint for TG bot. After signing up to the service, just create new Lua script like below:-

Then you need to create your bot using BotFather through your Telegram app. Once you get the auth token, replace tg_token variable in the script above with your auth token. Before the script can start accepting messages from Telegram, you need to tell TG using the setWebhook API method. So you have to make a request to the webscript endpoint yourself like:-

curl ''

If there's no error, all set now. You can also check the logging that provide to check for any error.

The only downside of is that it's not free. The script created under the free account will only last for 7 days. With the same amount of money, you can get a small VPS from Digital Ocean to run the bot + some other stuff as well. But if you're not interested in maintaining another server then this is a great service. This can also be your great excuse to learn Lua ;)

Comments powered by Disqus

About me

Web developer in Malaysia. Currently work at MARIMORE Inc building internet services using Python and Django web framework.

ImportError is an error message emitted by Python when it failed to load certain module as requested by programmer. It's a very common error when someone new to the language trying it out. This website on the same theme, will try provide help for newcomers on any technologies to overcome their first hurdle.

Try most of the examples you may find here on Digital Ocean cloud service. They provide excellent VPS at a very cheaper price. Using this referral link you'll get USD10 credits upon sign up. That's enough to run single VPS with 1GB RAM for a month.


I can also be found at the following sites:-



The postings on this site are my own and don't necessarily represent my employer's positions, strategies or opinions.