Skip to content

feat(Telegram Node): Add option to delete sent message on Send and Wait response - #36919

Open
HSGamer wants to merge 4 commits into
n8n-io:masterfrom
HSGamer:feat/telegram-send-and-wait-delete-message
Open

feat(Telegram Node): Add option to delete sent message on Send and Wait response#36919
HSGamer wants to merge 4 commits into
n8n-io:masterfrom
HSGamer:feat/telegram-send-and-wait-delete-message

Conversation

@HSGamer

@HSGamer HSGamer commented Aug 24, 2026

Copy link
Copy Markdown

Summary

When using Send and Wait for Response on Telegram, the bot's message tends to stick around long after it has served its purpose — once somebody has responded, you're left with stale buttons or a dead form link sitting in the chat.

This PR adds an Options → Delete Message on Response toggle to the operation. When enabled, the bot deletes its own message as soon as the user responds, regardless of how they did it:

  • tapping an in-chat approval button
  • clicking the approval link in a browser
  • submitting a Free Text or Custom Form response

Implementation-wise, the message identity (chat + message ID) is captured from the sendMessage response and stored in execution metadata (customData), which is persisted while the execution waits and is available again when the webhook resumes the execution. That means no extra Telegram API calls at send time and no IDs embedded in signed URLs.

Deletion is deliberately best-effort — if the deleteMessage call fails, the execution still resumes normally. Old executions that were already waiting before this change simply skip deletion (no stored metadata).

How to test

  1. Create a workflow with Telegram → Message → Send and Wait for Response.
  2. Under Options, enable Delete Message on Response.
  3. Execute the workflow and respond in Telegram (button tap, link, or form submission).
  4. The bot's message should disappear from the chat right away, and the execution output should be identical to a run with the option off.

You'll need a real Telegram bot credential and an instance reachable over public HTTPS for the resume webhook.

Related Linear tickets, Github issues, and Community forum posts

Both posts describe the same problem this solves: after someone responds to a Send and Wait message, the stale approval buttons/form stay in the chat forever, and users want the bot to clean up its own message.

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.

Review in cubic

@n8n-assistant

n8n-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

CLA Check passed. All contributors on this PR have signed the n8n CLA — thank you!

@HSGamer

HSGamer commented Aug 24, 2026

Copy link
Copy Markdown
Author

/cla-check

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Architecture diagram
sequenceDiagram
    participant Telegram as Telegram API
    participant Node as Telegram Node (Execute)
    participant Storage as Execution Metadata (customData)
    participant Webhook as Telegram Webhook Handler
    participant User as User (Chat/Browser)

    Note over Node,Telegram: Phase 1: Sending Message & Setup
    Node->>Telegram: POST /sendMessage
    Telegram-->>Node: 200 OK (message_id, numeric chat_id)
    
    opt NEW: Option "Delete Message on Response" enabled
        Node->>Node: Extract message identity
        Node->>Storage: NEW: set("tgDeleteTarget", {chatId, messageId})
    end
    Note over Node: Workflow enters Wait state

    Note over User,Webhook: Phase 2: User Response & Cleanup
    User->>Webhook: Interaction (Button tap / Link / Form POST)
    
    Webhook->>Storage: NEW: get("tgDeleteTarget")
    Storage-->>Webhook: stored identity (if exists)

    alt NEW: Option enabled AND valid metadata exists
        alt Response is Custom Form or Free Text
            opt Method is GET (Form Rendering)
                Note right of Webhook: Skip deletion to keep form link active
            end
        end
        
        opt Method is POST or Callback (Response Completion)
            Webhook->>Telegram: NEW: POST /deleteMessage (Best-effort)
            Telegram-->>Webhook: Result (ignored by node)
        end
    else Option disabled OR no metadata
        Webhook->>Telegram: CHANGED: POST /editMessageText (Standard behavior)
    end

    Webhook-->>User: Response UI / Redirect
    Note over Webhook: Execution resumes in workflow
Loading

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/nodes-base/nodes/Telegram/hitl/webhook.ts
Comment thread packages/nodes-base/nodes/Telegram/Telegram.node.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/nodes-base/nodes/Telegram/tests/node/sendAndWait.operation.test.ts Outdated
@n8n-assistant n8n-assistant Bot added community Authored by a community member node/improvement New feature or request triage:pending Waiting to be triaged labels Aug 24, 2026
@n8n-assistant

n8n-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Hey @HSGamer,

Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request.

Before we can proceed, please ensure the following: • Your PR references the GitHub issue it fixes (or, for feature requests, a link to the corresponding community forum post). • Tests are included for any new functionality, logic changes or bug fixes. • The PR aligns with our contribution guidelines.

Why the linked issue matters: Our teams pick up work from the issue, not from individual pull requests — the issue is what reaches them, with your PR linked to it. So please make sure the issue contains everything needed to judge the change: a clear problem description, reproduction steps, and the expected behaviour. If the issue is thin, add the missing context there rather than only in the PR description.

Regarding new nodes: We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently.

If your node integrates with an AI service that you own or represent, please email nodes@n8n.io and we will be happy to discuss the best approach.

About review timelines: While we plan to review it as soon as possible, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins.

Please also note that other contributors may have opened pull requests for the same issue. We keep them all open so the reviewing team can choose the approach that fits best. Once the issue is resolved, the remaining pull requests are closed — this is not a judgement on the quality of your work, and we're grateful for it either way.

Thank you again for contributing to n8n.

1 similar comment
@n8n-assistant

n8n-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Hey @HSGamer,

Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request.

Before we can proceed, please ensure the following: • Your PR references the GitHub issue it fixes (or, for feature requests, a link to the corresponding community forum post). • Tests are included for any new functionality, logic changes or bug fixes. • The PR aligns with our contribution guidelines.

Why the linked issue matters: Our teams pick up work from the issue, not from individual pull requests — the issue is what reaches them, with your PR linked to it. So please make sure the issue contains everything needed to judge the change: a clear problem description, reproduction steps, and the expected behaviour. If the issue is thin, add the missing context there rather than only in the PR description.

Regarding new nodes: We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently.

If your node integrates with an AI service that you own or represent, please email nodes@n8n.io and we will be happy to discuss the best approach.

About review timelines: While we plan to review it as soon as possible, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins.

Please also note that other contributors may have opened pull requests for the same issue. We keep them all open so the reviewing team can choose the approach that fits best. Once the issue is resolved, the remaining pull requests are closed — this is not a judgement on the quality of your work, and we're grateful for it either way.

Thank you again for contributing to n8n.

@n8n-assistant n8n-assistant Bot added triage:in-progress Triage is in progress feature Large self-contained feature and removed triage:pending Waiting to be triaged labels Aug 24, 2026
@n8n-assistant

n8n-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This feature request doesn't appear to be linked to a forum post. We require that community PRs that add features are linked to a forum post to help us understand the context behind the change and spot duplicate solutions.

If no post exists yet, please open one describing the problem you're trying to solve.

This looks like a feature rather than a bug fix, and we track feature requests on our community forum rather than in GitHub issues. That's where the discussion and the votes live, and it's what we use to gauge how many people need something before it goes into the product.

Could you link a forum post for this change in the PR description? Either:

  • A post already exists — add the link, e.g. Related: https://community.n8n.io/t/...
  • No post yetopen one describing the problem you're solving and what you'd like n8n to do, then link it here.

To be upfront: linking a post doesn't guarantee this gets merged. A feature with little demand behind it may still be declined, and we'd rather tell you that before you spend more time on it. But without a post there's no context for the reviewing team to weigh it against, so we can't move it forward at all.

Once the description links a forum post, this PR will automatically return to triage.

@n8n-assistant n8n-assistant Bot added triage:needs-info triage:pending Waiting to be triaged triage:in-progress Triage is in progress triage:complete Triage has been completed and issue is ready for internal teams triage:ready-for-review and removed triage:in-progress Triage is in progress triage:needs-info triage:pending Waiting to be triaged labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed community Authored by a community member feature Large self-contained feature node/improvement New feature or request triage:complete Triage has been completed and issue is ready for internal teams triage:ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant