Takopi Setup
Takopi is a Telegram bot that provides a chat interface to Claude Code.
GitHub: https://github.com/nuclearthinking/takopi
Prerequisites
- Python 3.10+
- uv (Python package manager)
- Telegram Bot Token (from @BotFather)
- Anthropic API Key
Step 1: Install uv
curl -LsSf https://astral.sh/uv/install.sh | shStep 2: Install Takopi
uv tool install takopiStep 3: Configure
Create ~/.takopi/config.toml:
[bot]
token = "your-telegram-bot-token"
allowed_users = [123456789] # Your Telegram user ID
[anthropic]
api_key = "your-anthropic-api-key"
model = "claude-sonnet-4-20250514"
[claude_code]
enabled = true
working_directory = "/home/ubuntu/claude-workspace"To get your Telegram user ID, message @userinfobot.
Step 4: Create Start Script
Create ~/start-takopi.sh:
#!/bin/bash
while true; do
echo "Starting Takopi..."
takopi run 2>&1 | tee -a ~/takopi.log
echo "Takopi stopped. Restarting in 5 seconds..."
sleep 5
doneMake it executable:
chmod +x ~/start-takopi.shStep 5: Create Stop Script
Create ~/stop-takopi.sh:
#!/bin/bash
# Kill the restart loop
pkill -f "start-takopi.sh"
# Kill takopi itself
if [ -f ~/.takopi/takopi.pid ]; then
kill $(cat ~/.takopi/takopi.pid) 2>/dev/null
fi
pkill -f "takopi run"
echo "Takopi stopped"Make it executable:
chmod +x ~/stop-takopi.shStep 6: Run
# Start in background
nohup ~/start-takopi.sh &
# Or in tmux
tmux new -s takopi
~/start-takopi.sh
# Ctrl+B, D to detachAdding Plugins
Takopi supports plugins for custom commands.
Create Plugin
Create a new directory with pyproject.toml:
[project]
name = "takopi-myplugin"
version = "0.1.0"
dependencies = ["takopi"]
[project.entry-points."takopi.commands"]
mycommand = "takopi_myplugin.backend:MyCommand"Create takopi_myplugin/backend.py:
from takopi.commands import CommandBackend, CommandResult
from takopi.context import Context
class MyCommand(CommandBackend):
name = "mycommand"
description = "My custom command"
async def execute(self, ctx: Context, args: str) -> CommandResult:
return CommandResult(text="Hello from my command!")Install Plugin
uv pip install -e /path/to/plugin \
--python ~/.local/share/uv/tools/takopi/bin/pythonRestart Takopi
~/stop-takopi.sh
nohup ~/start-takopi.sh &Logs
View logs:
tail -f ~/takopi.logTips
- Use
/helpin Telegram to see available commands - Bot only responds to users in
allowed_userslist - Restart after config changes