Is it possible to create a bot who manage more than one conversation with one user?
I need to create a bot able to make the link between a random chat and telegram.
For example, if I don’t wont to use Facebook Messenger anymore, creating a bot who send me every new Facebook message from my account to my Telegram number. The bot would create a new conversation for each unique Facebook user sending me message. Or, if it’s not possible, a bot who create a new temporary bot for each new user conversation and give me his @name.
Is it possible with the Telegram Bot API?
3
Answers
What you want is possible, as you know every single telegram user has a unique chatID in telegram so if your friends or users text to your bot directly you can use a code like below to answer their messages from your own telegram account and make the bot send it to the related user:
But if your users send the messages from Facebook to you and you want the bot to send them to your telegram account and answer them again through the bot using Facebook API or something else, all that must change is:
Instead of sender’s Chat ID you must save his/her Facebook username and reply it with the FB username instead of telegram Chat ID.
Also you can use telegram’s reply feature and check if the reply is null and find the Chat ID(or FB account or …) of the sender of the message your trying to reply and send the reply directly to that user.
According to the latest telegram bot api you can make more than one bot, but one thing that is crucial is the bot’s API token that is made manually through botFather. You can make a single bot and make other bots inherit its features and every time a new user sends you a message assign a bot to him/her. Up to here, it’s possible but for API token all you can do is to make as much bots as your Facebook friends count and store their api tokens in a DB and pass one of the api tokens to the bot that stands for a user.
This is what I think can solve your problem but the api token part is a bit strange 😀 although you can send a notification from the main bot to your own account when the number of unsigned api tokens get less than 5.
As you know the number of Facebook friends can change and any of them at any time can text you so there must be enough tokens because every time one of them texts you for the first time a bot must be created with a pre-made api token and inherit the features from the main bot. From that moment that token and that bot stand for the person who tried to message you.
That is achievable using the method that is used in this project.
[https://github.com/idoco/intergram%5D%5B1%5D
Essentially, you create a random userid for each user. In order to reply to that specific user, you have to use the reply to message method in your telegram client. Ie… right click on the message to reply to it.