AI-Powered Short Link Generator with Chat Interface
Overview
This workflow creates an intelligent short link generator that users can interact with through a chat interface. It combines an AI agent (powered by OpenAI) with a custom URL shortening service. When a user asks for a short link via the chat, the AI agent understands the request, generates a unique short ID, stores the mapping in a database table, and returns the shortened URL. The workflow also includes a public webhook endpoint that handles redirects when someone visits a short link.
This is particularly useful for teams who want to create branded short links on their own domain without relying on third-party services like bit.ly. The AI chat interface makes it extremely user-friendly — anyone can simply type "Shorten https://example.com" and get a working short link immediately.
Node-by-Node Breakdown
-
When chat message received (Chat Trigger — No auth) — This is the entry point for the AI chat interface. It creates a public webhook URL that users can open in a browser to chat with the AI agent. The
publicparameter is set totrue, meaning no authentication is required to access the chat. -
AI Agent (AI Agent — No auth) — The core orchestrator that processes chat messages. It uses the connected language model and tools to understand user requests and execute actions. The system message is set to "You are a helpful assistant."
-
OpenAI Chat Model (OpenAI Chat Model — API Key auth) — Provides the AI intelligence. Configured to use
gpt-4.1-minimodel. Requires an OpenAI API key credential. -
Simple Memory (Memory Buffer Window — No auth) — Maintains conversation context so the AI agent remembers previous messages in the chat session.
-
Call 'Create Short Link' (Tool Workflow — No auth) — A tool that the AI agent can invoke. It calls the "Create Short Link" sub-workflow (the same workflow, recursively) with the
originalLinkparameter extracted from the user's request. The input is dynamically generated by the AI ($fromAI). -
GenerateShortLink (Execute Workflow Trigger — No auth) — Activated when the sub-workflow is called. It receives the
originalLinkas input (example showshttps://www.nghiaai.dev/). -
Config (Set — No auth) — A configuration node that stores the base URL for your short links. Currently set to
http://localhost:5678— you must change this to your actual n8n instance URL. -
Generate shorlinkId (Code — No auth) — A JavaScript code node that generates a random 4-character alphanumeric string (e.g., "aB3x") to serve as the unique short link identifier.
-
Insert row (Data Table — No auth) — Stores the original link and generated short link ID into a database table named "ShortLink". The table must have columns
originalLinkandshortlinkId. -
Generate ShortLink (Code — No auth) — Constructs the final short URL by combining the base URL from the Config node with the short link ID (e.g.,
http://localhost:5678/webhook/shortLink?a=ab12). -
ShortLink API (Webhook — No auth) — A public webhook endpoint (
/webhook/shortLink) that listens for requests to short links. It expects a query parameteracontaining the short link ID. -
Get row(s) (Data Table — No auth) — Queries the "ShortLink" database table to find the original link matching the requested short link ID.
-
Page Redirect (HTML — No auth) — Generates an HTML page with automatic JavaScript redirect and a meta refresh fallback. It redirects the visitor to the original URL stored in the database.
-
Response (Respond to Webhook — No auth) — Sends the HTML redirect page back to the visitor's browser.
Setup Instructions
Prerequisites
- An n8n instance (self-hosted or cloud)
- An OpenAI API key (get one from platform.openai.com)
- n8n Data Table feature enabled (available in n8n cloud or self-hosted with license)
Step-by-Step Setup
-
Create the database table: In n8n, go to the Data Tables section and create a new table named "ShortLink" with two columns:
originalLink(type: string)shortlinkId(type: string)
-
Configure the base URL: Open the Config node and replace
http://localhost:5678with your actual n8n instance URL (e.g.,https://your-n8n-instance.com). This will be the domain used for your short links. -
Set up OpenAI credentials: Create an OpenAI API credential in n8n (Settings > Credentials > Add > OpenAI). Paste your API key.
-
Activate the workflow: Toggle the workflow to active. The chat interface will be available at the webhook URL shown in the When chat message received node.
-
Test: Open the chat URL in a browser and type "Shorten https://example.com". The AI should respond with a short link like
https://your-n8n-instance.com/webhook/shortLink?a=ab12.
Use Cases and Variations
Primary Use Case
- Internal URL shortener for teams: Create short, memorable links for internal resources, documentation, or meeting links.
- Marketing campaign tracking: Generate short links for different campaigns and track which IDs are being used.
Possible Adaptations
-
Custom short link aliases: Modify the Generate shorlinkId code node to accept user-specified aliases instead of random strings.
-
Add click tracking: Insert a node after Get row(s) to log the visit timestamp and IP address to another table.
-
Slack integration: Replace the chat trigger with a Slack trigger so users can generate short links directly from Slack.
-
QR code generation: Add a node after Generate ShortLink to create a QR code image for the short link.
-
Expiration dates: Add a column to the database for expiration dates and check it in the redirect flow.
-
Multi-user support: Add authentication to the chat interface and track which user created each short link.
Workflow JSON
{
"id": "WmHtnpnkARE1wVqs",
"meta": {
"instanceId": "a0e41110bf9f611e96e18e0663d80d746aeedc58368940bfe471a8d577a5069b",
"templateCredsSetupCompleted": true
},
"name": "AI Agent - Short Link Generator",
"tags": [],
"nodes": [
{
"id": "6c7043d8-e091-4e50-a661-f1047576c565",
"name": "Insert row",
"type": "n8n-nodes-base.dataTable",
"position": [
-16,
-144
],
"parameters": {
"columns": {
"value": {
"orginalLink": "={{ $('GenerateShortLink').item.json.originalLink }}",
"shortlinkId": "={{ $json.shortLinkId }}"
},
"schema": [
{
"id": "orginalLink",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "orginalLink",
"defaultMatch": false
},
{
"id": "shortlinkId",
"type": "string",
"display": true,
"removed": false,
"readOnly": false,
"required": false,
"displayName": "shortlinkId",
"defaultMatch": false
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
// ... truncated (copy to see full JSON)How to Import This Workflow
- 1Copy the workflow JSON above using the Copy Workflow JSON button.
- 2Open your n8n instance and go to Workflows.
- 3Click Import from JSON and paste the copied workflow.
Don't have an n8n instance? Start your free trial at n8nautomation.cloud
Related Templates
YouTube Video Summarizer with Telegram Notification
High-Level Summary This workflow automatically processes YouTube videos by fetching their transcripts, generating a structured AI-powered summary using OpenAI's GPT-4o-mini, and sending the summary along with video metadata to a Telegram chat. It is triggered via a webhook, making it easy to integrate with other tools or services (e.g., a browser extension, a form, or another automation). The workflow is ideal for content curators, researchers, or teams who want to quickly digest video content without watching the full video. Workflow Steps Webhook — Receives an incoming HTTP POST request containing a YouTube URL in the request body. This is the entry point of the workflow. (No auth) Get YouTube URL (Set node) — Extracts the field from the incoming webhook payload and stores it as a string variable for downstream use. (No auth) YouTube Video ID (Code node) — Runs a JavaScript function that parses the YouTube URL using a regex pattern to extract the 11-character video ID (supports both and formats). (No auth) Get YouTube Video (YouTube node) — Uses the extracted video ID to fetch video metadata (title, description, etc.) from the YouTube Data API v3. (OAuth2 — requires a Google Cloud project with YouTube Data API enabled) YouTube Transcript (Community node: ) — Fetches the transcript/captions for the video. This node requires the video ID (passed from the previous step). (No auth — uses public YouTube captions) Split Out (SplitOut node) — Splits the transcript array into individual items so each text segment can be processed separately. (No auth) Concatenate (Summarize node) — Concatenates all transcript text segments into a single string, separated by spaces, to prepare the full transcript for analysis. (No auth) gpt-4o-mini (OpenAI Chat Model node) — Configures the OpenAI language model (GPT-4o-mini) that will be used for summarization. (API Key auth — requires an OpenAI API key) Summarize & Analyze Transcript (LLM Chain node) — Sends the concatenated transcript to the GPT-4o-mini model with a detailed prompt asking for a structured summary with headers, bullet points, bold terms, and tables. The output is a markdown-formatted analysis. (No auth — uses the model configured in the previous node) Response Object (Set node) — Assembles the final output object containing: - : The AI-generated summary text - : An empty array (placeholder for future use) - : The video title from YouTube metadata - : The video description from YouTube metadata - : The YouTube video ID - : The original YouTube URL from the webhook (No auth) Respond to Webhook — Sends the assembled response object back to the original webhook caller (e.g., a browser extension or app). (No auth) Telegram — Sends a message to a specified Telegram chat containing the video title and the YouTube URL. (API Key auth — requires a Telegram Bot Token and chat ID) Setup Instructions To use this workflow, you will need the following accounts and credentials: OpenAI Account: Create an account at platform.openai.com and generate an API key. Add this as a credential in n8n under "OpenAI". Google Cloud Project: Enable the YouTube Data API v3 in your Google Cloud Console, create OAuth 2.0 credentials (Desktop app type), and add them in n8n under "YouTube OAuth2 API". Telegram Bot: Create a bot via @BotFather on Telegram to get a Bot Token. Find your chat ID (e.g., by messaging your bot and visiting ). Add the token as a credential in n8n under "Telegram API". Webhook URL: After activating the workflow, copy the production webhook URL (e.g., ). You will send POST requests to this URL with a JSON body like . Use Cases and Variations Content Curation: Automatically summarize long conference talks, tutorials, or webinars and share them with your team on Telegram. Research Assistant: Collect video transcripts and AI summaries for later reference or database storage. Browser Extension Integration: Pair this workflow with a browser extension that sends the current YouTube URL to the webhook when clicked. Variations: - Replace Telegram with Slack, Discord, or email notifications. - Store summaries in a Google Sheet or Airtable for a searchable archive. - Add a filter to skip videos shorter than a certain duration. - Use a different LLM (e.g., Claude, Gemini) by swapping the OpenAI node. - Add error handling to notify you if a video has no captions.
Telegram to Email Newsletter Automation using Dumpling AI
High-Level Summary This workflow transforms a simple keyword sent via Telegram into a polished, HTML-formatted email newsletter. It leverages Dumpling AI's APIs for search and scraping, OpenAI's language models for content generation, and Gmail for delivery. The automation is ideal for content creators, marketers, or anyone who wants to quickly curate and distribute news on a specific topic without manual research and formatting. Step-by-Step Node Breakdown Start: Receive Keyword from Telegram (Telegram Trigger) — No auth (uses Telegram bot token configured in n8n credentials). Listens for incoming Telegram messages. When a message is received, it passes the message text (the keyword) to the next node. AI Agent: Expand Keyword & Orchestrate Tools (LangChain Agent) — Uses the connected LLM and tools. The system prompt instructs the agent to first call to expand the keyword into popular search terms, then pass those terms to to fetch recent articles. The agent outputs a structured JSON array of articles. LLM: Language Model (OpenAI Chat Model) — API Key auth (OpenAI API key stored in n8n). Provides the language model (GPT-4o-mini) that powers the AI Agent's reasoning and tool selection. Simple Memory (Memory Buffer Window) — Stores conversation context for the AI Agent using the Telegram user's ID as the session key. Google_autocomplete (HTTP Request Tool) — Header Auth (Dumpling AI API key in header). Calls with a POST request containing the keyword. Returns autocomplete suggestions from Google. Search_news (HTTP Request Tool) — Header Auth (Dumpling AI API key in header). Calls with a POST request containing the autocomplete suggestion. Returns recent news articles. Parser: Format News JSON (Output Parser) — Defines a JSON schema that the AI Agent must follow when outputting the final list of articles (with fields: category, title, url, source, summary, published). Split Articles (Split Out) — Splits the array from the agent into individual items, one per article. Loop: Process Each Article (Split In Batches) — Iterates over each article one at a time. For each article, it triggers the Wait node and then the Scraper. Wait (Wait) — No auth. Adds a small delay (configurable) between scraping requests to avoid rate limiting. Scraper: Clean Article Content (HTTP Request) — Header Auth (Dumpling AI API key in header). Calls with the article URL and to get the article's main content in markdown format. Aggregate: Combine Article Content (Aggregate) — Collects the field from all scraped articles into a single array. Generate Newsletter (OpenAI) — API Key auth (OpenAI API key). Sends the aggregated content to GPT-4.1-mini with a system prompt that instructs it to generate a professional HTML newsletter and a subject line. Outputs JSON with (HTML) and fields. Send Newsletter via Email (Gmail) — OAuth2 (Google account connected via n8n Gmail node). Sends the generated HTML newsletter to a specified email address with the generated subject line. Setup Instructions To use this workflow, you will need accounts and API keys for the following services: Telegram: Create a bot via @BotFather and get the bot token. Configure the Telegram Trigger node with this token. Dumpling AI: Sign up at app.dumplingai.com and generate an API key. This key is used as a header () in the three HTTP Request nodes (Googleautocomplete, Searchnews, Scraper). OpenAI: Sign up at platform.openai.com and create an API key. Use this in the LLM node and the Generate Newsletter node. Gmail: Connect your Google account via OAuth2 in n8n's Gmail node. Ensure the email address you want to send to is authorized (or use your own address for testing). After configuring all credentials, activate the workflow and send a keyword (e.g., "AI in retail") to your Telegram bot. The workflow will run and deliver a newsletter to your inbox. Use Cases and Variations Content Curation for Newsletters: Replace the Telegram trigger with a Schedule trigger to run daily or weekly on predefined keywords (e.g., "tech news", "climate change"). Brand Monitoring: Use the workflow to monitor news about your brand or competitors and send alerts to your team via email or Slack. Personalized Digests: Modify the AI prompt to generate summaries in different languages or tones (e.g., executive brief, casual digest). Multi-Channel Delivery: Instead of Gmail, send the newsletter to Slack, Discord, or a Notion database by swapping the final node. Add Human Review: Insert a manual approval step (e.g., n8n's "Wait" node with webhook) before sending, so you can review and edit the newsletter.
AI-Powered Gmail Email Classifier & Labeler
Overview This workflow automatically monitors your Gmail inbox for new emails, retrieves the full email content, and uses an AI agent powered by Anthropic's Claude to classify each email into a predefined Gmail label. It also checks prior email history with the sender to improve classification accuracy. Finally, it applies the chosen label to the email, helping you organize your inbox without manual effort. How It Works Gmail Trigger — Polls Gmail every minute for new emails (OAuth2). Gmail — Fetches the full email details (headers, body, etc.) using the message ID from the trigger (OAuth2). AI Agent — Orchestrates the classification process. It uses the Anthropic Chat Model as its language model and the Structured Output Parser to extract the label ID. The agent also has access to two Gmail tools to check prior email history. Anthropic Chat Model — The LLM (Claude Sonnet 4) that analyzes the email content and history to decide the best label (API Key auth). Structured Output Parser — Ensures the AI's response is a valid JSON object containing the label ID (No auth). Get Email — A Gmail tool used by the AI agent to search for prior emails from the sender (OAuth2). Check Sent — A Gmail tool used by the AI agent to check if the user has previously sent emails to the sender (OAuth2). Gmail1 — Applies the chosen label to the original email (OAuth2). Node Details Gmail Trigger (OAuth2) — Polls Gmail every minute for new messages. No filters are set, so it watches the entire inbox. Gmail (OAuth2) — Uses the operation to retrieve the full email object by . The option is disabled to get the raw JSON. Anthropic Chat Model (API Key auth) — Configured to use the model with default options. AI Agent (No auth) — Contains a detailed system message that instructs the AI to classify emails into one of six labels (To Respond, FYI, Comment, Notification, Meeting Update, Marketing) based on content, headers, and prior email history. It uses the input "Run the task." and has an output parser attached. Structured Output Parser (No auth) — Expects a JSON schema with keys and . This forces the AI to output a clean JSON object. Get Email (OAuth2) — Gmail tool that searches for emails from the sender using the query. It returns all matching emails (no limit). Check Sent (OAuth2) — Gmail tool that searches for emails sent to the sender in the folder, using the query. Gmail1 (OAuth2) — Uses the operation to apply the label ID returned by the AI agent to the original email. Setup Instructions Gmail OAuth2 Credentials — You need a Google Cloud project with the Gmail API enabled. Create OAuth2 credentials (Desktop app or Web application) and add them in n8n under Credentials > Google. The workflow uses OAuth2 for all Gmail nodes. Anthropic API Key — Sign up at Anthropic and generate an API key. Add it in n8n under Credentials > Anthropic. Gmail Labels — The workflow expects specific label IDs (e.g., for "To Respond"). You must create these labels in your Gmail account and note their IDs. Alternatively, you can modify the system message in the AI Agent node to use your own label names/IDs. Activate the workflow — Once credentials are set and labels exist, activate the workflow. It will start polling Gmail and classifying new emails. Use Cases & Variations Personal Inbox Zero — Automatically sort newsletters, notifications, and actionable emails into separate folders. Sales Pipeline Management — Classify incoming leads as "To Respond" or "Marketing" based on prior contact. Support Ticket Triage — Route customer emails to appropriate labels based on content and history. Custom Labels — Modify the AI agent's system prompt to use your own set of labels (e.g., "Urgent", "Read Later", "Archive"). Integration with Other Tools — After labeling, you could add nodes to send Slack notifications, create tasks in Notion, or log to a spreadsheet.