DEV Community

Bitpixelcoders
Bitpixelcoders

Posted on

How to Create an n8n Telegram Workflow (Step-by-Step Guide)

Telegram automation has become one of the most powerful ways to build chatbots, notifications, AI assistants, and automated customer support systems. With n8n, you can visually create automation workflows without writing complex backend code. In this tutorial, you'll learn how to create a Telegram workflow in n8n step by step. We will connect a Telegram bot with n8n, automate message handling, and send automated replies. This guide is beginner-friendly and follows a documentation style similar to the official n8n tutorials.

What You'll Build:-
By the end of this tutorial, you will have:

  • A working Telegram bot
  • An n8n automation workflow
  • Automated Telegram message replies
  • Telegram Trigger integration
  • Telegram Send Message automation

Requirements
Before starting, make sure you have:

  • An n8n account or self-hosted n8n instance
  • A Telegram account
  • Access to BotFather on Telegram
  • Basic understanding of workflows

Official n8n website:
https://n8n.io
Step 1: Create a Telegram Bot
Telegram bots are created using BotFather.

Create the Bot

  1. Open Telegram.
  2. Search for BotFather
  3. Open the verified BotFather account
  4. Send the following command: /newbot
  5. Enter your bot name
  6. Enter a unique bot username

After setup, BotFather will generate a Telegram Bot API token.
Example: 123456789:AAxxxxxxxxxxxxxxxxxxxxx

Save this token because you’ll use it inside n8n.

Step 2: Open n8n Dashboard
Now open your n8n dashboard.
Create Workflow

  1. Click Create Workflow
  2. Rename the workflow
  3. Open the workflow editor

You'll now see the empty workflow canvas.
The workflow editor is where you connect automation nodes visually.

Step 3: Add Telegram Trigger Node
The Telegram Trigger node listens for incoming Telegram messages.

Add Node

  • Click the + button
  • Search: Telegram Trigger
  • Add the node to the canvas

Configure Trigger
Inside the node:

  • Updates → message
  • Credentials → Telegram API


This node will activate whenever someone sends a message to your Telegram bot.

Step 4: Add Telegram Credentials
Now connect Telegram with n8n.
Create Credentials

  • Open Telegram Trigger node
  • Click Credentials
  • Select: Create New Credential
  • Paste Telegram Bot API token
  • Save credentials

If configured correctly, the red warning icon disappears.

Step 5: Add AI Agent Node
The AI Agent node is the brain of the workflow.
Add AI Agent

  1. Click +
  2. Search: AI Agent

  3. Add node to canvas
    Connect Telegram Trigger → AI Agent
    Configure AI Agent
    Inside the AI Agent node:
    Prompt (User Message) :
    {{ $json.message.text }}

    This sends the Telegram user message into the AI model.

Add System Prompt (System Message):

Example: You are a helpful AI Telegram assistant. Reply professionally and clearly.
The AI Agent will now process user messages intelligently.

Step 6: Add Google Gemini Chat Model
Now connect Gemini AI.

Add Gemini Node:-

  1. Click +
  2. Search: Google Gemini Chat Model
  3. Connect it to AI Agent

Add Gemini Credentials
Get Gemini API key from:
https://aistudio.google.com

Then:

  1. Create Gemini credentials
  2. Paste API key
  3. Save connection

Configure Model
Recommended model: gemini-1.5-pro


This AI model will generate intelligent responses.

Step 7: Add Simple Memory
Memory allows the AI assistant to remember previous conversations.

Add Memory Node

  1. Search: Simple Memory
  2. Connect to AI Agent Memory input

This enables conversational context.
Example:

  • User asks first question
  • AI remembers previous messages
  • Future replies become smarter

Step 8: Add Google Sheets Nodes
Now we'll save user data into Google Sheets.

Add Create Sheet Node
Search: Create Sheet in Google Sheets

This creates a spreadsheet automatically.

Add Get Row Node
Search: Get Row(s) in Google Sheets

Used for retrieving stored data.

Add Update Row Node
Search: Google Sheets tool(Update Row)

Used for updating conversation records.

Why Use Google Sheets?

Google Sheets helps:

  • Save user messages
  • Store chatbot history
  • Create AI logs
  • Manage leads
  • Build CRM automations

Step 9: Add Telegram Send Message Node
Now send AI-generated replies back to Telegram.

Add Node
Search: Telegram → Send Message and Wait for Response
Connect:
AI Agent → Telegram Send Message
Configure Message
Use AI output as message text.
Example expression:
{{ $json.output }}

This sends the AI-generated response to Telegram automatically.

Step 10: Connect Complete Workflow

Your workflow should now look like this:

  Telegram Trigger

AI Agent

Telegram Send Message

Connected tools:

  • Gemini AI
  • Simple Memory
  • Google Sheets

Top comments (0)