$cd ../troubleshooting/
Telegram Group Sessions Reset After Gateway Restart
// After restarting the OpenClaw gateway, Telegram group-bound agents create fresh sessions instead of restoring from sessions.json. The session key mapping exists but the group session is not restored on boot.
symptoms.log
π Symptoms
βBot loses memory of previous conversation after gateway restart
βAgent introduces itself as if meeting the group for the first time
βSessions.json exists and has the correct session entries
βTelegram group chats affected β private DMs may restore correctly
check_sessions.sh
β Fix 1 β Verify sessions.json is being persisted
Verify session persistence
# Check sessions.json exists and has your Telegram group session cat ~/.openclaw/sessions.json | jq 'keys' # Look for entries like: telegram:group:-1001234567890 # If empty or missing, session was never persisted
agent_config.yaml
β Fix 2 β Set explicit sessionKey for group agents
Set explicit sessionKey matching the sessions.json key
agents:
- name: my-group-bot
channel: telegram
sessionKey: "telegram:group:-1001234567890" # Explicit key
memory:
persist: truegateway.yaml
β Fix 3 β Enable session restore on gateway boot
Force session restore from sessions.json on gateway start
gateway:
sessions:
restoreOnBoot: true
restoreChannels:
- telegramβΉ Known Bug
This is a confirmed bug tracked in Issue #35283. The root cause is that gateway boot does not re-hydrate Telegram group sessions from sessions.json when the session key mapping exists but points to a group chat. A fix is in progress.
β FAQ
Q1. Where is sessions.json stored?
By default at ~/.openclaw/sessions.json on the host, or /app/data/sessions.json inside Docker. Ensure this file persists across restarts. If using Docker, add a volume mount for the data directory: './data:/app/data'. Without this, every container restart wipes the session file.
Q2. Can I manually restore a session?
Yes. If you have a backup of sessions.json, stop the gateway with 'docker compose down', replace the file at ~/.openclaw/sessions.json, then restart with 'docker compose up -d'. The gateway reads sessions.json during boot. After restart, verify the session was restored by sending a test message to the Telegram group β the bot should remember previous context.
Q3. Does this affect WhatsApp or Discord sessions?
WhatsApp sessions use a separate auth state directory (the Baileys auth folder) and are not affected by sessions.json issues. Discord sessions are token-based β the bot token is stateless and reconnects automatically on restart without any session file. This bug is specific to Telegram group session key mapping in sessions.json.
Q4. How do I find my Telegram group's chat ID?
The chat ID is the number in your sessionKey (e.g., 'telegram:group:-1001234567890'). You can find it by: (1) Adding @userinfobot to your group β it reports the group ID. (2) Checking OpenClaw debug logs when a message arrives from the group β the chat_id is logged with each incoming message. (3) Using the Telegram Bot API: send a GET to 'https://api.telegram.org/bot<token>/getUpdates' after sending a message from the group.
Q5. The fix works but resets again after a few days. What's going on?
This usually means sessions.json is being overwritten rather than updated. Check if something in your deployment pipeline is doing a 'docker compose down -v' (which removes volumes) or overwriting the data directory on deploy. Also check if you're running with '--force-recreate' which destroys the container filesystem. Use a named Docker volume ('sessions_data:/app/data') instead of a bind mount β named volumes survive '--force-recreate'.
Q6. Is there a way to get notified when a session resets?
Yes. Set up a webhook or Telegram notification in your monitoring config. OpenClaw can send a self-notification to a specific Telegram chat when a session reset is detected. Alternatively, set 'notify_on_session_reset: true' in the gateway config β this sends a message to the bot's own chat (or a designated admin chat) whenever a session is recreated from scratch rather than restored.