How to Build a Telegram Bot with n8n (No Code Required)

n8n #n8n#telegram#bot#nocode#automation
How to Build a Telegram Bot with n8n (No Code Required)

What You’ll Need

  • n8n Cloud or self-hosted n8n (running on Hetzner VPS , Contabo VPS , or DigitalOcean )
  • A Telegram account and bot token (created via BotFather)
  • Basic understanding of webhooks and HTTP requests
  • 15 minutes of setup time

Table of Contents

  1. Getting Your Telegram Bot Token
  2. Setting Up n8n for Telegram
  3. Building Your First Message Workflow
  4. Adding Conditional Logic and Responses
  5. Testing and Deploying
  6. Getting Started

Getting Your Telegram Bot Token

I always start here because without a valid bot token, nothing else works. Here’s the fastest way:

Open Telegram and search for @BotFather. This is Telegram’s official bot creation tool. Send the message /newbot and follow the prompts:

  1. Give your bot a name (example: “My Automation Bot”)
  2. Give it a username ending in _bot (example: my_automation_bot)
  3. BotFather will return your HTTP API Token—copy this immediately and save it somewhere secure

Your token looks like this: 123456789:ABCDefGhIjKLmnOpQRstUVwxYZ1234567890

Keep this token private. Anyone with it can control your bot.


Setting Up n8n for Telegram

Now let’s connect n8n to Telegram. I’ll show you two approaches: the quick way using n8n Cloud , and the self-hosted option if you’re running n8n on Hetzner VPS or another server.

For n8n Cloud:

  1. Log into your n8n account
  2. Create a new workflow (click + and select New Workflow)
  3. Search for the Telegram node in the left sidebar
  4. Click on the Telegram node to add it to your canvas
  5. Click Create New Credential and paste your bot token
  6. Select the action: Send Message

For self-hosted n8n (if you’ve deployed n8n on a VPS using our VPS setup guide ), the process is identical—the Telegram node is built-in.

Here’s what your credential configuration looks like:

{
  "accessToken": "123456789:ABCDefGhIjKLmnOpQRstUVwxYZ1234567890"
}

Don’t manually enter JSON—use the UI form. The token field is all n8n needs to authenticate.


Building Your First Message Workflow

Let’s build something useful: a workflow that sends a message to your Telegram whenever it’s triggered.

  1. Create a new workflow in n8n
  2. Add a Webhook node as the trigger (this lets external services or your own apps ping n8n)
  3. Add a Telegram node set to Send Message
  4. Connect the Webhook to the Telegram node

Here’s the configuration for each node:

Webhook Node:

  • Set the method to POST
  • Copy the webhook URL that n8n generates
  • Name it something memorable like telegram-trigger

Telegram Node: Set up these fields:

Chat ID: {{ $json.chatId }}
Text: {{ $json.message }}

The $json.chatId and $json.message are placeholders—they’ll be replaced with actual values from your webhook payload.

Now, to test it, click Execute Workflow (the play button). Then send a test request to your webhook URL with this JSON body:

{
  "chatId": "-1001234567890",
  "message": "Hello from n8n!"
}

You can use curl to send this:

curl -X POST https://your-n8n-instance.com/webhook/telegram-trigger \
  -H "Content-Type: application/json" \
  -d '{"chatId":"-1001234567890","message":"Hello from n8n!"}'

Replace your-n8n-instance.com with your actual n8n URL, and replace the chatId with your actual Telegram chat ID (you can find this by messaging your bot and checking the bot’s message history).

💡 Fast-Track Your Project: Don’t want to configure this yourself? I build custom n8n pipelines and bots. Message me with code SYS3-HUGO.


Adding Conditional Logic and Responses

Most real-world bots do more than send messages—they respond based on what users type. Let’s build a bot that echoes messages back.

Create a new workflow:

  1. Add a Webhook node (POST method)
  2. Add an IF node for conditional logic
  3. Add a Telegram node to send the response
  4. Add another Telegram node for the fallback case

Configure the Webhook to receive Telegram updates. Instead of manually pinging your webhook, we’ll use Telegram’s built-in webhook feature. Go back to BotFather, message it with /setwebhook, select your bot, and provide your n8n webhook URL.

Webhook Node Configuration:

Keep it simple—just accept POST requests. Telegram will send your bot’s updates to this URL in this format:

{
  "update_id": 123456789,
  "message": {
    "message_id": 1,
    "date": 1704067200,
    "chat": {
      "id": -1001234567890,
      "type": "private"
    },
    "from": {
      "id": 987654321,
      "first_name": "John",
      "username": "johndoe"
    },
    "text": "hello bot"
  }
}

IF Node:

Add a condition to check if the message contains the word “ping”:

Condition: message contains "ping"

In the IF node’s expression editor:

{{ $json.message.text.toLowerCase().includes('ping') }}

True Branch (Telegram Node):

Send a “Pong!” response:

Chat ID: {{ $json.message.chat.id }}
Text: Pong! You said: {{ $json.message.text }}

False Branch (Telegram Node):

Send a default message:

Chat ID: {{ $json.message.chat.id }}
Text: I didn't understand that. Try saying "ping".

This workflow now receives Telegram messages, checks their content, and responds accordingly.


Testing and Deploying

Before going live, test your workflow thoroughly:

  1. Save the workflow (Ctrl+S or Cmd+S)
  2. Enable it by clicking the toggle switch in the top-right
  3. Use your Telegram bot to send test messages
  4. Check n8n’s execution history to see logs and debug any errors

If you’re running self-hosted n8n on a VPS (like our Hetzner VPS guide ), make sure:

  • Your firewall allows inbound traffic on port 443 (HTTPS)
  • Your domain is properly configured with an SSL certificate
  • Your n8n instance is running and accessible

For production workflows involving AI responses, consider which LLM to use. If you’re unsure whether to use Claude or OpenAI for your automation, our guide on Claude Haiku vs GPT-4o Mini for automation pipelines walks through the decision.

Deployment Checklist:

  • Telegram webhook URL is set in BotFather
  • n8n workflow is enabled
  • All credentials are securely stored
  • Webhook URL matches your n8n instance URL
  • Test messages are processed and logged

Getting Started

Ready to build? Here’s your launch sequence:

  1. Get your bot token from BotFather in Telegram
  2. Choose your n8n platform: n8n Cloud for instant setup or self-hosted on Hetzner VPS , Contabo VPS , or DigitalOcean
  3. Add the Telegram node and paste your token
  4. Set up your webhook to receive Telegram updates
  5. Build conditional logic using IF nodes
  6. Test thoroughly before enabling in production

For decision-makers weighing hosting options, I compare self-hosted n8n vs n8n Cloud in detail—helpful if you’re torn between managed and DIY.

Outsource Your Automation

Don’t have time? I build production n8n workflows, WhatsApp bots, and fully automated YouTube Shorts pipelines. Hire me on Fiverr — mention SYS3-HUGO for priority. Or DM at chasebot.online .

Your Telegram bot is now ready to handle messages, respond intelligently, and integrate with the rest of your automation stack. From here, you can add database lookups, send notifications, trigger other services, or build multi-step workflows that feel like magic to your users.

Want to automate this yourself?

Start with n8n Cloud (free tier available) or self-host on a Hetzner VPS for full control.

📬 Get Weekly Automation Tips

One email per week with tutorials, tools, and workflows. No spam, unsubscribe anytime.

Subscribe Free →