Search code examples
asp.net-web-apitelegramtelegram-bottelegram-webhook

How to create real-time push notifications from Telegram Chats to Web API?


I am new to Telegram development and am looking for a way to push real-time notifications from a current group that I am in to my own c# Web API. I was looking at the API docs, but confused about where should i start, Bot or Telegram APIs? Are there any existing projects that show such integration?


Solution

  • It can be achieved using Telegram Bot:

    1. Create a Telegram Bot by contacting @BotFather bot in telegram.
    2. Set a Web-Hook, so that any updates that @YourBot receives are transmitted by telegram via URL that you provide. It should be a secured one (HTTPS). You may also use polling. It is all described here: Telegram Bot Api - getting updates
    3. Now if you add @YourBot to your Group, it will only receive/transmit your commands (messages that start with '/'). If you want him to receive/transmit all messages you have to turn off @YourBot's privacy mode. It is also configured via @BotFather.