I’m developing a basic Telegram bot and discovered that replying to one message creates an implicit bond between messages, which works perfectly. Now, I want to programmatically link a separate message using its message ID. The approach I encountered involves building a URL using a chat identifier and a message number, but this method breaks when the chat lacks a public identifier. How can I achieve a direct connection between messages under these conditions?
def build_message_link(chat_token, msg_number):
# Create a link if the chat has a unique token
if chat_token:
return f"tg://resolve?user={chat_token}&msg={msg_number}"
return "Direct linking is not supported for this chat."
result = build_message_link("sampleChat", 10234)
print(result)
hey, i ran into a similar prblm. i ended up storing msg id’s and using callback queries to link context. without a public chat id, there’s no magic solution. hope this points you in a useful direction.
I faced a similar limitation when experimenting with Telegram bots in private groups where there’s no public invite link. The only viable approach was to maintain a separate mapping of message IDs, which I later exploited via inline keyboard callbacks to provide context. In personal projects, this method proved reliable despite the extra effort required to store and fetch the IDs. Unfortunately, Telegram does not support direct linking in private chats, so using callback data remains the most consistent workaround available.
In my personal experiments with Telegram bots, I encountered the same limitation where direct linking based on message IDs isn’t feasible without a public chat identifier. I resolved it by implementing my own storage solution to map message IDs to their respective contexts. This method involved saving each relevant message’s ID and then referencing it later on via inline keyboards and callback queries. Although it demands extra coding and maintenance, it offers more robust control and is adaptable to various chat settings, particularly in private groups.