Want to build a personal assistant that lives in your pocket, understands your voice, and helps you with daily tasks? With an n8n Telegram bot powered by Google Gemini, you can create a surprisingly powerful AI assistant without writing a single line of code. This isn't just another simple auto-reply bot; this is a conversational AI that can remember your chats, answer complex questions, and even send you proactive updates.
This tutorial is for Bangladeshi marketers, small business owners, students, or anyone curious about AI automation. We will guide you through every step, from creating your bot in Telegram to building a sophisticated workflow in n8n that handles both text and voice commands. In about 60-90 minutes, you will have a working AI assistant, with costs being minimal to none thanks to the generous free tiers of the tools involved.
- What you'll build: A personal AI assistant on Telegram.
- Tools you'll use: n8n, Telegram, and Google Gemini.
- Key features: Handles text and voice, remembers conversations, and sends proactive messages.
- Time to complete: 60-90 minutes.
- Cost: Free or very low cost, depending on usage.
Table of Contents
- Prerequisites: What You Need to Get Started
- Building Your AI Assistant: A Step-by-Step Guide
- Common Errors and How to Fix Them
- Your Pre-Launch Checklist
- Frequently Asked Questions
- Next Steps
- Related Reading
- Sources
Prerequisites: What You Need to Get Started
Before we dive into building our n8n Telegram bot, you need to have a few things ready. Having these prepared will make the process smooth and straightforward. You won't need to spend any money upfront, but you will need accounts for the following services.
- A Telegram Account: You'll need the Telegram app on your phone or desktop to create and interact with your bot.
- An n8n Instance: n8n is the automation engine where we'll build the logic. You can use n8n Cloud (which has a free tier) or self-host it for full control. For a detailed guide on setting up your own instance, check out this step-by-step tutorial on how to self-host n8n on a VPS.
- A Google AI Studio API Key: This key allows your bot to access the powerful Google Gemini language model. You can get one for free from the Google AI Studio website.
Building Your AI Assistant: A Step-by-Step Guide
Now for the exciting part. We will build the workflow from the ground up. Follow these steps carefully, and you'll have your AI assistant running in no time. We will start with the basics and then add more advanced features like voice handling and memory.
Step 1: Create Your Telegram Bot with BotFather
First, you need to register your bot with Telegram. This is done by talking to a special bot called the "BotFather".
- Open Telegram and search for the user
@BotFather(make sure it has a blue checkmark). - Start a chat and type
/newbot. - BotFather will ask for a name for your bot. This is the display name, like "My AI Assistant".
- Next, it will ask for a username. This must be unique and end in "bot", for example,
MyAIAssistant2026_bot. - Once successful, BotFather will give you a long string of characters. This is your HTTP API token. It's very important, so copy it and keep it safe. We'll need it in the next step.
Step 2: Set Up the n8n Workflow and Telegram Trigger
This is where we start building the automation in n8n. The trigger node is what starts your workflow when a new message is sent to your bot.
- In your n8n canvas, click the '.+' button to add a new node and search for "Telegram Trigger".
- In the Telegram Trigger node settings, click on "Credential to connect with" and select "Create New".
- Give your credential a name (e.g., "My Telegram API") and paste the HTTP API token you got from BotFather into the "Access Token" field. Click "Save".
- n8n will now display a Webhook URL. Copy this URL.
- Go back to BotFather in Telegram and use the command
/setwebhook. Select your bot, and then paste the n8n webhook URL. Telegram will confirm that the webhook was set. - Finally, in the n8n Telegram Trigger node, under the "Updates" field, make sure
messageis checked. Now, click "Test step" to put n8n in a "listening" state. Send any message to your new bot on Telegram. The data should appear in n8n!
Step 3: Handle Incoming Text and Voice Messages
A true assistant should understand more than just text. Here, we'll add the logic to process both regular text messages and voice notes. For this, we'll use a Switch node to direct the workflow and the OpenAI Whisper node for transcription.
- Add a "Switch" node connected to your Telegram Trigger. Set the "Mode" to "Rules".
- For the first output (Rule 1), we will check for a text message. Set "Value 1" to the expression
{{ $json.message.text }}. Set the "Operation" to "Is Not Empty". - Add a second output (Rule 2) to check for a voice message. Set "Value 1" to
{{ $json.message.voice }}and the "Operation" to "Is Not Empty". - Now, let's handle the voice. Add an "OpenAI" node and connect it to the second output of the Switch node. Select "Whisper" as the model. You will need to add your OpenAI API credential.
- In the OpenAI node, set the "Operation" to "Audio Transcriptions". Under "File to Process", select "Get from a URL". For the "File URL", we need to construct the file path using an expression. Add an "HTTP Request" node before the OpenAI node to get the file path from the Telegram API. Then, in the OpenAI node, get the file using the Telegram Bot API file URL and the file path.

Step 4: Add Conversational Memory
For your assistant to feel intelligent, it needs to remember the context of your conversation. A simple bot answers every question as if it's the first one. An AI assistant remembers what you last said. We'll use n8n's built-in memory for this.
- Add a "Chat Memory (Overwrites)" node. Connect both the "text" output from the Switch node and the output from your "Whisper" transcription node to its input.
- In the "User Message" field, you need to use an expression to get the message from whichever path was taken:
{{ $json.message.text || $items("OpenAI")[0].json.text }}. This expression tells the node to use the incoming text, or if that doesn't exist, use the transcribed text from the Whisper node. - Set a "Session ID". This is crucial for keeping conversations separate. A good session ID is the chat ID from Telegram:
{{ $json.message.chat.id }}.
Step 5: Connect to Google Gemini
Now it's time to connect our bot's "brain". We'll send the user's message, along with the conversation history, to Google Gemini for a response.
- Add a "Google Gemini" node and connect it to the output of the Chat Memory node.
- Create a new credential and paste in your Google AI Studio API key.
- In the "Prompt" field, we will use the output from our memory node. Use the expression:
{{ $json.prompt }}. This passes the user's latest message and the recent conversation history to the AI. - You can leave the other settings as default for now, but feel free to experiment with the "Temperature" later to make the responses more creative or factual.
Step 6: Send the AI's Response Back to Telegram
The final step in our main workflow is to take the response from Gemini and send it back to the user in Telegram.
- Add a "Telegram" node (this is an action node, not the trigger). Connect it to the output of the Google Gemini node.
- Your Telegram credential should already be selected.
- The "Chat ID" should be the same as the one we used for the session ID. Use the expression
{{ $json.message.chat.id }}. - In the "Text" field, use an expression to pull the generated content from Gemini:
{{ $json.candidates[0].content.parts[0].text }}. This navigates the data structure from the Gemini node to find the actual text response. - Test your workflow! Send a message to your bot. You should get a reply from Gemini. Try sending a voice note, too. Then ask a follow-up question to see if it remembers the context.
Step 7 (Bonus): Enable Proactive Daily Briefings
An assistant is even more useful when it tells you things without being asked. Let's create a separate, simple workflow to send a daily news summary.
- Create a new, separate workflow.
- Add a "Cron" node. This node starts a workflow on a schedule. Set it to run at your desired time, for example, every day at 8 AM.
- Add an "RSS Reader" node. Paste the URL of an RSS feed for a news site you follow (e.g., a major Bangladeshi news portal).
- Add a "Google Gemini" node. In the prompt, write something like: "Please summarize the following articles into a few bullet points for my daily briefing: {{ $items('RSS Feed Read')[0].json.items.map(item => item.title + ': ' + item.contentSnippet).join('\n\n') }}".
- Finally, add a "Telegram" node. In the "Chat ID" field, you must paste your personal Telegram Chat ID (you can find this by inspecting the data from your main workflow). In the "Text" field, put the response from the Gemini node.
- Activate this workflow. Now, you'll get a custom news summary every morning!

Common Errors and How to Fix Them
Even with a visual builder, things can sometimes go wrong. Here’s a quick table of common issues you might face with your telegram ai bot and how to resolve them.
| Error | Common Cause | Solution |
|---|---|---|
| Webhook not registering or "404 not found" on trigger. | The n8n workflow is not active, or the webhook URL is incorrect. | Ensure your workflow is saved and activated (toggle switch in the top right). Double-check that the URL you pasted into BotFather is the exact one from the n8n Telegram Trigger node. |
| Gemini node shows an "API key invalid" error. | The key was copied incorrectly or is not enabled for the Gemini API. | Go back to Google AI Studio, generate a new key, and carefully copy and paste it into your n8n credential. Ensure the project has the Generative Language API enabled. |
| The bot replies with an empty message. | The expression in the final Telegram node is incorrect. | Check the output of the Gemini node in a test execution. The path to the text might have changed. The correct expression is likely {{ $json.candidates[0].content.parts[0].text }}. |
| Voice messages don't work. | The file path expression is wrong, or the OpenAI credential is invalid. | Ensure your OpenAI API key is correct and has billing set up (transcription is not free). Verify the expressions used to get the file from Telegram's API. |
Your Pre-Launch Checklist
Before you activate your workflow and let your new assistant run wild, go through this quick checklist:
- ✅ All credentials (Telegram, Google Gemini, OpenAI) are correctly entered and saved.
- ✅ The Telegram Trigger webhook is successfully registered with BotFather.
- ✅ The expressions for Chat ID, user message, and Gemini response are correct.
- ✅ The Switch node correctly routes text and voice messages.
- ✅ The Chat Memory node is using the Chat ID as the Session ID.
- ✅ The workflow is saved and the "Active" toggle is switched on.
Frequently Asked Questions
Do I need coding skills to build this n8n Telegram bot?
No, you do not need coding skills. This tutorial uses n8n, a visual workflow builder. You will use expressions to connect data between nodes, but this is much simpler than traditional programming and we provide the exact expressions you need to copy and paste.
Is using n8n and Gemini for this bot free?
The cost can be close to zero. n8n has a free community edition if you self-host. The Google Gemini Pro API has a generous free tier (as of late 2026). Voice transcription with Whisper may have a small cost. For heavy use, you might incur minor API fees, but for a personal assistant, it is extremely affordable.
Can this Telegram AI bot work in group chats?
Yes, it can. When you add your bot to a group, it can read all messages if its privacy mode is disabled (via BotFather). You can then configure your n8n workflow to only respond when the bot is mentioned directly, preventing it from replying to every single message in the group.
How do I find my Telegram Chat ID?
The easiest way is to send a message to your bot and check the data that arrives in the n8n "Telegram Trigger" node. The execution data will contain a `message.chat.id` field. This unique number is your personal chat ID, which you can use to send proactive messages to yourself.
Can I use ChatGPT instead of Google Gemini?
Absolutely. The process is very similar. Instead of the "Google Gemini" node, you would use the "OpenAI Chat" node in n8n. You would then need to get an API key from OpenAI. The rest of the workflow, including the trigger, memory, and sending the message back, remains the same.
Is it safe to put my API keys in n8n?
Yes, n8n is designed to handle credentials securely. When you add a new credential (like your Telegram or Gemini API key), it is encrypted and stored separately from your workflow data. This is much safer than pasting keys directly into your workflow nodes.
What is a webhook and why do I need it?
A webhook is a way for one app (Telegram) to send real-time information to another app (n8n). When you set up the Telegram Trigger, n8n generates a unique webhook URL. You register this URL with your Telegram bot, so every time a new message arrives, Telegram instantly sends it to your n8n workflow.
My bot is not responding. What should I do?
First, check that your n8n workflow is active. Second, look at the "Executions" tab in n8n to see if the trigger is receiving data from Telegram. If not, your webhook setup might be wrong. If it is receiving data, click on the execution to see which node failed and what the error message is.
Next Steps
Congratulations! You've built a sophisticated n8n ai agent on Telegram. This is just the beginning of your journey into AI automation for your business or personal life. Here’s what you can do next:
- Customize Your Assistant's Personality: Go to the Google Gemini node and add a system prompt. Tell the AI to act as a formal business assistant, a friendly helper, or a witty expert. This dramatically changes the tone of its responses.
- Integrate More Tools: Connect your bot to other applications. Use the Google Calendar node to have your bot schedule meetings, a Google Sheets node to log expenses, or a Todoist node to manage your tasks, all through chat. This is one of the most powerful business automation ideas to implement.
- Build a Customer-Facing Bot: Apply these principles to build a chatbot for your business. It could answer customer questions, qualify leads, or provide 24/7 support on your company's Telegram channel. Understanding the potential costs is a good next step, which you can learn about in this guide on n8n automation costs in Bangladesh.
Feeling overwhelmed or want to build a more complex, enterprise-grade solution? As an AI automation specialist, I can help you design and implement custom workflows that save you time and money. Book a free consultation today to discuss your automation needs.
Related Reading
- n8n Automation Cost in Bangladesh: What to Expect to Pay
- AI Automation for Small Business in Bangladesh: Complete 2026 Guide
- Business Automation Ideas: 10 Things to Automate First (and 5 to Never Automate)
Sources
- Telegram bot starter template setup & AI agent chatbot
- Telegram integrations | Workflow automation with n8n
- Creating Telegram Bots with n8n, a No-Code Platform
- n8n Telegram integration: Set up, automate, and scale bots
- How to build an n8n Telegram bot with AI - IONOS
Checked on 2026-10-24.




