In the bot menu, I have an online chat option with me. If a user clicks this button, bot saves this users state as chatMode
. The scenario is like if the user's state is chatMode
each of his messages should be forwarded to me, and when I reply to this message, my answer should be sent to this user - all of these communications should be vie my bot. This scenario is just like the service bot @LivegramBot. Can you provide a detailed answer for how to achieve this result?
Also, is there any way to group these users because if there are more users, my conversations will be all mixed on my side of the bot?
This is what I am trying:
if (user.state === 'chatMode') {
bot.forwardMessage(xx4775xxx, msg.from.id, msg.message_id);
} else if (user.telegramId === xx4775xxx) {
if (msg.reply_to_message) {
bot.sendMessage(msg.reply_to_message.chat.id, msg.text)
}
}
But here if (msg.reply_to_message)
part is sending to myself again.