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)
- n8n (installed via npm or Docker)
-
Pinggy (no installation required—just an SSH command)
Step 1: Create a Telegram Bot
To get started, you'll need a bot:
- Open Telegram and search for
@BotFather
. -
Send the
/newbot
command and follow the prompts to set a name and username. BotFather will respond with an API token. Keep it secure—you'll need it shortly.
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
This command sets up a reverse tunnel and gives you a public HTTPS URL like:
https://random-name.a.pinggy.link
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
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
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:
- Create a new workflow in the n8n dashboard.
-
Add a Telegram Trigger node.
-
Click “Create New Credential” and paste your bot token.
-
Save the node. You’ll now see a generated webhook path.
Step 5: Register Telegram Webhook
Now, connect your bot to n8n using Telegram’s API.
Replace the placeholders and use the following format:
https://api.telegram.org/bot<your_bot_token>/setWebhook?url=<your_webhook_url>
Example:
https://api.telegram.org/bot123456:ABCdefGhIJK/setWebhook?url=https://example.pinggy.link/webhook-test/uuid/webhook
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"}
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!”)
Step 7: Test the Automation
Now run the workflow:
- Click Execute Workflow in n8n.
- Open Telegram and send a message to your bot (e.g.,
/start
). - The bot should reply instantly.
- 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.
Top comments (0)