04

Multi-Agent Conversation System

A Telegram-triggered AI workflow that manages conversation state, iterates through agent behaviour, maintains memory, and sends coordinated responses using Gemini and n8n. Orchestration, memory and model behaviour are separated instead of being pushed through one assistant step.

Class
AI Agents
Built with
n8n · Telegram · Google Gemini · AI Agents · Simple Memory
Walkthrough
Loom recording

The work

Complex assistant conversations need more than sending one prompt to one model. Context has to be retained, agent behaviour needs structure, and responses have to stay coherent across turns.

The friction

Without orchestration, a single assistant prompt ends up responsible for user context, agent behaviour, memory, iterative responses, message formatting and conversation continuity all at once.

n8n workflow canvas for the Multi-Agent Conversation System, showing a Telegram trigger, global and agent settings, mention extraction, a loop over items with a first-loop check that switches the input between the user message and the last assistant message, an AI Agent node using a Google Gemini chat model and simple memory, and response combination before Telegram delivery.
The full n8n canvas. The loop and the first-loop check are what keep the conversation coherent across turns.1811 × 817 · 168 KB

The system

The loop is the core of it. On the first pass the user message is the input; on later passes the last assistant message is.

  1. Telegram Trigger
  2. Define Global Settings
  3. Define Agent Settings
  4. Extract Mentions
  5. Loop Over Items
  6. First Loop?

    Input switches by pass

    • First loop: set the user message as input
    • Later loops: set the last assistant message as input
  7. AI Agent

    The agent uses

    • Google Gemini Chat Model
    • Simple Memory
  8. Set lastAssistantMessage
  9. Continue loop
  10. Combine and Format Responses
  11. Send Response to Telegram

What it handles

  • Telegram message intake
  • Global configuration
  • Agent configuration
  • Mention extraction
  • Loop orchestration
  • Input switching between user and assistant messages
  • Gemini inference
  • Conversation memory
  • Response aggregation
  • Telegram delivery

What stays human

Every setting that decides how the agents behave is a human decision.

  • Defining agent behaviour
  • Setting boundaries
  • Tuning prompts and settings
  • Evaluating conversation quality
  • Intervening where judgment or sensitive decisions matter

The principle

The structure is automated. The behaviour is authored.

Exceptions

This is a conversation system, not a support desk. It is not described here as production support automation.

  • Ambiguous mentions
  • Context drift
  • Weak or incomplete model response
  • Stale memory
  • Loop behaviour requiring tuning
  • Sensitive or business-critical conversation requiring escalation

How it improves the workflow

The workflow separates conversation orchestration, memory, model behaviour and response handling instead of forcing everything through one unstructured assistant step.

Who it’s for

  • Businesses needing 24/7 AI-powered support
  • Teams handling complex multi-step queries
  • Companies deploying AI agents on Telegram
  • Developers building scalable AI chat systems
  • Organizations needing multiple specialized AI roles

Walkthrough