🤖Agent ProtocolAgent Protocol
The AI Agent Playbook
Your AI.
Your Telegram.
Always On.
From BotFather to autonomous agent. From prompt to production.
10 levels. 2 tracks. 100% practical.
Choose Your Track
Complete levels 1-4 first, then your chosen track, then 8-10.
Before starting, you need a place to run commands. Good news: Track B works on your laptop!
Track A vs Track B Requirements
Critical💡 Why This Matters
Different tracks have different needs!
Local Setup (Mac/Windows/Linux)
💡 Why This Matters
Start here! Works for both tracks.
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejsnode --version
npm --versionVPS Options (Track A / 24/7 Production)
VPS Quick Setup
ssh root@your-server-ipcurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejsnode --version
npm --versionEasy Option: Hostinger VPS
💡 Why This Matters
Don't want to deal with SSH? Hostinger has a friendly panel.
Every Telegram bot starts with @BotFather. It's the official bot that creates and manages all other bots. No coding required - just a Telegram conversation!
Create Your Bot
Critical💡 Why This Matters
Your bot token is the key to everything. Guard it like a password.
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
⚠️ NEVER share this token publicly!Configure Bot Settings
Privacy Mode
💡 Why This Matters
Privacy mode determines what messages your bot receives in groups.
A quick overview of how Telegram bots receive and send messages. Don't worry about the technical details - OpenClaw and Claude Code handle this for you!
The Simple Flow
What Your Bot Can Do
Message Types
Before connecting AI to Telegram, understand the core concepts that make agents work.
Large Language Models
System Prompts
Critical💡 Why This Matters
The system prompt defines who your agent IS.
Context Window
Tool Use
💡 Why This Matters
Tools give your agent superpowers beyond conversation.
search_web(query) - Search the internet
• get_balance(wallet) - Check crypto balance
• send_message(to, text) - Message someone
• execute_trade(pair, amount) - Trading
Flow:
1. User asks something
2. AI decides to use a tool
3. Your code executes the tool
4. Result goes back to AI
5. AI responds to user
This is how agents ACT, not just talk.Two ways to connect Claude to Telegram. Choose based on your skills and needs.
Stack Comparison
Track A: OpenClaw
Track B: Claude Code
Make Your Choice
Critical💡 Why This Matters
You can always switch later - the concepts transfer.
Combine AI with Web3. Your agent can check balances, send transactions, and interact with DeFi.
TON for Agents
TON in OpenClaw (Track A)
openclaw skills install ton-blockchainget_balance(address)
• get_transactions(address)
• send_ton(to, amount)
• swap_tokens(from, to, amount)
• get_token_price(symbol)
The skill handles wallet connection and transaction signing.TON in Claude Code (Track B)
/mcp add ton-blockchainimport { TonClient } from '@ton/ton';
const client = new TonClient({
endpoint: 'https://toncenter.com/api/v2/jsonRPC'
});
// Tool: check_balance
async function checkBalance(address) {
const balance = await client.getBalance(address);
return `Balance: ${balance / 1e9} TON`;
}Web3 Security
Critical💡 Why This Matters
Blockchain = irreversible. Be careful!
Before going live, secure your agent and prepare for scale.
API Key Security
Critical💡 Why This Matters
Leaked keys = stolen funds and runaway bills.
Rate Limiting
const userCounts = new Map();
function checkLimit(userId) {
const count = userCounts.get(userId) || 0;
if (count > 10) throw new Error('Rate limit');
userCounts.set(userId, count + 1);
}Deployment Options
openclaw gateway start
• Docker + docker-compose
• PM2 for process management
Claude Code (Track B):
• Run in screen or tmux session
• Use a dedicated server
• Consider OpenClaw for true 24/7
Cloud options:
• Railway, Render, Fly.io
• AWS ECS / Google Cloud Run
• DigitalOcean App PlatformMonitoring
Final project: Deploy your own AI agent that runs on Telegram.
Project: Personal Assistant
Launch Checklist
Critical💡 Why This Matters
Don't ship without checking these.
What's Next?
🔐 Agent Security Checklist
Complete before deploying any agent to production.
🚩 Common Agent Pitfalls
📚 Sources & Resources
Official documentation — verify everything and DYOR!
🟣 Claude Code
🔵 OpenClaw
🛠️ Tools & Frameworks
⚠️ Always verify commands and instructions against official sources before running them.