Bot-to-bot communication allows bots to receive messages from other bots in the contexts described below. Outside of these contexts, bots normally do not receive messages from other bots.
Enable Bot-to-Bot Communication Mode for every bot that should participate in this feature in @BotFather ».
For a simplified Bot API description, see Bot-to-Bot Communication ».
updateNewMessage#1f2b0afd message:Message pts:int pts_count:int = Update;
updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update;
Bots in the same group or supergroup » may communicate through ordinary group messages.
A bot receives a message from another bot if the message:
/command@TargetBot.At least one of the two bots must have Bot-to-Bot Communication Mode enabled.
A bot with Bot-to-Bot Communication Mode enabled can also receive messages from other bots in groups without a command mention or direct reply, if the receiving bot:
Group Privacy Mode is the bot privacy setting » that limits ordinary group updates to messages explicitly relevant to the bot.
Incoming bot messages are delivered through the usual update handling flow »: updateNewMessage in basic groups, and updateNewChannelMessage in supergroups.
---functions---
messages.sendMessage#545cd15a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates;
A bot can send a private message to another bot using messages.sendMessage and other message sending methods, passing the recipient bot in peer.
Bot-to-Bot Communication Mode must be enabled for both the sender bot and the recipient bot. If either bot has not enabled the setting, the methods will return USER_BOT_TO_BOT_DISABLED.
The USER_BOT_TO_BOT_DISABLED RPC error only applies to Communication in Private Chats.
botBusinessConnection#8f34b2f5 flags:# disabled:flags.1?true connection_id:string user_id:long dc_id:int date:int rights:flags.2?BusinessBotRights = BotBusinessConnection;
updateBotNewBusinessMessage#9ddb347c flags:# connection_id:string message:Message reply_to_message:flags.0?Message qts:int = Update;
---functions---
invokeWithBusinessConnection#dd289f8e {X:Type} connection_id:string query:!X = X;
messages.sendMessage#545cd15a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int schedule_repeat_period:flags.24?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates;
Chat Access Mode lets a bot receive and send messages through chats available to a connection_id, as described in the connected bot » flow. In this mode, the bot can send messages to other bots in those chats.
Only the sending bot needs to enable Bot-to-Bot Communication Mode.
Obtain the connection_id from botBusinessConnection, then invoke messages.sendMessage through invokeWithBusinessConnection. The available operations still depend on the businessBotRights granted for that connection.
Messages received through the connection are delivered as updateBotNewBusinessMessage updates, using the qts update sequence ».
Bot-to-bot communication can create infinite reply loops. Bots using this feature must make bot-message handling terminate predictably.
Recommended safeguards:
The bot must remain stable if another bot replies immediately and repeatedly.