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 send multiple shorter messages in quick succession, in place of a single, longer message. This workflow accounts for this behavior. ### 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 to 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 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.
Use Case
When creating chatbots that interface through applications such as Telegram and WhatsApp, users can often send multiple shorter messages in quick succession, in place of a single, longer message. This workflow accounts for this behavior.
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
- When messages arrive, they are stored in a Supabase PostgreSQL table.
- The system waits briefly to see if additional messages arrive.
- 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
- Create a table in Supabase called message_queue. It needs to have the following columns: user_id (
uint8), message (text), and message_id (uint8). - Add your Telegram, Supabase, OpenAI, and PostgreSQL credentials.
- Activate the workflow and test by sending multiple messages to the Telegram bot in one go.
- 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 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.
New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.
Related bundle
Content Repurposing Engine
8 hand-picked workflows for $29.00.
That is $3.63 each, vs $14.99 for this one alone.
View bundleSecure checkout powered by Stripe
Support
How to import this workflow into n8n
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related AI workflows
- Launch Your First AI-Powered Chatbot with Actionable Tools$9.99
- Automate AI Video Creation and YouTube Upload with Google Sheets$14.99
- Build a WhatsApp Assistant with Memory, Google Suite, Multi-AI, Research, and Imaging$24.99
- Automate Blog Post Creation and Publishing with GPT, Leonardo AI, and WordPress$14.99
- Automate SEO Keyword Generation with ChatGPT from Google Sheets$3.99
- Email Agent$500.99
Need this deployed? We'll set it up for you.
Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.