Skip to main content

Debounce Telegram support messages and aggregate replies with OpenAI

Workflow preview

Workflow preview
100%
Debounce Telegram support messages and aggregate replies with OpenAI preview
Open on n8n.io

1. Workflow Overview

This workflow prevents your AI support bot from responding to every single message by intelligently aggregating rapid fire messages from users before generating a comprehensive response. Who's it f...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.set, n8n-nodes-base.postgres, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.respondtowebhook, @n8n/n8n-nodes-langchain.lmchatopenai, n8n-nodes-base.telegramtrigger, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Naveen Choudhary.

Original n8n.io source

1.1 Workflow description

Title
Debounce Telegram support messages and aggregate replies with OpenAI
Workflow name
Debounce Telegram support messages and aggregate replies with OpenAI

This workflow prevents your AI support bot from responding to every single message by intelligently aggregating rapid-fire messages from users before generating a comprehensive response.

Who's it for

Support teams and bot developers who want to provide better AI responses by letting users fully explain their issue before the bot responds, reducing unnecessary back-and-forth and improving response quality.

How it works

When a user sends a message to your Telegram bot, the workflow:

  • Checks if the user has an active session within the last 60 seconds
  • If no session exists, creates a new one and starts a 60-second timer
  • If a session is active, appends the new message to the existing conversation
  • After 60 seconds of the first message, fetches all aggregated messages
  • Sends the complete conversation to OpenAI for a comprehensive response
  • Delivers the AI-generated answer back to the user via Telegram
  • Clears the session for the next interaction

Requirements

  • Telegram bot token (set up via BotFather)
  • OpenAI API key
  • PostgreSQL database with a user_sessions table containing columns: user_id, session_id, messages (jsonb array), first_message_at, wait_expires_at, status, and resume_url
  • n8n instance (self-hosted or cloud)

How to set up

  1. Configure your Telegram credentials in the Telegram Trigger node
  2. Add your OpenAI API key to the OpenAI Chat Model node
  3. Set up PostgreSQL credentials and create the required database table
  4. Adjust the wait time (default 60 seconds) in the Wait node if needed
  5. Activate the workflow and test with your Telegram bot

How to customize

  • Modify the aggregation window by changing the wait duration
  • Customize the AI prompt in the AI Agent node for different response styles
  • Add additional logic to handle specific keywords or commands
  • Integrate other AI models or add context from external sources

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Incoming Message Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 2 - Extract User Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Check Active Session

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 4 - Create New Session

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 5 - Append Message

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 6 - Fetch All Messages

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 7 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 8 - Clear Session

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 9 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 10 - Store Resume URL

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 11 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 12 - Telegram Trigger

Type / Role
n8n-nodes-base.telegramTrigger - telegramTrigger
Config choices
Version 1.2

Block 13 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 14 - Send a text message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 15 - Format All Messages

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Wait 60s (New Session)

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 17 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Debounce Telegram support messages and aggregate replies with OpenAI
Complexity advanced
Nodes 24
Categories Support Chatbot, AI Chatbot
Author Naveen Choudhary
Published 28 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13070/13070.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Debounce Telegram support messages and aggregate replies with OpenAI do?

This workflow prevents your AI support bot from responding to every single message by intelligently aggregating rapid fire messages from users before generating a comprehensive response. Who's it f...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.