AI Agents

Telegram chat with buffering

22 nodes 216 134 Automatic trigger
Download

Workflow Description

A Telegram chatbot automation template with intelligent buffering. It receives messages through Telegram, queues and sorts them, processes them via an AI agent powered by OpenAI, retrieves conversation context from Postgres, and sends intelligent responses back to users.

How it works

  1. 1.Receive incoming message from Telegram trigger
  2. 2.Queue and sort messages by priority using Sort node
  3. 3.Process message through AI Agent with OpenAI model
  4. 4.Retrieve conversation history from Postgres memory
  5. 5.Send response back to user via Telegram

Use cases

  • Build an intelligent chatbot that maintains full conversation context across sessions
  • Handle high-volume concurrent message processing while preserving message order
  • Manage long-running conversations with persistent memory of previous interactions

Requirements

  • Configure OpenAI API key and enable AI Agent permissions
  • Set up Postgres database with conversation context storage tables
  • Connect Telegram bot with valid Bot API token

Service Value

Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.

Apps Used

Telegram Supabase OpenAI Sort AI Agent Postgres

Details

Trigger Automatic trigger
Nodes 22
Apps 6
Views 216
Downloads 134

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (22)

/

Sticky Note

Sticky Note

#1

Sticky Note1

Sticky Note

#2

Reply

Set

#3

Receive Message

Set

#4

Wait 10 Seconds

Wait

#5

Sticky Note3

Sticky Note

#6

Add to Queued Messages

Supabase

#7

No Operation, do nothing

No Op

#8

Aggregate

Aggregate

#9

Delete Queued Messages

Supabase

#10

Sticky Note2

Sticky Note

#11

OpenAI Chat Model

OpenAI

#12

Sort by Message ID

Sort

#13

Get Queued Messages

Supabase

#14

Check Most Recent Message

If

#15

AI Agent

Agent

#16

Postgres Chat Memory

Memory Postgres Chat

#17

Sticky Note4

Sticky Note

#18

Sticky Note5

Sticky Note

#19

Sticky Note6

Sticky Note

#20

Sticky Note8

Sticky Note

#21

Sticky Note9

Sticky Note

#22