Published on

Building Your First n8n Automation: Sending Telegram Messages

Authors

If you're looking to dip your toes into workflow automation, creating a Telegram message sender with n8n is the perfect starter project. In this guide, I'll walk you through setting up a simple yet powerful automation that sends messages to Telegram on a schedule.

What You'll Need

Step 1: Create Your Telegram Bot

First, let's set up a Telegram bot that will send your messages:

  1. Open Telegram and search for @BotFather
  2. Send the command /newbot and follow the instructions
  3. Give your bot a name and username when prompted
  4. Important: Copy the bot token you receive - you'll need this later!

Step 2: Get Your Telegram Chat ID

To send messages to yourself, you need your chat ID:

  1. Start a conversation with your newly created bot in Telegram (send any message)
  2. Open this URL in your browser (replace YOUR_TOKEN with your actual bot token):
    https://api.telegram.org/botYOUR_TOKEN/getUpdates
    
  3. Look for the chat.id field in the JSON response and copy that number

Step 3: Set Up n8n Using Docker Compose

Let's get n8n running with Docker Compose:

docker-compose.yml
    version: '3.1'

    services:
    n8n:
        image: n8nio/n8n
        ports:
        - 5678:5678
        volumes:
        - ~/.n8n:/home/node/.n8n
        environment:
        - TELEGRAM_BOT_TOKEN=your_bot_token
  1. Create a docker-compose.yml file with the content above
  2. Replace your_bot_token with the token you received from BotFather
  3. Open your terminal and run:
    docker-compose up -d
    
  4. Access the n8n dashboard at http://localhost:5678

Step 4: Build Your Telegram Message Workflow

Now let's create your first automation workflow:

  1. Add a Cron Node (this will trigger your workflow)

    • Set the trigger frequency (every minute for testing, or customize as needed)
    • For a one-time test, you can keep the default settings
  2. Add a Telegram Node

    • Select Resource: Message Select-tele-node
    • Operation: Send Message
    Send-Message
    • Enter your Chat ID (from Step 2)
    • Type your message text: Hello from n8n! 🚀
    • Enter your Bot Token (from Step 1)
    Setting-Message
  3. Connect the Nodes

    • Draw a connection from the Cron node to the Telegram node
  4. Test Your Workflow

    • Click the Execute Workflow button to run a test

      Setting-Message
    • Check your Telegram - you should receive the message! Setting-Message
  5. Activate the Workflow (Optional)

    • If you want this to run automatically based on your trigger, click the Activate toggle

Next Steps and Customizations

Once you have the basic workflow running, you can enhance it by:

  • Adding dynamic content to your messages
  • Connecting to other services like weather APIs, RSS feeds, or databases
  • Creating conditional logic for when to send messages
  • Adding more nodes to create complex workflows

Troubleshooting Tips

  • If you don't receive messages, double-check your bot token and chat ID
  • Make sure you've started a conversation with your bot in Telegram
  • Check the n8n execution logs for any errors

That's it! You've successfully created your first n8n automation workflow that sends messages to Telegram. This simple project demonstrates the power of n8n for creating custom automations without complex coding.

What automation will you build next?

Last updated: Thursday, April 17, 2025