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.
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.
- Telegram Trigger
- Define Global Settings
- Define Agent Settings
- Extract Mentions
- Loop Over Items
- First Loop?
Input switches by pass
- First loop: set the user message as input
- Later loops: set the last assistant message as input
- AI Agent
The agent uses
- Google Gemini Chat Model
- Simple Memory
- Set lastAssistantMessage
- Continue loop
- Combine and Format Responses
- 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
