Telegram: edited messages go through processMessage, so they are dropped or answered twice instead of reaching onMessageUpdated
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in packages/adapter-telegram/src/index.ts at collectUpdateTasks and handleIncomingMessageUpdate, then compare how the Slack and Teams adapters call processMessageUpdated. Route the three Telegram edit update types through that path and check the adapter tests for edit handling. Done means edits invoke onMessageUpdated without starting typing or being treated as new messages; the issue says a PR with tests and doc updates is already ready.
Written by the indexing model from the issue text.
Description
Hope you're doing well! On Telegram, an edited message is handled like a brand new message with the original message ID, so the Chat dedupe drops it within 10 minutes and answers it as a new message after that, and onMessageUpdated never fires.
What this code is for
collectUpdateTasks in packages/adapter-telegram/src/index.ts reads each Telegram update and decides where it goes: new messages to chat.processMessage, slash commands to chat.processSlashCommand, and business chats through handleBusinessMessageUpdate. Since #788, edits have their own path in core, chat.processMessageUpdated, which calls the onMessageUpdated handlers.
Current behaviour
A user in a group sends "can someone look at this", then edits it to "can someone look at this @mybot".
- Telegram sends an
edited_messageupdate with the samemessage_idand the new text. collectUpdateTaskspicks it up in the same expression as new messages (update.message ?? update.edited_message ?? update.channel_post ?? update.edited_channel_post) and passes it tohandleIncomingMessageUpdate(L1021-L1027).handleIncomingMessageUpdatestarts typing in private chats and callschat.processMessage(L1229-L1262).- The message ID is
encodeMessageId(chat.id, message_id)(L2888), the same ID the original message had. - Core checks
dedupe:telegram:${id}, which the original message set for 10 minutes (chat.ts L134, L2613-L2629), and skips the edit as a duplicate. - The bot never sees the mention, and
onMessageUpdatedis never called.
edited_business_message goes the same way. It sets isEdit, but that only skips slash commands, and the edit still starts typing and reaches chat.processMessage (L1077-L1081, L1212-L1226).

collectUpdateTasks hands edits to handleIncomingMessageUpdate, which starts typing and parses them as new messages, Functions view in Architect
Expected behaviour
edited_message, edited_channel_post, and edited_business_message go to chat.processMessageUpdated, the way Slack's message_changed and Teams' editMessage do. Telegram only sends the new version, so previousMessage would be undefined. An edit wouldn't start typing or run a slash command.
Minimal repro
I ran this on main (990411e) with a real Chat, createMemoryState(), and createTelegramAdapter, posting updates to bot.webhooks.telegram:
- A group message "hello all", then an
edited_messagefor the samemessage_idthat adds@mybotwith amentionentity: no handler runs. - A private message "hi", then an
edited_message"hi there" within 10 minutes:onDirectMessageruns once for "hi", and the edit is dropped. - The same private edit sent after the dedupe entry expires:
onDirectMessageruns again, so the bot answers a second time. - In both edit cases a
sendChatActiontyping call goes out, andonMessageUpdatednever fires.
flowchart LR
classDef box fill:#eef1ff,stroke:#4c5bd4,color:#111827
classDef bad fill:#ffd6d6,stroke:#cc0000,color:#111827,stroke-width:3px
U["edited_message or edited_channel_post"] --> C["collectUpdateTasks"]
BZ["edited_business_message"] --> BH["handleBusinessMessageUpdate"]
C --> H["handleIncomingMessageUpdate"]
H --> T["startTypingForPrivateMessage"]
BH --> T
H --> P["chat.processMessage"]
BH --> P
P --> D{"dedupe key already set?"}
D -->|"within 10 minutes"| X["edit dropped"]
D -->|"after 10 minutes"| Y["handled as a new message"]
class U,BZ,C,BH,H,T,P box
class D,X,Y bad
Prior work
#788 added processMessageUpdated and mentioned that other adapters could opt in later, #1120 did that for Teams, and #887 asked for business edits to use the message updated path. Thanks to everyone who worked on those, they made this one really easy to follow. apps/docs/content/docs/handling-events.mdx (L329) still says only Slack emits these events, which is out of date since #1120.
A couple of questions
- Would you like
edited_business_messageincluded in the same change, as #887 suggested? I assumed yes. - Is it OK to skip the typing indicator for edits? It felt right since nothing is being replied to yet, but happy to keep it if you'd prefer.
I have a PR ready that routes all three edit kinds this way, with tests and doc updates, and I'm glad to change anything. Any feedback or tips are very welcome!
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 355
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 42
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel/chat
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
X and Twitch: paragraphs inside a block quote are joined with no spacePossibly taken @abhiramshaji-cyber claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day
-
🛠️ dette technique
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
betagouv/mon-entreprise#4752 · 1 comment ·
Maintainers usually reply within 5 days
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainers usually reply within 2 days
-
area/providers type/feature version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/opencode#64845 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day