Skip to main content

Allow users to send a sequence of messages to an AI agent in Telegram

Workflow preview

Workflow preview
100%
Allow users to send a sequence of messages to an AI agent in Telegram preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Use Case When creating chatbots that interface through applications such as Telegram and WhatsApp , users can often sends multiple shorter messages in quick succession, in place of a single, longer...

Best for

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

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.telegram, n8n-nodes-base.telegramtrigger, n8n-nodes-base.wait, n8n-nodes-base.supabase, n8n-nodes-base.noop, n8n-nodes-base.aggregate, @n8n/n8n-nodes-langchain.lmchatopenai

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Allow users to send a sequence of messages to an AI agent in Telegram
Workflow name
Allow users to send a sequence of messages to an AI agent in Telegram

Use Case

When creating chatbots that interface through applications such as Telegram and WhatsApp, users can often sends multiple shorter messages in quick succession, in place of a single, longer message. This workflow accounts for this behaviour.

What it Does

This workflow allows users to send several messages in quick succession, treating them as one coherent conversation instead of separate messages requiring individual responses.

How it Works

  1. When messages arrive, they are stored in a Supabase PostgreSQL table
  2. The system waits briefly to see if additional messages arrive
  3. If no new messages arrive within the waiting period, all queued messages are:
    • Combined and processed as a single conversation
    • Responded to with one unified reply
    • Deleted from the queue

Setup

  1. Create a table in Supabase called message_queue. It needs to have the following columns: user_id (uint8), message (text), and message_id (uint8)
  2. Add your Telegram, Supabase, OpenAI, and PostgreSQL credentials
  3. Activate the workflow and test by sending multiple messages the Telegram bot in one go
  4. Wait ten seconds after which you will receive a single reply to all of your messages

How to Modify it to Your Needs

  • Change the value of Wait Amount in the Wait 10 Seconds node in order to to modify the buffering window
  • Add a System Message to the AI Agent to tailor it to your specific use case
  • Replace the OpenAI sub-node to use a different language model

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 - Sticky Note

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

Block 2 - Sticky Note1

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

Block 3 - Reply

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

Block 4 - Receive Message

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

Block 5 - Wait 10 Seconds

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

Block 6 - Sticky Note3

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

Block 7 - Add to Queued Messages

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

Block 8 - No Operation, do nothing

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

Block 9 - Aggregate

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

Block 10 - Delete Queued Messages

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

Block 11 - Sticky Note2

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

Block 12 - OpenAI Chat Model

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

Block 13 - Sort by Message ID

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

Block 14 - Get Queued Messages

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

Block 15 - Check Most Recent Message

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

Block 16 - AI Agent

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

Block 17 - Postgres Chat Memory

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

Block 18 - Sticky Note4

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

Block 19 - Sticky Note5

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

Block 20 - Sticky Note6

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

Block 21 - Sticky Note8

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

Block 22 - Sticky Note9

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

3. Summary Table

Workflow Allow users to send a sequence of messages to an AI agent in Telegram
Complexity advanced
Nodes 22
Categories Support Chatbot, AI Chatbot
Author Chris Carr
Published 16 Feb 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2917/2917.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 Allow users to send a sequence of messages to an AI agent in Telegram do?

Use Case When creating chatbots that interface through applications such as Telegram and WhatsApp , users can often sends multiple shorter messages in quick succession, in place of a single, longer...

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.