My Own AI Assistant on Telegram: OpenClaw + Ollama on Omarchy

4 min read

GenAIAgentsOllamaOmarchyGuides

I message a Telegram bot from my phone, and an agent running on my Omarchy laptop answers, using a model served locally by Ollama. No cloud model, no open ports, and the agent can use tools on the machine I gave it.

The piece in the middle is OpenClaw, an open-source assistant that connects chat apps to AI agents through a local gateway. Here's the exact setup, with real terminal output from each step.

Phone, Telegram, OpenClaw gateway, agent loop, Ollama
The gateway polls Telegram over HTTPS, so nothing on the laptop is exposed to the internet.

What you need

  • Ollama running with a model that supports tool calling (ollama show <model> lists tools under capabilities).
  • Node 24.16+ (OpenClaw won't install on Node 22). On Omarchy: mise use -g node@24.
  • A Telegram account.

1. Install OpenClaw

npm install -g openclaw@latest --allow-scripts=openclaw
openclaw --version
Installing OpenClaw with npm
On npm 11.16+ and 12, --allow-scripts=openclaw lets its install scripts run.

There's also a one-line installer (curl -fsSL https://openclaw.ai/install.sh | bash) and, if Ollama is already set up, ollama launch openclaw does the install, model pick and onboarding in one go.

2. Onboard it with Ollama as the model

openclaw onboard --install-daemon

The wizard asks for a model provider (choose Ollama), detects your local models, writes ~/.openclaw/openclaw.json, and installs the gateway as a systemd user service so it starts on login. The scriptable version of the same thing:

openclaw onboard with Ollama, then models list
Onboarding found the local Ollama model and made it the default.

The relevant part of the config it writes:

{
  "agents": { "defaults": { "model": { "primary": "ollama/qwen3:0.6b" } } },
  "models": {
    "providers": {
      "ollama": { "baseUrl": "http://127.0.0.1:11434", "api": "ollama" }
    }
  },
  "gateway": { "mode": "local", "port": 18789, "bind": "loopback" }
}

Keep bind on loopback. The gateway can run tools on your machine, so only local clients should reach it.

3. Check the gateway is up

openclaw gateway status
openclaw status
openclaw gateway status output
Loopback-only and reachable. The dashboard lives at http://127.0.0.1:18789/.

4. Create the Telegram bot

  1. In Telegram, open a chat with @BotFather (check the handle exactly).
  2. Send /newbot, pick a display name and a username ending in bot.
  3. Copy the token it gives you. Treat it like a password.

5. Connect the bot to OpenClaw

openclaw channels add --channel telegram --token <your-bot-token>
openclaw channels status --probe

Or put it in ~/.openclaw/openclaw.json yourself:

{
  "channels": {
    "telegram": {
      "enabled": true,
      "botToken": "123456:ABC...",
      "dmPolicy": "pairing",
      "groups": { "*": { "requireMention": true } }
    }
  }
}

The running gateway hot-reloads the change. dmPolicy: "pairing" is the important line: strangers who find your bot can't talk to your agent until you approve them.

6. Pair your own account

Send your bot any message from your phone. That creates a pairing request. Approve it on the laptop:

openclaw pairing list telegram
openclaw pairing approve telegram <CODE>

Codes expire after an hour. Once approved, every message you send the bot goes to the agent, and its reply comes back in the chat.

7. Make the local model good enough

This is where most local setups fall over:

  • Context window. OpenClaw's system prompt, tools and memory need room. Ollama's docs recommend at least 64k tokens for local models. Set OLLAMA_CONTEXT_LENGTH=65536 on the Ollama service (how).
  • But context costs RAM. On an 8 GB test box, a 32k context got the model killed mid-load, and the agent just reported provider internal error, HTTP 500. If you see that, check journalctl -u ollama for a killed runner and lower the context or use a smaller model.
  • Model size. Tiny models can call tools but make poor decisions. Use the biggest tool-capable model your GPU runs comfortably, and keep a small one for quick tests.
  • Keep it warm. OLLAMA_KEEP_ALIVE=30m stops the first message after a break from waiting for a model load.

8. Day-to-day commands

CommandUse
openclaw statusHealth, sessions, channels at a glance
openclaw logs --followWatch messages and tool calls live
openclaw models listWhich model the agent uses
openclaw doctorFind and fix config problems
openclaw gateway stopStop the gateway
openclaw security auditCheck what the agent is allowed to do

Guardrails I'd keep

  • Pairing on, and only your Telegram user ID allowed.
  • Gateway on loopback, no port forwarding.
  • Run openclaw security audit after changing tools or skills, and keep risky tools behind approvals.
  • Keep the bot token and gateway token out of screenshots and git. None of the ones here show either.

The agent loop running behind all this is the one from my AI agents guide, just with a phone on the other end.

Waste no more time arguing what a good man should be. Be one.

Marcus Aurelius

Built with Next.js and far too much coffee.