Chat with your stateful AI agent with long-term memory in your n8n workflows using a Telegram bot.
demo.mp4
This document covers installation, credentials, and workflow implementation.
We are assuming you have basic familiarity with n8n and Telegram bots.
- n8n v1.0.0+ (Cloud or self-hosted).
- A Telegram bot and its API token (from BotFather).
- Letta account (Cloud or self-hosted) and an API token.
- A Letta Agent ID (e.g.,
agent-90009dba-8012-46c5-a0f5-5630cc457363).
(Click to expand) How to create a Letta agent and get its ID
- In n8n, go to Settings → Community Nodes → Install.
- Enter
@letta-ai/n8n-nodes-lettaand confirm.
- In the n8n root directory:
npm install @letta-ai/n8n-nodes-letta- If you run n8n with Docker, add to your
.envbeforeN8N_CUSTOM_EXTENSIONS, like this:
N8N_CUSTOM_EXTENSIONS=@letta-ai/n8n-nodes-letta
Then rebuild/restart n8n.
- Open the Credentials screen → New → choose Letta API.
-
Fill in:
- API Token: your Letta token (from the Letta dashboard).
- Base URL:
https://api.letta.com(or your self-hosted URL).
Where to get the token: Letta dashboard → API settings → generate token.
You can create a workflow that listens for new Telegram messages and forwards them to your Letta agent, then sends the agent's response back to the user.
- Create a new workflow in n8n.
- Add a Telegram Trigger node:
- Set Resource to
Message. - Set Operation to
Get Updates. - Enter your Telegram bot token.
- Optionally, set Poll Interval (default is 3000 ms).
- Set Resource to
- Add a Letta - Send Message to Agent node:
- Connect it to the Telegram Trigger node.
- Set Credentials to the Letta credentials you created.
- Set Agent ID to your Letta Agent ID.
- Set Message to
{{ $("Telegram Trigger").json.message.text }}.
- Save and activate the workflow.
See the complete workflow example Telegram Letta Chat.
It uses the following sub-workflows:
- TelegramTypingIndicator: shows a "Typing..." message indicator on main workflow execution.
- TelegramRecordingIndicator: shows a "Recording..." audio indicator on main workflow execution.
- TelegramProdHookRegister: registers a webhook for production use.
^ You may want to run this workflow to set up the Telegram production webhook for your bot, so you don't have to manually poll for updates (aka clicking "Execute Workflow" like a Cookie Clicker game :P).
- Telegram Trigger node may not work properly with webhooks in some n8n versions. If you experience issues, consider using polling mode or refer to Common Issues for troubleshooting.
- Typing and recording indicators may not display correctly if the main workflow takes too long to process. Refer to this community post for solutions.
- Filtering bots commands (e.g.,
/start,/help, etc...) is not implemented in the sample workflow. You may want to add logic to ignore such commands in your workflow. - Audio message transcription requires integration with a speech-to-text service, which is not covered in the sample workflow.
- Letta community node may have limitations or bugs
- https://github.com/letta-ai/n8n-nodes-letta
- https://core.telegram.org/api
- https://www.npmjs.com/package/n8n-nodes-globals
- https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.telegramtrigger/common-issues/
- https://community.n8n.io/t/how-to-make-telegram-action-typing-work-while-ai-agent-processing/69149/5








