An autonomous AI agent accessible through Telegram. Built with Upsonic following the OpenClaw philosophy: simple tools, agent-driven autonomy, and memory without limitations.
This is not a chatbot wrapper. It's a full autonomous agent with filesystem and shell access, controlled entirely through Telegram.
- Remember conversation context between messages
- Run shell commands on your machine
- Read, write, and edit files in its workspace
- Build up its own memories over time via
AGENTS.md
- Python 3.10+
- uv package manager
- A Telegram account
- An ngrok account (free tier works)
- An OpenAI API key
uv venv
uv pip install upsonic fastapi uvicorn- Open Telegram and search for @BotFather
- Send
/newbotand follow the prompts to pick a name and username - Copy the Bot API Token BotFather gives you
Now get your Telegram user ID:
- Search for @userinfobot on Telegram
- Send it any message
- It replies with your numeric user ID — write it down
Why? This agent has filesystem and shell access on your machine. Locking it to your user ID ensures nobody else can interact with it.
Install ngrok:
# macOS
brew install ngrok
# Linux
snap install ngrok
# Windows
choco install ngrokCreate a free account at ngrok.com/signup, grab your authtoken, and run:
ngrok config add-authtoken YOUR_AUTH_TOKENStart the tunnel:
ngrok http 8000You'll see output like:
Forwarding https://abc123.ngrok-free.app -> http://localhost:8000
Copy that https://....ngrok-free.app URL. That's your public webhook endpoint.
Important: Keep this terminal open. If you close ngrok, the tunnel dies and your bot goes deaf. When you restart ngrok, the URL changes — update your
.envaccordingly.
Copy the example env file and fill in your values:
cp .env.example .envEdit .env:
TELEGRAM_BOT_TOKEN=your-bot-token-from-botfather
TELEGRAM_WEBHOOK_URL=https://abc123.ngrok-free.app
TELEGRAM_USER_ID=your-numeric-user-id
OPENAI_API_KEY=your-openai-api-key
The workspace is the agent's home directory. All file and shell operations are sandboxed here.
Copy the included workspace to ~/my-agent-workspace:
cp -r workspace ~/my-agent-workspaceYour workspace will look like this:
~/my-agent-workspace/
├── AGENTS.md # Agent behavior & guidelines
├── SOUL.md # Agent identity
├── USER.md # User context
└── memory/ # Daily logs will go here
Customize it: Edit AGENTS.md to change how your agent behaves. Edit SOUL.md to change who it is. No code changes needed.
Make sure ngrok is running in one terminal, then in another:
uv run bot.pyOpen Telegram, find your bot by its username, and start chatting.
/reset— Clears the conversation history. The agent re-reads the workspace and sends a fresh greeting.
Since there's an actual autonomous agent behind Telegram, you can send messages like:
- "Find all TODO comments in the codebase"
- "Run the tests and tell me if anything fails"
- "Create a new file called hello.py with a hello world program"
- "Read the README and summarize it"
- "List all Python files in the project"
The agent uses its filesystem and shell tools to actually do these things and report back.
AutonomousAgentcomes with built-in filesystem and shell tools — no extra config neededAGENTS.mdis automatically loaded into the system prompt. The agent's personality and rules come from thereInterfaceMode.CHATmeans the agent remembers your conversation across messagesallowed_user_idslocks the bot to your Telegram account onlyworkspacepoints to the folder where the agent operates — it's sandboxed and can't escape
openclaw-telegram-bot/
├── bot.py # Main entry point
├── .env.example # Environment variables template
├── README.md # This file
└── workspace/ # Agent workspace (copy to ~/my-agent-workspace)
├── AGENTS.md # Agent behavior & guidelines
├── SOUL.md # Agent identity
├── USER.md # User context
└── memory/ # Daily memory logs
- TASK mode: Switch
InterfaceMode.CHATtoInterfaceMode.TASKfor stateless one-off queries - Custom tools: Give your agent domain-specific capabilities (API calls, database queries, deployment scripts)
- Heartbeat: Enable periodic check-ins by setting
heartbeat=Trueon theAutonomousAgent
Full docs: docs.upsonic.ai