Telegram Managed Bots
One Telegram contact per user-character relationship.
Use this path when your product wants every user-character relationship to have its own Telegram contact and chat history.
Managed Bots are different from connecting one existing BotFather token to one character. You connect a manager bot once, then LoreOS creates or reuses a child bot contact for each relationship.
1. Prepare the manager bot
In Telegram:
- Open
@BotFather. - Create or select the manager bot.
- Open BotFather’s Mini App.
- Open the manager bot settings.
- Enable Bot Management Mode.
Then copy the manager bot token.
2. Connect the manager
The hosted console has a Telegram Managed Bots panel. Paste an app runtime API key, paste the manager bot token, and click Connect manager.
Or call the API:
The response includes non-secret status:
Status meanings:
enabled: Telegram confirmedcan_manage_bots=true.disabled: enable Bot Management Mode in BotFather and verify again.unknown: verify again after enabling Bot Management Mode.not_required: ordinary character bots do not use management mode.
Verify again after changing BotFather settings:
3. Create a relationship session
Save data.session_id.
4. Create or reuse the Telegram contact
Response:
Open data.telegram.deep_link from the end user’s Telegram account. Telegram
guides the user through creating or confirming the child bot. When Telegram sends
the managed-bot update to LoreOS, LoreOS fetches the child token, stores it in
Vault, registers the webhook, and binds the child bot to the existing session.
Calling the endpoint again after linking returns:
5. Check child contact status
The console shows Recent child contacts in the Telegram Managed Bots panel. Use it to see whether the web handoff is still waiting for Telegram, already linked to a child bot, expired, or failed.
You can also call the API:
Response fields are non-secret:
Possible request statuses:
pending: LoreOS created the request and is waiting for Telegram’s managed-bot update.linked: the child bot token was fetched, stored in Vault, and bound to the session.expired: the short-lived request was not completed beforeexpires_at.failed: LoreOS received enough information to try linking, but child setup failed. Checkerror_codeanderror_message.
The response does not include manager tokens, child tokens, webhook secrets, raw Telegram update payloads, or raw Telegram owner user IDs.
6. Read replies from the event log
Telegram delivery and web delivery share one session event log.
Render message.created, character.initiated, and image.ready events. Do
not wait for delivery-attempt delivered status before showing a reply in your
own UI.
Troubleshooting
Security model
- Raw manager and child bot tokens are never returned by the API.
- Tokens are stored in Vault, not in delivery-channel config.
- Console and API responses expose only non-secret status fields.
- One child bot maps to one user-character relationship, so Telegram chat history stays natural for the user.