Get chat_id from bot to bot conversation - telegram-bot

So What Im trying to accomplish is a bot that forwards messages from one specific user to one specific group chat. I started my testing by using my own chat_id and the bot perfectly forwards my messages to the right groupchat.
The problem is tho, that I want to forward messages that I receive from a bot. So I am trying to gather the chat_id between this bot and my bot but I can't get my head around how I should send and/or receive a message from this bot to gather said chat_id because I cant use it's #username in a /sendMessage? URL.

Why doesn't my bot see messages from other bots? Bots talking to each
other could potentially get stuck in unwelcome loops. To avoid this,
we decided that bots will not be able to see messages from other bots
regardless of mode.
Telegram Bots FAQ

Related

Telegram Bots: Can I now start a chat or not?

https://core.telegram.org/bots clearly says:
Bots can't initiate conversations with users. A user must either add them to a group or send them a message first.
But if I visit https://telegram.org/blog/login it says
Telegram bots are a powerful communication tool, but until today they couldn't start a conversation. Even if you wanted them to reach out to you, you had to chat them up first.
With the new login widget, moving from interacting with a website to a conversation on Telegram becomes completely frictionless.
So it is somehow possible to start a conversation via the login widget. But how do I do it?
I get a user id. Is there an api endpoint to initiate a chat with the user?
The only way to begin conversing with a Telegram bot is to start the conversation with them yourself. There's no way for the bot to start a conversation with a user themselves.
As you said, telegram clearly says there is no way for bot to start a conversation, the only thing bots can do is sending messages to an old conversation (I mean a user have to start the conversation).

Telegram group read messages from another bot

I have 2 bots in 1 Group (bot A and bot B).
When a user sends a message to the group, both bots can see it.
But if any of the bots A or B send a message to the group, none of the bots can read the other bot message.
Is it possible that bot can read other bots messages? or messages sent by himself?
The "getUpdates" function returns only mesages from users, not bots, is there a way how to receive group messages sent by bots?
Thanks
You can not. This is a limitation set by Telegram itself.
It is stated clearly in the official Bot documentation under FAQ Section.
Why doesn't my bot see messages from other bots?
Bots talking to each other could potentially get stuck in unwelcome loops. To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.

Telegram bot receiving commands from other bot

in the documentation of the telegram bot API I found:
Bots with privacy mode enabled will receive:
Commands explicitly meant for them (e.g., /command#this_bot).
General commands from users (e.g. /start) if the bot was the last bot
to send a message to the group.
So I created two bots - invited both in a group and had "firstbot" to fire /cmd#otherbot something commands. The "otherbot" echos everything it reads.
I (in the client) I can write - "otherbot" doesn't see it - which is correct due to privacy settings.
I i write /cmd#otherbot - "otherbot" receives and echos this - also correct.
BUT - when I let "firstbot" emit /cmd#otherbot in the group "otherbot" doesn't see it.
Am I doing something wrong - or am I miss-leaded by the documentation?
I use C# with Telegram.Bot by roundrobin.
Bots can't see messages meant for other bots, regardless of privacy modes.
Why doesn't my bot see messages from other bots?
Bots talking to each other could potentially get stuck in unwelcome loops. To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.
Recently I came across with this problem, that one bot can't read messages from another bot.
But I've found a solution: instead of using the Telegram Bot API, you can use TDLib (Telegram Database library) to read the messages.
I am using python, so with this short piece of code I am able to read messages from a bot:
from telegram.client import Telegram
tg = Telegram(
api_id=123456,
api_hash='api_hash',
phone='+555555555',
database_encryption_key='changehere' )
tg.login()
def new_message_handler(update):
message_content = update['message']['content']
message_text = message_content.get('text', {}).get('text', '').lower()
print(message_text)
# do what you want with the message
tg.add_message_handler(new_message_handler)
tg.idle()
I guess that the same can be extended for other languages.
With this approach combined with Bot Telegram API, you are able to:
read messages from a bot (with Telegram Database library)
send that message with another bot (with Telegram Bot API)

Telegram Bot messages

Is it possible that bots send messages in chats only to specific members, and the messages aren't visible for other members of the chat?
For example:
There is a chat with 200 members and the bot is one of them. Somebody sends a command /help and bot responds only to him and others don't see the response
You can't do this at this time, but there are deleteMessage method you might interested.
And there are inline keyboard can ask users to START your bot, just put https://t.me/Bot as URL value.

How can I send message to specific chatID?

I have chatId and want send messages while execute some tasks from java code. I found this explain on telegram "Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot." But my task works good when I use https request directly from browser. My bot perfectly answer for requests but how I can do this without user request?
I can not truly understand your case!
Anyway, your bot can send a message to a chat ID Only if the user witch blongs to the specified chat ID added your bot (send start to a bot).
and if it happened then send your message with
/sendMessage