An AI agent performs tasks autonomously, differing from a simple chat by possessing specific capabilities.
Asking Claude 'what should I post today?' is a chat, not an agent.
An agent finds trending AI topics, picks high-engagement ones, drafts a post in your style, and saves it to a file without user interaction.
An agent has three things a regular chat does not: callable tools, persistent memory, and a loop running until a task is finished.
Agent tools include search, file systems, code execution, and external APIs.
Agent memory persists across tasks, not just within one session.
An agent's loop keeps running until the task is finished, not just until one response is generated.
The more tools, memory, and loops an agent has, the less human involvement is required.
The difference between an agent and a non-agent is not the underlying model but the structure surrounding it.
AI tools exist on a spectrum from basic chat to fully autonomous agents, defined by their capabilities and human involvement.
At one end, a basic chat involves asking Claude a question, getting an answer, and the session ends without tools or ongoing goals.
One step up, Claude with tools enabled is slightly agentic, as it decides to use features like web search or file reading independently.
Further up, multi-step workflows involve Claude breaking a given goal into steps, executing each, checking results, and delivering a finished output without human involvement.
At the top, fully autonomous agents run on a schedule, monitor inputs, call external services, and complete complex tasks without human intervention after the goal is set.
The distinction between the bottom and top of the spectrum lies in the surrounding structure, including callable tools, context-carrying memory, and continuous task loops.
Various types of AI agents can be built, each designed for specific tasks and situations.
A research agent gathers information, reads sources, extracts key points, and delivers structured summaries based on a question.
A writing agent creates content based on defined style, tone, format, audience, and topic, handling drafts, rewrites, and edits.
A code agent writes, runs, debugs, and improves code, managing implementation and debugging loops based on the desired functionality.
A business agent handles repetitive business tasks like drafting emails, processing customer requests, qualifying leads, and generating reports, running on autopilot.
A personal agent manages schedules, organizes tasks, prepares briefings, and handles daily planning work.
This guide will walk through building a Telegram bot using Claude Code, with Claude as its brain, running on a remote server.
Claude Code writes all necessary code based on plain English descriptions, allowing direct communication with the bot via Telegram once set up.
The entire setup process for the agent takes approximately 10-20 minutes and requires no coding knowledge.
Ready-made system prompt templates are provided for different agent types, to be pasted into Prompt 2 during setup using Claude Code.
Users should adjust any details in the templates to match their specific situation.
This template defines the research agent's job as gathering, analyzing, and synthesizing information.
When given a research task, the agent identifies sub-questions, searches for information, evaluates sources, extracts direct answers, and delivers a structured summary.
The summary should use headers, bullet points, and clear sections, explicitly stating uncertainties and avoiding filler.
This template defines the writing agent's job as writing content in a specified voice and style.
The writing style should be conversational, direct, use short sentences/paragraphs, include specific numbers/examples, and end with a call to action/thought.
When given a writing task, the agent asks for topic/audience/length, writes a first draft, reviews against style rules, and delivers a final version.
The agent should never add unnecessary introductions and always start with the most important point.
This template defines the code agent's job as writing, debugging, and improving code.
When given a coding task, the agent confirms understanding, writes clear code, identifies edge cases, and systematically debugs errors.
Code rules include writing clean, readable code with meaningful variable names, including error handling, explaining sections in plain language, and asking clarifying questions if unsure.
This template defines the business email agent's job as writing professional emails.
The communication style should be direct, respectful, without formalities, get to the point, and close with a clear next step.
When given an email task, the agent identifies the goal, writes a subject line, drafts the email in 3-5 short paragraphs, and ends with one clear action item.
The agent should always write ready-to-send emails, not templates with blanks.
This template defines the personal planning agent's job as organizing work and priorities.
When tasks/goals are shared, the agent identifies urgency, suggests realistic sequences, estimates time, and flags items for delegation/elimination.
When a project is described, the agent breaks it into next actions, identifies the most important first step, and creates a simple checklist.
The agent should keep planning practical, provide only the plan, and avoid motivational filler.
To build your AI agent, you will need a Claude API key, a Telegram bot token, and a Linux-based Virtual Private Server (VPS).
A Claude API key from console.anthropic.com is a developer key, charged per usage instead of a fixed monthly fee.
For a personal bot sending 50 messages a day, the Claude API cost is $1-5 per month, depending on the chosen model.
A Telegram bot token needs to be obtained from BotFather.
A Linux-based VPS is required, with 1 CPU, 1GB RAM, and 20GB storage being sufficient for a personal Telegram bot.
Basic VPS plans from providers like DigitalOcean, Hetzner, or Vultr cost around $4 to $6 per month.
Once the VPS server is set up, install Claude Code by running npm i -g @anthropic-ai/claude-code in the terminal.
The choice of Claude model impacts performance and cost for the bot.
Different Claude models offer varying performance and cost suitable for personal bots and complex analytical agents.
| Model | Use Case | Cost Efficiency | Answer Quality |
|---|---|---|---|
| Sonnet 4.6 | Most personal bots | Affordable for daily use | Strong enough for any task |
| Haiku 4.5 | Minimize cost | Lowest cost | — |
| Opus 4.8 | Complex analytical agent | — | Critical |
The first step involves launching Claude Code in the VPS terminal and pasting a prompt to build the Telegram bot.
A prompt is provided to define the agent's personality, instructing Claude Code to build a Telegram bot using the Claude API as its brain.
The bot requirements include Python language, python-telegram-bot library, claude-sonnet-4-6 model, message handling, conversation history per user, and /start and /clear commands.
Claude Code should create main bot file, requirements.txt, and a .env file, reading API keys from environment variables.
The bot should be deployed as a systemd service to run automatically on a Linux server.
The service should start automatically on boot, restart on crashes, load environment variables from .env, and save logs to a file.
The exact terminal commands for installing and starting the service should also be provided.
A prompt is provided to fix the issue of the bot losing conversation history upon restart by adding persistent memory.
Conversation history for each user should be saved to a JSON file on disk, with a maximum length of the last 20 messages.
Skills are capabilities added to the bot over time by giving Claude Code new prompts, which then writes the necessary code.
The web search skill allows the agent to look up real-time information instead of only answering from its memory.
Web search capability should be added using the Tavily API, and Claude's tool use feature should be implemented cleanly.
The bot should decide on its own when to search for current information or answer from memory.
The save notes skill allows the agent to save ideas, tasks, and research findings to a file and retrieve them later.
A note-saving feature should be added, triggered by phrases like "save this," "remember this," or "note:", along with /notes and /clearnotes commands.
This skill restricts bot usage to only the owner's account, preventing others from consuming API credits.
User restriction should be added, using the Telegram user ID from the .env file as ALLOWED_USER_ID, and responding with "This bot is private" to unauthorized users.
Instructions should be provided on how to find the Telegram user ID, either through the bot or otherwise.
This skill adds a cost tracker to monitor Claude API charges per token, keeping the user aware of their spending.
Basic cost tracking should be added, logging input and output tokens after each Claude API response, maintaining a running total in a costs.json file.
A /costs command should be added to display total tokens used today and overall.
This skill enables the agent to send a daily message every morning without being prompted.
Every day at 8:00 am, the bot should send a message containing a motivational one-liner, a reminder for the top priority, and a random productivity/AI fact.
The briefing should be sent to the Telegram user ID from the .env file, using schedule or APScheduler library.
Several useful tips are provided for managing and maintaining the AI agent after its initial setup.
To update the agent's personality, open the main bot file, change the system prompt variable, save, and restart the service with sudo systemctl restart your-bot-name.
To check if the bot is running, use sudo systemctl status your-bot-name; "active (running)" means it's working, "failed" indicates logs should be checked.
Logs can be read using journalctl -u your-bot-name -n 50 to view the last 50 lines and find error messages.
To add a new skill, open Claude Code in the project folder, describe the feature, and Claude Code will integrate it, indicating if a restart is needed.
The most common problem with AI agents is losing context between sessions, during long tasks, or after many messages, leading to mistakes or repeated work.
The memory problem manifests in three main ways, impacting the agent's ability to maintain context.
Long tasks can exceed Claude's context limit, causing the agent to lose the original goal, past decisions, and constraints from the conversation's beginning.
When a session is closed and reopened, the agent starts from zero, losing all previous context.
If the agent is interrupted mid-task, it has no way of knowing where it stopped, leading to potential rework.
Four methods can fix the agent's memory problem and maintain context across tasks and sessions.
Instruct the agent to write a progress note after every major step, detailing what was done, decided, and needs to happen, to restore full context in new sessions.
Ask the agent to summarize its current status every 10 to 15 messages to compress context and prevent overflow.
Before conversations become too long, ask the agent to compress everything into a short summary and continue from there to keep the thread intact.
Add key facts that the agent always needs directly to the system prompt in the bot code, ensuring this information is always in context.
A prompt is provided for the agent to write a brief checkpoint, covering completed items, key decisions, remaining tasks, and necessary context for continuation, under 200 words.
A specific format is provided for the memory note to be written after each major step, including what was done, key decisions, current state, and next steps.
A prompt for resuming a task from a previous session instructs the agent to confirm understanding, identify the next step, and ask questions based on a pasted memory note.
A prompt is provided for compressing a long conversation into a summary of the original goal, what has been done, what was found, and key decisions made.
An AI agent performs tasks autonomously, differing from a simple chat by possessing specific capabilities.
Asking Claude 'what should I post today?' is a chat, not an agent.
An agent finds trending AI topics, picks high-engagement ones, drafts a post in your style, and saves it to a file without user interaction.
An agent has three things a regular chat does not: callable tools, persistent memory, and a loop running until a task is finished.
Agent tools include search, file systems, code execution, and external APIs.
Agent memory persists across tasks, not just within one session.
An agent's loop keeps running until the task is finished, not just until one response is generated.
The more tools, memory, and loops an agent has, the less human involvement is required.
The difference between an agent and a non-agent is not the underlying model but the structure surrounding it.
AI tools exist on a spectrum from basic chat to fully autonomous agents, defined by their capabilities and human involvement.
At one end, a basic chat involves asking Claude a question, getting an answer, and the session ends without tools or ongoing goals.
One step up, Claude with tools enabled is slightly agentic, as it decides to use features like web search or file reading independently.
Further up, multi-step workflows involve Claude breaking a given goal into steps, executing each, checking results, and delivering a finished output without human involvement.
At the top, fully autonomous agents run on a schedule, monitor inputs, call external services, and complete complex tasks without human intervention after the goal is set.
The distinction between the bottom and top of the spectrum lies in the surrounding structure, including callable tools, context-carrying memory, and continuous task loops.
Various types of AI agents can be built, each designed for specific tasks and situations.
A research agent gathers information, reads sources, extracts key points, and delivers structured summaries based on a question.
A writing agent creates content based on defined style, tone, format, audience, and topic, handling drafts, rewrites, and edits.
A code agent writes, runs, debugs, and improves code, managing implementation and debugging loops based on the desired functionality.
A business agent handles repetitive business tasks like drafting emails, processing customer requests, qualifying leads, and generating reports, running on autopilot.
A personal agent manages schedules, organizes tasks, prepares briefings, and handles daily planning work.
This guide will walk through building a Telegram bot using Claude Code, with Claude as its brain, running on a remote server.
Claude Code writes all necessary code based on plain English descriptions, allowing direct communication with the bot via Telegram once set up.
The entire setup process for the agent takes approximately 10-20 minutes and requires no coding knowledge.
Ready-made system prompt templates are provided for different agent types, to be pasted into Prompt 2 during setup using Claude Code.
Users should adjust any details in the templates to match their specific situation.
This template defines the research agent's job as gathering, analyzing, and synthesizing information.
When given a research task, the agent identifies sub-questions, searches for information, evaluates sources, extracts direct answers, and delivers a structured summary.
The summary should use headers, bullet points, and clear sections, explicitly stating uncertainties and avoiding filler.
This template defines the writing agent's job as writing content in a specified voice and style.
The writing style should be conversational, direct, use short sentences/paragraphs, include specific numbers/examples, and end with a call to action/thought.
When given a writing task, the agent asks for topic/audience/length, writes a first draft, reviews against style rules, and delivers a final version.
The agent should never add unnecessary introductions and always start with the most important point.
This template defines the code agent's job as writing, debugging, and improving code.
When given a coding task, the agent confirms understanding, writes clear code, identifies edge cases, and systematically debugs errors.
Code rules include writing clean, readable code with meaningful variable names, including error handling, explaining sections in plain language, and asking clarifying questions if unsure.
This template defines the business email agent's job as writing professional emails.
The communication style should be direct, respectful, without formalities, get to the point, and close with a clear next step.
When given an email task, the agent identifies the goal, writes a subject line, drafts the email in 3-5 short paragraphs, and ends with one clear action item.
The agent should always write ready-to-send emails, not templates with blanks.
This template defines the personal planning agent's job as organizing work and priorities.
When tasks/goals are shared, the agent identifies urgency, suggests realistic sequences, estimates time, and flags items for delegation/elimination.
When a project is described, the agent breaks it into next actions, identifies the most important first step, and creates a simple checklist.
The agent should keep planning practical, provide only the plan, and avoid motivational filler.
To build your AI agent, you will need a Claude API key, a Telegram bot token, and a Linux-based Virtual Private Server (VPS).
A Claude API key from console.anthropic.com is a developer key, charged per usage instead of a fixed monthly fee.
For a personal bot sending 50 messages a day, the Claude API cost is $1-5 per month, depending on the chosen model.
A Telegram bot token needs to be obtained from BotFather.
A Linux-based VPS is required, with 1 CPU, 1GB RAM, and 20GB storage being sufficient for a personal Telegram bot.
Basic VPS plans from providers like DigitalOcean, Hetzner, or Vultr cost around $4 to $6 per month.
Once the VPS server is set up, install Claude Code by running npm i -g @anthropic-ai/claude-code in the terminal.
The choice of Claude model impacts performance and cost for the bot.
Different Claude models offer varying performance and cost suitable for personal bots and complex analytical agents.
| Model | Use Case | Cost Efficiency | Answer Quality |
|---|---|---|---|
| Sonnet 4.6 | Most personal bots | Affordable for daily use | Strong enough for any task |
| Haiku 4.5 | Minimize cost | Lowest cost | — |
| Opus 4.8 | Complex analytical agent | — | Critical |
The first step involves launching Claude Code in the VPS terminal and pasting a prompt to build the Telegram bot.
A prompt is provided to define the agent's personality, instructing Claude Code to build a Telegram bot using the Claude API as its brain.
The bot requirements include Python language, python-telegram-bot library, claude-sonnet-4-6 model, message handling, conversation history per user, and /start and /clear commands.
Claude Code should create main bot file, requirements.txt, and a .env file, reading API keys from environment variables.
The bot should be deployed as a systemd service to run automatically on a Linux server.
The service should start automatically on boot, restart on crashes, load environment variables from .env, and save logs to a file.
The exact terminal commands for installing and starting the service should also be provided.
A prompt is provided to fix the issue of the bot losing conversation history upon restart by adding persistent memory.
Conversation history for each user should be saved to a JSON file on disk, with a maximum length of the last 20 messages.
Skills are capabilities added to the bot over time by giving Claude Code new prompts, which then writes the necessary code.
The web search skill allows the agent to look up real-time information instead of only answering from its memory.
Web search capability should be added using the Tavily API, and Claude's tool use feature should be implemented cleanly.
The bot should decide on its own when to search for current information or answer from memory.
The save notes skill allows the agent to save ideas, tasks, and research findings to a file and retrieve them later.
A note-saving feature should be added, triggered by phrases like "save this," "remember this," or "note:", along with /notes and /clearnotes commands.
This skill restricts bot usage to only the owner's account, preventing others from consuming API credits.
User restriction should be added, using the Telegram user ID from the .env file as ALLOWED_USER_ID, and responding with "This bot is private" to unauthorized users.
Instructions should be provided on how to find the Telegram user ID, either through the bot or otherwise.
This skill adds a cost tracker to monitor Claude API charges per token, keeping the user aware of their spending.
Basic cost tracking should be added, logging input and output tokens after each Claude API response, maintaining a running total in a costs.json file.
A /costs command should be added to display total tokens used today and overall.
This skill enables the agent to send a daily message every morning without being prompted.
Every day at 8:00 am, the bot should send a message containing a motivational one-liner, a reminder for the top priority, and a random productivity/AI fact.
The briefing should be sent to the Telegram user ID from the .env file, using schedule or APScheduler library.
Several useful tips are provided for managing and maintaining the AI agent after its initial setup.
To update the agent's personality, open the main bot file, change the system prompt variable, save, and restart the service with sudo systemctl restart your-bot-name.
To check if the bot is running, use sudo systemctl status your-bot-name; "active (running)" means it's working, "failed" indicates logs should be checked.
Logs can be read using journalctl -u your-bot-name -n 50 to view the last 50 lines and find error messages.
To add a new skill, open Claude Code in the project folder, describe the feature, and Claude Code will integrate it, indicating if a restart is needed.
The most common problem with AI agents is losing context between sessions, during long tasks, or after many messages, leading to mistakes or repeated work.
The memory problem manifests in three main ways, impacting the agent's ability to maintain context.
Long tasks can exceed Claude's context limit, causing the agent to lose the original goal, past decisions, and constraints from the conversation's beginning.
When a session is closed and reopened, the agent starts from zero, losing all previous context.
If the agent is interrupted mid-task, it has no way of knowing where it stopped, leading to potential rework.
Four methods can fix the agent's memory problem and maintain context across tasks and sessions.
Instruct the agent to write a progress note after every major step, detailing what was done, decided, and needs to happen, to restore full context in new sessions.
Ask the agent to summarize its current status every 10 to 15 messages to compress context and prevent overflow.
Before conversations become too long, ask the agent to compress everything into a short summary and continue from there to keep the thread intact.
Add key facts that the agent always needs directly to the system prompt in the bot code, ensuring this information is always in context.
A prompt is provided for the agent to write a brief checkpoint, covering completed items, key decisions, remaining tasks, and necessary context for continuation, under 200 words.
A specific format is provided for the memory note to be written after each major step, including what was done, key decisions, current state, and next steps.
A prompt for resuming a task from a previous session instructs the agent to confirm understanding, identify the next step, and ask questions based on a pasted memory note.
A prompt is provided for compressing a long conversation into a summary of the original goal, what has been done, what was found, and key decisions made.