Featured image of post Make a Telegram Web Apps for Bots

Make a Telegram Web Apps for Bots

This is a Telegram Web Apps example, I use Cloudflare workers as my web server and bot server. This example can open a web app and return user input to bot, and bot can show user input on Telegram chat.

Demo

Please click article button on bottom left of the https://t.me/blog_toolman_xyz_bot

Steps

  1. Create two new Cloudflare workers and paste below code https://gist.github.com/toolmanxyz/bab44386e61f9bc03966ac6d2943615e
  2. Create a new Telegram Bot in https://t.me/BotFather
  3. Edit Telegram Bot’s menu button in BotFather : /mybots > <MyBot> > Bot Settings > Menu Button > Edit Menu button URL > <Your cloudflare workers front end url (ex:https://front-end.example.workers.dev)>
  4. Open https://api.telegram.org/bot<Telegram Bot token>/setWebhook?url=<Cloudflare workers back-end url (ex:https://back-end.example.workers.dev)> in broswer

Refer