Create and Manage Short URLs with Telegram Bot, MongoDB and Nginx Redirects — n8n Workflow

High complexity Trigger22 nodes🏷️ Miscellaneousby Rudi Afandi

Overview

This workflow contains community nodes that are only compatible with the self-hosted version of n8n.

This workflow allows you to create and manage custom short URLs directly via Telegram, with all data stored in MongoDB, and redirects handled efficiently via Nginx.

How it works This flow provides a seamless URL shortening experience:

Create via Telegram: Send a long URL to your bot. It will ask if you want a custom short code.

Store in MongoDB: All long URLs and their corresponding short cod

Nodes used

TelegramMongoDBCode

Workflow Preview

Validating
Link not valid
Creating new link
Handle Redirects
Link exist, ask another one
Workflow 1: Create Short URL
I. Main Message & Reply Detection
- Telegram Trigger: Receives all Telegram messages.
- Is it Reply? (IF): Checks if message is a reply.
- True: Reply (-> Code)
- Fal
Workflow 2: URL Redirect Handler
- Webhook (Webhook Trigger): Receives short URL request
- Data2 (Set): Extracts short code from webhook URL.
Exist?2 (MongoDB - Find): Finds orig
T
Telegram Trigger
Insert shortCode
New link
Exist?
N
no exist?
E
exist?
W
Webhook
I
Is it reply?
R
Reply Data
askShortCode
Clean Data
askShortCode1
V
Valid URL
take URL
N
Not Valid URL?
Not Valid URL1
T
take short code
short code exist?
S
short code exist?1
I
If short code exist
4
404 page
S
shortCode Data
22 nodes20 edges

How it Works

  1. 1

    Trigger

    The workflow starts with a trigger trigger.

  2. 2

    Process

    Data flows through 22 nodes, connecting code, if, mongodb.

  3. 3

    Output

    The workflow completes its automation and delivers the result to the configured destination.

Node Details (22)

TE

Telegram

telegram

#1
MO

MongoDB

mongoDb

#2
CO

Code

code

#3

How to Import This Workflow

  1. 1Click Download JSON button on the right to save the workflow file.
  2. 2Open your n8n instance. Go to Workflows → New → Import from file.
  3. 3Select the downloaded create-and-manage-short-urls-with-telegram-bot-mongodb-and-nginx-redirects file and click Import.
  4. 4Set up credentials for each service node (API keys, OAuth, etc.).
  5. 5Click Test Workflow to verify everything works, then activate it.

Or paste directly in n8n → Import from JSON:

{ "name": "Create and Manage Short URLs with Telegram Bot, MongoDB and Nginx Redirects", "nodes": [...], ...}

Integrations

codeifmongodbrespondtowebhooksettelegramtelegramtriggerwebhook

Get This Workflow

Download and import in one click

Download JSONView on n8n.io
Nodes22
Complexityhigh
Triggertrigger

Created by

Rudi Afandi

Rudi Afandi

@fanfanra

Tags

codeifmongodbrespondtowebhooksettelegramtelegramtriggerwebhook

New to n8n?

n8n is a free, open-source workflow automation tool. Self-host it or use the cloud version.

Get n8n Free →

Related Miscellaneous Workflows