Skip to main content
  1. Posts/

Connecting Claude Max and Telegram

Patrik Grobshäuser
Author
Patrik Grobshäuser
Breaking things, building things, writing about it.
Table of Contents
Installation - This article is part of a series.
Part 3: This Article

Dear Readers,

next up: talking to agents from my phone. That means getting OpenClaw authenticated against an LLM and wiring up Telegram. If you already have a Claude Max subscription you can reuse those OAuth credentials instead of paying for API access separately.

Claude OAuth
#

The Claude CLI stores its OAuth tokens at ~/.claude/.credentials.json. OpenClaw can use those same tokens — you just need to copy the values into the right format.

Here’s what the auth profile looks like:

// ~/.openclaw/agents/main/agent/auth-profiles.json
{
  "version": 1,
  "profiles": {
    "anthropic:default": {
      "type": "oauth",
      "provider": "anthropic",
      "access": "sk-ant-oat01-...",
      "refresh": "sk-ant-ort01-...",
      "expires": 1771357025665
    }
  }
}

Gotcha: The field names must be access, refresh, and expires. Not token, refreshToken, or expiresAt. Get this wrong and OpenClaw silently fails to authenticate.

The refresh token means OpenClaw handles re-auth on its own. Set it once, forget about it.

The Telegram Bot
#

Creating the Bot
#

Nothing new here, standard BotFather flow:

  1. Message @BotFather on Telegram
  2. /newbot — pick a name and username
  3. Save the bot token

Channel Config
#

Drop the Telegram channel into your OpenClaw config:

// In ~/.openclaw/openclaw.json
{
  "channels": {
    "telegram": {
      "botToken": "your-bot-token",
      "dmPolicy": "open",
      "allowFrom": ["*"]
    }
  }
}

dmPolicy: "open" plus allowFrom: ["*"] means the bot auto-approves all incoming conversations. Fine for a personal bot — for anything shared, restrict by Telegram user ID.

Routing DMs to an Agent
#

Set one agent as the default and all incoming DMs go there:

{
  "agents": {
    "list": [
      {
        "id": "pa",
        "name": "PA",
        "default": true,
        "model": "anthropic/claude-haiku-4-5-20251001",
        "workspace": "/root/obsidian/config/patrik"
      }
    ]
  }
}

"default": true catches everything that doesn’t match a specific agent. You can also run multiple agents and trigger them via mention patterns in group chats:

{
  "id": "wongel",
  "name": "Wongel",
  "model": "anthropic/claude-sonnet-4-5-20250929",
  "groupChat": {
    "mentionPatterns": ["@wongel_bot", "Wongel"]
  }
}

Agent Identity
#

Each agent gets its own personality via SOUL.md and IDENTITY.md files in its agent directory. There’s also inline config if you prefer:

{
  "identity": {
    "name": "PA",
    "emoji": "clipboard",
    "theme": "Professional, helpful personal assistant"
  }
}

Gotcha: If SOUL.md or IDENTITY.md exist in the agent’s workspace directory (not just agentDir), they override the agent directory versions. Useful if your workspace is an Obsidian vault — you can edit agent personalities from your phone.

The Telegram Update Offset Trap
#

If you swap your bot token (new bot, rotated credentials), Telegram might not deliver messages to the new bot.

The fix:

rm /root/.openclaw/telegram/update-offset-default.json
systemctl --user restart openclaw-gateway

OpenClaw tracks the last-processed Telegram update ID. A stale offset from the old bot means the new bot skips everything. Delete the file, restart, done.

Model Selection
#

OpenClaw lets you assign different models per agent:

  • claude-haiku-4-5 — fast and cheap, good for a PA handling quick tasks
  • claude-sonnet-4-5 — more capable, good for group chat bots that need more nuance
  • claude-opus-4 — full capability, for complex multi-step tasks

I’m running Haiku for my PA. More than enough for filing notes and answering quick questions.


This wraps up the Installation series. The server is running, the dashboard is secured, and agents are connected via Telegram. Next: giving agents a knowledge base and email access.

Installation - This article is part of a series.
Part 3: This Article

Related