DEV Community

Cover image for Building Telegram Automation Workflows with n8n and Pinggy Webhooks
Lightning Developer
Lightning Developer

Posted on

Building Telegram Automation Workflows with n8n and Pinggy Webhooks

Automation workflows are increasingly vital for developers and modern businesses. Telegram, with its versatile Bot API, offers an excellent way to interact with users, while n8n enables flexible, no-code/low-code automation workflows. But a common challenge arises when building Telegram bots locally: Telegram only accepts HTTPS webhook endpoints, while local servers like n8n typically run on HTTP. This is where Pinggy comes in as a secure tunneling service that exposes your local n8n instance to the web with HTTPS support.

In this guide, we’ll walk through integrating Telegram with n8n using Pinggy to handle webhooks securely and effortlessly during local development.

Why Use n8n with Telegram?

Combining Telegram with n8n allows you to automate processes like:

  • Responding to messages instantly
  • Collecting user data from chats
  • Sending alerts or updates to users
  • Interfacing with CRMs, databases, or AI models
  • Powering chatbots without spinning up a full backend service

The visual nature of n8n workflows makes it accessible for developers and non-developers alike, while still supporting custom scripting for complex logic.

Prerequisites

Before you begin, make sure the following tools are set up:

  • Node.js (version 16 or above)
  • npm (comes bundled with Node.js)
  • SSH client (for Pinggy tunneling)
  • Telegram Bot token (generated via @BotFather)

chat with god bot

  • n8n (installed via npm or Docker)
  • Pinggy (no installation required—just an SSH command) pinggy

Step 1: Create a Telegram Bot

To get started, you'll need a bot:

  1. Open Telegram and search for @BotFather.
  2. Send the /newbot command and follow the prompts to set a name and username.

    new chat

  3. BotFather will respond with an API token. Keep it secure—you'll need it shortly.

bot_name

bot token

Step 2: Tunnel n8n Locally Using Pinggy

Since Telegram requires an HTTPS endpoint for webhooks, you’ll need to expose your local n8n server. Pinggy allows you to do that with a single command:

ssh -p 443 -R0:localhost:5678 qr@free.pinggy.io
Enter fullscreen mode Exit fullscreen mode

pinggy

This command sets up a reverse tunnel and gives you a public HTTPS URL like:

https://random-name.a.pinggy.link
Enter fullscreen mode Exit fullscreen mode

Use this link as your webhook endpoint. No SSL setup, no third-party clients—just standard SSH.

Step 3: Install and Run n8n

You can install and run n8n in two ways:

Option A: Using npm

npm install -g n8n
WEBHOOK_URL="https://your-pinggy-url.a.pinggy.link" n8n start
Enter fullscreen mode Exit fullscreen mode

n8n through pinggy

Make sure to replace the URL with your actual Pinggy link. Setting the WEBHOOK_URL environment variable ensures Telegram knows where to send messages.

Option B: Using Docker

docker run -it --rm --name n8n \
  -p 5678:5678 \
  -e WEBHOOK_URL="https://your-pinggy-url.a.pinggy.link" \
  n8nio/n8n
Enter fullscreen mode Exit fullscreen mode

Navigate to http://localhost:5678 in your browser to access n8n’s interface.

Step 4: Configure Telegram Integration in n8n

Once n8n is running, it’s time to build the Telegram automation workflow:
start

  1. Create a new workflow in the n8n dashboard.
  2. Add a Telegram Trigger node.

    pinggy url

  3. Click “Create New Credential” and paste your bot token.

    credentials

  4. Save the node. You’ll now see a generated webhook path.
    1st node

    Step 5: Register Telegram Webhook

Now, connect your bot to n8n using Telegram’s API.

add api key

Replace the placeholders and use the following format:

https://api.telegram.org/bot<your_bot_token>/setWebhook?url=<your_webhook_url>
Enter fullscreen mode Exit fullscreen mode

Example:

https://api.telegram.org/bot123456:ABCdefGhIJK/setWebhook?url=https://example.pinggy.link/webhook-test/uuid/webhook
Enter fullscreen mode Exit fullscreen mode

Send this URL from your browser or using a tool like Postman. If successful, Telegram will respond with:

{"ok":true,"result":true,"description":"Webhook was set"}
Enter fullscreen mode Exit fullscreen mode

pinggy postman

Step 6: Add a Response Node

After the trigger, add a Telegram node to reply to incoming messages:

  • Resource: Message
  • Operation: Send Message
  • Chat ID: ={{$json["message"]["chat"]["id"]}}
  • Text: Your response (e.g., “Hello, your message was received!”)

adding node2

Step 7: Test the Automation

Now run the workflow:

  1. Click Execute Workflow in n8n. execute
  2. Open Telegram and send a message to your bot (e.g., /start).
  3. The bot should reply instantly. test
  4. Confirm execution logs in n8n to verify message flow.

If everything works, you’ve successfully integrated Telegram with a locally running n8n instance using Pinggy.

Use Cases You Can Explore

With this setup, you can quickly prototype or deploy:

  • Auto-responders for customer service
  • Order tracking bots
  • Internal team alerts
  • Contact forms that collect and store user info
  • AI assistants using external APIs

As your requirements grow, n8n's rich node ecosystem allows integrations with Google Sheets, Notion, GitHub, OpenAI, and more.

Conclusion

Setting up a Telegram bot with a local n8n instance used to be a hassle due to HTTPS constraints. With Pinggy in the mix, those roadblocks vanish. Whether you're building a support system, data collection tool, or chatbot prototype, this approach makes development faster and easier.

Start with simple flows, refine the UX, and let your workflows grow organically. As always, keep your bot tokens secure, and don't forget to clean up old tunnels when done.

Now go automate something cool.

References

  1. n8n Telegram Integration with Pinggy
  2. Self-Host AI Agents Using n8n and Pinggy
  3. How to Set Up and Test Telegram Bot Webhook

Top comments (0)