How to send regular(not via bot) message in telegram knowing chatId

Viewed 171

I develop a telegram bot in Java. One of the wanted function in my bot I want to see is the opportunity to invite users by other ones. I tried to make it works next way: the user sends forwarded message from the user he wants to invite to bot, program extract chat id of invited user by:

update.getMessage().getForwardFrom().getId();

and then send a message for invited user. But Telegram doesn't allow to start a conversation with a user before he tapped to "/start" button, and after user has done this, described function stops having any sense. So what I'm looking is some way to send message to user from regular(not bot) account by using, for example, json request such as we can use in bot api. Is there some way to do it?

1 Answers

Yes, there is the MTProto Protocol which allows you to build a custom Telegram application, There are several libraries that implemented it. It basically lets you program a user-bot, which gets triggered by particular commands/events and responds correspondingly.

A java library I found is telegram-s/telegram-mt but it doesn't seem to be active at all. I suggest you implement it easily in Python with libraries such as Pyrogram.

Related