- A channel adapter receives a message.
- The gateway checks pairing and allowlist rules.
- The gateway resolves routing and selects an AI adapter.
- The gateway loads recent session history for context.
- The gateway builds the request (history + new user message).
- The gateway records the user message locally (in memory, and optionally on disk).
- The AI adapter returns a response.
- The gateway records the assistant response locally (in memory, and optionally on disk).
- The gateway sends the response back to the original channel.
Example
Telegram user sends “what’s the weather?”. The gateway:- checks pairing (e.g. is the user allowed to message the bot?),
- resolves routing and fetches recent history,
- calls your AI adapter (e.g. an AI-sdk backend or HTTP adapter),
- replies in Telegram,
- and stores both messages locally (and can persist them to a session transcript if enabled).