Skip to content
UsecaseBoard
← All use cases
HashnodePersonal assistant

Put a Claude assistant in a private Telegram chat

At a glance

A Hashnode guide connects Telegram, Claude and n8n to make a chat assistant with per-chat memory. This workflow is listed under Personal assistant, Messaging, Automation.

Agents / tools
Telegram, Claude, n8n

SourceBuilding a tool for these workflows? See weekly rates.

What they did

1) Prepare an n8n instance reachable over public HTTPS, an Anthropic API key and a Telegram account. In Telegram message the verified BotFather with /newbot, choose a display name and username ending in bot, and save its token. 2) In a new n8n workflow add Telegram Trigger, create a Telegram API credential with the token, set Trigger On to Message, test it and send the bot a message. 3) Add AI Agent, set its prompt source to Define below and its user prompt to {{ $json.message.text }}. Connect an Anthropic Chat Model with the API key and a Claude model; add a system message asking for short plain-text answers and an admission when it does not know. 4) Attach Simple Memory to the agent, define its Session ID as {{ $('Telegram Trigger').item.json.message.chat.id }}, and set the context window length to something like 10. After the agent add Telegram / Send a text message, using the same credential, that chat ID for Chat ID and {{ $json.output }} for Text. 5) Find your message.from.id in the trigger output, insert an If node between trigger and agent that checks it equals your user ID, and connect only the true branch to the agent. Save and activate the workflow, then message the bot in Telegram.

Worth knowing

Simple Memory is cleared when n8n restarts. Telegram permits one webhook per bot, so stop editor testing when activating the workflow. Anyone with the bot token can control it; BotFather's /revoke replaces a leaked token.

Save ideas in this browser. Upvotes count across the board.

Prompt excerpt

No prompt excerpt was provided by the source.

Sponsored

CodeBuddy

Tencent Cloud AI coding assistant for IDE and CLI.

Try CodeBuddy ↗
Explore all →