Wednesday, 29 April 2026

n8n OpenRouter Tutorial: Build Multi-Model AI Automation Workflows

n8n + OpenRouter Tutorial

How to Use n8n with OpenRouter for Multi-Model AI Automation

Learn how to connect n8n to OpenRouter and use multiple AI models in one automation workflow.

If you want to build flexible AI automations, combining n8n with OpenRouter is a powerful setup. OpenRouter gives you access to many AI models through one unified API, while n8n lets you automate how those models are used.

💡 Example: user submits a question → n8n sends it to OpenRouter → AI generates a response → result is sent to Telegram, Gmail, CRM, or your website chatbot.

What You’ll Learn

  • What OpenRouter is
  • How to connect OpenRouter to n8n
  • How to call AI models using HTTP Request
  • How to use dynamic prompts from previous nodes
  • How to build real AI automation workflows

What Is OpenRouter?

OpenRouter is a unified AI model gateway. Instead of integrating many separate AI providers one by one, you can call different models through one OpenRouter API.

This is useful when you want to test different models for chatbots, AI agents, blog automation, summarization, customer support, and internal tools.

Simple explanation: OpenRouter is like a router for AI models. n8n sends the request, OpenRouter sends it to the selected AI model.

Step 1: Get Your OpenRouter API Key

  1. Create or log in to your OpenRouter account
  2. Go to API Keys
  3. Create a new API key
  4. Copy and save it securely
⚠️ Security tip: never expose your OpenRouter API key in frontend code or public pages.

Step 2: Add HTTP Request Node in n8n

OpenRouter can be connected using the n8n HTTP Request node.

HTTP Request settings:

  • Method: POST
  • URL: https://openrouter.ai/api/v1/chat/completions
  • Authentication: None or Generic Header Auth
  • Send Body: JSON

Headers:

Content-Type: application/json
Authorization: Bearer YOUR_OPENROUTER_API_KEY

Step 3: Send Your First AI Request

Example JSON body:

{
  "model": "openai/gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful AI automation assistant."
    },
    {
      "role": "user",
      "content": "Explain n8n in simple terms."
    }
  ]
}

After executing the node, OpenRouter will return an AI-generated response from the selected model.

Step 4: Use Dynamic Data from Previous Nodes

In real workflows, your prompt usually comes from a webhook, form, chat widget, Google Sheet, or database.

Example dynamic message:

{
  "model": "openai/gpt-4o-mini",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful customer support assistant."
    },
    {
      "role": "user",
      "content": "{{ $json.message }}"
    }
  ]
}

This lets n8n send user input directly to OpenRouter and use the response in the next node.

Step 5: Extract the AI Response

The AI response is usually returned inside the output JSON. In many chat completion responses, the generated text can be found in:

{{ $json.choices[0].message.content }}

You can pass this value to Telegram, Gmail, Google Sheets, WordPress, CRM, or a website chatbot.

Example n8n + OpenRouter Workflow

Webhook / Chat Trigger
   ↓
Set
   ↓
HTTP Request (OpenRouter)
   ↓
Set / Extract AI Response
   ↓
Telegram / Gmail / Google Sheets / WordPress

This workflow receives input, sends it to an AI model through OpenRouter, extracts the AI answer, and sends it to another app.

Real Use Cases

AI chatbot replies
Blog post generation
Email auto-response
AI agent workflows
Document summarization
Customer support automation

Example: AI Support Bot with OpenRouter

You can use OpenRouter as the AI brain of a support bot. A simple workflow can look like this:

Website Chat Form
   ↓
n8n Webhook
   ↓
OpenRouter AI
   ↓
Business Logic / IF Node
   ↓
Reply to User
   ↓
Log to Google Sheets

This is useful for schools, LGUs, service businesses, online stores, and internal helpdesks.

Common Errors and Fixes

1. Unauthorized error
Check your Authorization header and make sure it uses Bearer YOUR_API_KEY.

2. Model not found
Confirm the model ID from the OpenRouter models page before using it.

3. Empty response
Check your messages array and make sure user content is not blank.

4. Wrong output expression
Inspect the HTTP Request output and adjust the expression path if needed.

5. High cost or slow response
Try a smaller model for simple tasks and reserve larger models for complex reasoning.

Best Practices

  • Start with a low-cost model for testing
  • Use clear system prompts
  • Log prompts and responses during development
  • Keep API keys inside n8n credentials or secure variables
  • Use IF nodes to handle errors or empty responses
  • Use different models depending on task complexity

Watch My AI Automation Builds on YouTube

I share real n8n workflows, AI agent builds, and automation systems on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Can n8n connect to OpenRouter?
Yes. You can use the HTTP Request node to call OpenRouter’s API directly.

Is OpenRouter compatible with OpenAI-style requests?
Yes. OpenRouter’s request and response schemas are similar to the OpenAI Chat API, which makes it easier to integrate.

Can I use OpenRouter for AI agents?
Yes. You can use OpenRouter as the model backend for AI chatbots, assistants, and agent-style workflows in n8n.


SEO Title

n8n OpenRouter Tutorial: Build Multi-Model AI Automation Workflows

Meta Description

Learn how to connect n8n with OpenRouter using HTTP Request, send AI prompts, extract responses, and build multi-model AI automation workflows.

Suggested Labels

n8n, OpenRouter, AI Automation, AI Agent, Workflow Automation, Chatbot, OpenAI API, Blogspot Tutorial

Tuesday, 28 April 2026

n8n Gemini Image Generation Tutorial: Create AI Images Automatically

n8n + Google Gemini Tutorial

How to Create AI Images with n8n and Google Gemini

Learn how to automate AI image generation using n8n, Google Gemini, Google Sheets, and Google Drive.

If you want to create images automatically for blogs, YouTube thumbnails, social media posts, product visuals, or marketing content, combining n8n with Google Gemini is a powerful workflow.

💡 Example: Google Sheets contains image ideas → n8n reads the rows → Gemini generates images → n8n saves them to Google Drive → status updates automatically.

What You’ll Learn

  • How Gemini image generation works
  • How to connect Gemini API to n8n
  • How to generate images from text prompts
  • How to save generated images to Google Drive
  • How to build a full content automation workflow

What Is Google Gemini Image Generation?

Google Gemini can generate and process images using text prompts, reference images, or a combination of both. This makes it useful for creating thumbnails, social media graphics, blog images, concept art, product visuals, and marketing assets.

Google also provides Imagen models for high-fidelity image generation. Imagen is designed to generate realistic, high-quality images from text prompts.

Simple explanation: Gemini creates the image, while n8n automates the full process around it.

Step 1: Prepare Your Google Gemini API Key

First, get your Gemini API key from Google AI Studio or your Google AI developer account.

  1. Go to Google AI Studio
  2. Create or select your API key
  3. Copy the key
  4. Store it securely in n8n credentials or environment variables
⚠️ Security tip: never expose your API key in frontend code or public blog pages.

Step 2: Create the n8n Workflow Structure

A simple image automation workflow can look like this:

Google Sheets Trigger
   ↓
Get Row / Prompt
   ↓
HTTP Request or Gemini Node
   ↓
Convert Base64 / Download Image
   ↓
Google Drive Upload
   ↓
Update Google Sheet
   ↓
Telegram Notification

This workflow is useful if you want to generate images in bulk from a spreadsheet.

Step 3: Prepare Your Google Sheet

Create a Google Sheet with these columns:

  • title – image topic or content title
  • prompt – full image prompt
  • status – pending / done / failed
  • image_url – final uploaded image link

Example prompt:

A futuristic n8n automation dashboard with glowing nodes, dark background, cinematic lighting, high-tech UI, no text

Step 4: Generate Image Using Gemini API

In n8n, you can use either a Gemini-supported node or the HTTP Request node to call the Gemini image generation endpoint.

Typical HTTP Request setup:

  • Method: POST
  • Authentication: API key or Bearer token, depending on your setup
  • Body type: JSON
  • Prompt: use dynamic value from Google Sheets

Example dynamic prompt:

{{ $json.prompt }}
💡 Tip: For blog thumbnails, add style details like “cinematic lighting,” “dark tech background,” “3D vector style,” and “no text” for cleaner output.

Step 5: Save the Generated Image

Image generation APIs often return either a downloadable image URL or base64 image data. In n8n, your next step depends on the response type.

  • If the API returns a URL, use HTTP Request to download the file.
  • If the API returns base64, convert it to binary data.
  • Then upload the file to Google Drive, Supabase Storage, or WordPress media.

Workflow sample:

Gemini Image Response
   ↓
Convert to Binary
   ↓
Google Drive Upload
   ↓
Get Share Link
   ↓
Update Google Sheet

Step 6: Update Google Sheet Status

After saving the image, update the same Google Sheet row.

Recommended values:

  • status: done
  • image_url: Google Drive or storage link
  • generated_at: current timestamp

Real Use Cases

YouTube thumbnail ideas
Blog featured images
Social media creatives
Product mockup images

Prompt Examples for n8n Automation Content

Example 1: Tech thumbnail

A premium dark tech illustration showing automation nodes connected to AI, glowing blue and purple lights, cinematic, modern SaaS style, no text

Example 2: AI agent image

A futuristic AI assistant controlling business workflows, floating automation nodes, digital dashboard, dark background, clean modern style, no text

Example 3: Blog featured image

A clean vector-style image of a workflow automation system connecting Google Sheets, AI image generation, and cloud storage, dark background, professional, no text

Common Errors and Fixes

1. API key error
Check if your Gemini API key is active and correctly added to n8n.

2. No image returned
Check if you are using an image-capable Gemini or Imagen model.

3. Base64 conversion issue
Make sure you convert the correct response field into binary data.

4. Prompt gives messy text
Add “no text” or “no typography” to your prompt if you want a clean thumbnail background.

5. Google Drive upload fails
Check your Google Drive credentials and binary property name in n8n.

Best Practices

  • Use Google Sheets to manage prompts in bulk
  • Keep prompts clear and style-specific
  • Add “no text” for cleaner blog images
  • Save outputs to Google Drive or Supabase Storage
  • Log failed generations for retry
  • Use a Wait node if generating many images

Watch My Automation Videos on YouTube

I share n8n workflows, AI automation tutorials, and real system builds on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Can I generate images automatically with n8n and Gemini?
Yes. You can use n8n to send prompts to Gemini or Imagen image models, then save the generated output to Drive, storage, or WordPress.

Can I generate images from Google Sheets rows?
Yes. A common workflow is Google Sheets → Gemini image generation → Google Drive upload → update row status.

Can I use this for YouTube thumbnails?
Yes. It is useful for thumbnail backgrounds, blog featured images, social media graphics, and marketing visuals.


SEO Title

n8n Gemini Image Generation Tutorial: Create AI Images Automatically

Meta Description

Learn how to use n8n and Google Gemini to generate AI images from prompts, save them to Google Drive, and automate content creation workflows.

Suggested Labels

n8n, Google Gemini, AI Image Generation, Automation, Google Drive, Google Sheets, Blogspot Tutorial

Monday, 27 April 2026

n8n GoHighLevel Tutorial: Automate CRM Workflow

n8n + GoHighLevel Tutorial

How to Automate GoHighLevel (GHL) Using n8n

Connect GHL CRM with n8n to automate leads, follow-ups, pipelines, and notifications 🚀

If you're running a CRM-based business, combining n8n with GoHighLevel (GHL) is extremely powerful. GHL handles leads, pipelines, and communication — while n8n automates everything behind the scenes.

💡 Example: new lead → n8n processes data → push to GHL → send SMS → notify team → update pipeline.

📌 What You'll Learn

  • Connect GHL API to n8n
  • Create and update contacts
  • Automate pipelines
  • Send SMS/email automatically
  • Build full CRM workflows

What is n8n + GHL?

GoHighLevel is a CRM and marketing platform used for lead management, automation, and communication. n8n lets you connect GHL with external systems and automate workflows.

Step 1: Get GHL API Key

  1. Login to GoHighLevel
  2. Go to Settings → API Keys
  3. Generate or copy your API key
⚠️ Keep your API key secure.

Step 2: Setup HTTP Request Node in n8n

GHL works via API, so we use the HTTP Request node.

  • Method: POST
  • URL: https://rest.gohighlevel.com/v1/contacts/

Headers:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Step 3: Create a Contact

{
  "firstName": "John",
  "lastName": "Doe",
  "email": "john@example.com",
  "phone": "09171234567"
}

This will create a new lead inside GHL CRM.

Step 4: Update Contact

PUT /v1/contacts/{contactId}

Use this to update lead status, tags, or pipeline stage.

Full Workflow Example

Webhook → Set → GHL (Create Contact) → SMS → Telegram → Google Sheets
  • Receive lead from form or landing page
  • Format data
  • Push to GHL
  • Send SMS via GHL or external API
  • Notify your team

Real Use Cases

Lead Capture Automation
Sales Pipeline Automation
SMS Follow-Ups
Appointment Booking

Common Errors

❌ Invalid API key
❌ Unauthorized request
❌ Missing required fields
❌ Rate limits

Pro Tips

  • Use tags to organize leads
  • Automate follow-ups instantly
  • Connect GHL with AI agents
  • Store logs in Google Sheets

🎥 Watch My Automation Tutorials

I share n8n workflows, CRM automations, and AI systems on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Q: Can I automate leads into GHL?
Yes, using n8n and API integration.

Q: Can I send SMS automatically?
Yes, via GHL or external SMS APIs.

Q: Can I use AI with GHL?
Yes, integrate OpenAI or Claude with n8n.


SEO Title: n8n GoHighLevel Tutorial: Automate CRM Workflows

Meta Description: Learn how to connect n8n with GoHighLevel to automate leads, pipelines, and CRM workflows.

Friday, 24 April 2026

n8n Firecrawl Tutorial: AI Web Scraping Automation

n8n + Firecrawl Tutorial

How to Use n8n with Firecrawl for AI Web Scraping Automation

Extract website content, clean data, and build AI pipelines using Firecrawl + n8n 🚀

If you're building AI systems, RAG pipelines, or automation workflows, combining n8n with Firecrawl is a powerful solution. Firecrawl extracts clean content from websites, while n8n automates what you do with that data.

💡 Example: scrape article → clean content → send to OpenAI → publish blog → notify Telegram.

📌 What You'll Learn

  • Connect Firecrawl API to n8n
  • Scrape websites automatically
  • Extract clean content
  • Build AI workflows (RAG, blog automation)
  • Real-world use cases

What is n8n + Firecrawl?

Firecrawl is an AI-powered web scraping tool that extracts clean, structured content from websites. n8n allows you to automate how that data is processed, stored, and used.

Step 1: Get Firecrawl API Key

  1. Go to Firecrawl website
  2. Create an account
  3. Copy your API key
⚠️ Keep your API key secure.

Step 2: Setup HTTP Request Node in n8n

Firecrawl works via API, so we use the HTTP Request node.

  • Method: POST
  • URL: https://api.firecrawl.dev/v1/scrape

Headers:

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Step 3: Scrape a Website

{
  "url": "https://example.com",
  "formats": ["markdown"]
}

This will return clean structured content ready for AI processing.

Step 4: Crawl Multiple Pages

{
  "url": "https://example.com",
  "crawl": true,
  "limit": 10
}

This allows you to scrape entire websites automatically.

Full Workflow Example

Manual Trigger → HTTP Request (Firecrawl) → OpenAI → Set → WordPress → Telegram
  • Scrape website
  • Clean content
  • Generate article using AI
  • Publish blog
  • Send notification

Real Use Cases

AI Blog Automation
Competitor Monitoring
RAG Knowledge Base
News Aggregation

Common Errors

❌ Invalid API key
❌ Website blocking scraping
❌ Empty content returned
❌ Rate limits

Pro Tips

  • Use markdown format for AI processing
  • Combine with OpenAI for summarization
  • Store scraped data in Supabase
  • Limit crawl depth for performance

🎥 Watch My AI Automation Tutorials

I share n8n workflows, scraping systems, and AI automations on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Q: Is Firecrawl free?
Firecrawl offers limited free usage.

Q: Can I scrape multiple pages?
Yes, using crawl mode.

Q: Can I use this for AI chatbots?
Yes, perfect for RAG pipelines.


SEO Title: n8n Firecrawl Tutorial: AI Web Scraping Automation

Meta Description: Learn how to use n8n with Firecrawl to scrape websites and build AI-powered automation workflows.

Thursday, 23 April 2026

How to Use n8n with PostgreSQL for Database Automation

n8n + PostgreSQL Tutorial

How to Use n8n with PostgreSQL for Database Automation

Learn how to connect n8n to PostgreSQL, run queries, insert and update rows, and automate database workflows with triggers and notifications.

If you want to automate database tasks, combining n8n with PostgreSQL is a strong setup. PostgreSQL stores your structured data, while n8n handles the workflow logic around it.

💡 Example: when a form is submitted, n8n can save the lead to PostgreSQL, notify your team on Telegram, and send an email automatically.

What You’ll Learn

  • How to connect PostgreSQL to n8n
  • How to run SELECT queries
  • How to INSERT new rows
  • How to UPDATE existing records
  • How to DELETE rows safely
  • How to use PostgreSQL Trigger in n8n

Why Use n8n with PostgreSQL?

PostgreSQL is a powerful relational database used for apps, dashboards, internal systems, and business workflows. n8n makes it easier to automate what happens before and after your database actions.

  • Save leads or orders automatically
  • Read customer or system data on demand
  • Update statuses after payments or approvals
  • Trigger automations when rows change
  • Connect database events to email, Telegram, APIs, and CRMs

Step 1: Prepare Your PostgreSQL Database

Before connecting n8n, make sure your PostgreSQL server is ready and you have these connection details:

  • Host
  • Port
  • Database name
  • Username
  • Password

It is best to create a dedicated database user for n8n instead of using your main admin account.

⚠️ Security tip: only give the n8n database user the permissions it needs.

Step 2: Add Postgres Credentials in n8n

n8n has official Postgres credentials support. Create a new Postgres credential and enter your database connection settings.

  1. Open Credentials in n8n
  2. Create a new Postgres credential
  3. Enter host, port, database, username, and password
  4. Save and test the connection

After that, you can use the Postgres node inside your workflows.

Step 3: Read Data with SELECT

To read data from PostgreSQL, use SELECT.

SELECT id, full_name, email
FROM customers
ORDER BY id DESC;

This is useful for reading customers, orders, attendance logs, payments, and other records.

Step 4: Insert New Rows

To save new data, use INSERT.

INSERT INTO customers (full_name, email, phone)
VALUES ('John Doe', 'john@example.com', '09171234567');

This works well for form entries, lead capture, registrations, chatbot logs, and order records.

Step 5: Update Existing Records

To change existing records, use UPDATE.

UPDATE customers
SET phone = '09998887777'
WHERE id = 1;

This is useful for updating payment status, approval state, timestamps, or workflow progress.

Step 6: Delete Rows Carefully

To remove data, use DELETE. Always include a clear WHERE condition.

DELETE FROM customers
WHERE id = 1;
Warning: if you run DELETE without a WHERE clause, you can remove all rows from the table.

Step 7: Use Dynamic Data from Previous Nodes

One of the best parts of n8n is using data from earlier nodes inside your Postgres workflow.

Example expression:

{{ $json.email }}

This lets you insert, search, or update rows using form values, webhook data, chatbot output, or API responses.

Step 8: Use Postgres Trigger for Event-Based Automation

n8n also has a Postgres Trigger node that can respond to database events. According to n8n’s docs, it supports reacting to insert, update, and delete events.

Postgres Trigger
   ↓
IF
   ↓
Telegram / Gmail / HTTP Request / Google Sheets

This is useful when you want instant automation whenever a row changes in your database.

Example n8n + PostgreSQL Workflow

Webhook
   ↓
Set
   ↓
Postgres (INSERT lead)
   ↓
Postgres (SELECT saved record)
   ↓
Telegram
   ↓
Gmail

In this workflow:

  • A webhook receives incoming data
  • A Set node formats the fields
  • The Postgres node inserts the record
  • Another Postgres step reads the row
  • Telegram and Gmail notify your team

Real Use Cases

Lead capture systems
Order and invoice tracking
Attendance and RFID systems
Internal dashboards and CRMs

Best Practices

  • Use a separate PostgreSQL user for n8n
  • Test SELECT first before running UPDATE or DELETE
  • Log important outputs during development
  • Keep your SQL simple and readable
  • Use UTC and ISO 8601 dates when possible

Common Errors and Fixes

1. Connection failed
Check host, port, username, password, and whether your PostgreSQL server accepts external connections.

2. Access denied
Your database user may not have the needed privileges.

3. Query returned nothing
Review your table name, filters, and incoming data.

4. Wrong data inserted
Check your n8n expressions and field mapping.

5. Array or date issues
n8n’s Postgres common issues page recommends careful parameter handling, UTC for dates, and ISO 8601 formatting to avoid timezone confusion.

Watch My Automation Videos on YouTube

I share n8n workflows, automation tutorials, and AI system ideas on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Can I use n8n to insert data into PostgreSQL automatically?
Yes. n8n’s Postgres node supports inserting and updating rows, and it can also execute queries.

Can n8n react when PostgreSQL data changes?
Yes. n8n has a Postgres Trigger node for insert, update, and delete events.

Can I use PostgreSQL with Telegram, Gmail, or Google Sheets in the same workflow?
Yes. That is one of the main strengths of n8n.


SEO Title

n8n PostgreSQL Tutorial: How to Automate Database Workflows

Meta Description

Learn how to use n8n with PostgreSQL to automate queries, inserts, updates, deletes, and trigger-based workflows.

Wednesday, 22 April 2026

n8n Apollo Tutorial: Automate Lead Generation

n8n + Apollo Tutorial

How to Use n8n with Apollo for Lead Generation Automation

Automate B2B lead generation, enrichment, and outreach using n8n and Apollo 🚀

If you want to build a powerful lead generation system, combining n8n with Apollo is a game changer. Apollo provides B2B contact data, while n8n automates extraction, enrichment, and follow-ups.

💡 Example: search leads in Apollo → send to Google Sheets → trigger email outreach → notify via Telegram.

📌 What You'll Learn

  • Connect Apollo API to n8n
  • Search and extract leads
  • Save leads to database or Sheets
  • Automate outreach workflows
  • Real use cases

What is n8n + Apollo?

Apollo is a B2B data platform that provides verified emails, company data, and prospecting tools. n8n allows you to automate how that data is used.

Step 1: Get Apollo API Key

  1. Login to Apollo dashboard
  2. Go to Settings → API
  3. Copy your API key
⚠️ Keep your API key private.

Step 2: Setup HTTP Request in n8n

Apollo does not have a native n8n node, so we use the HTTP Request node.

  • Method: POST
  • URL: https://api.apollo.io/v1/mixed_people/search

Headers:

Content-Type: application/json
X-Api-Key: YOUR_API_KEY

Step 3: Search Leads

{
  "q_organization_domains": ["example.com"],
  "page": 1,
  "per_page": 5
}

This returns leads from Apollo database.

Full Workflow Example

Manual Trigger → HTTP Request (Apollo) → Set → Google Sheets → Gmail → Telegram
  • Fetch leads
  • Format data
  • Store in Sheets
  • Send outreach email
  • Notify team

Real Use Cases

Cold Email Automation
Lead Database Builder
Sales CRM Sync
AI Lead Scoring

Common Errors

❌ Invalid API key
❌ Rate limits
❌ Wrong query format
❌ No results returned

Pro Tips

  • Filter leads carefully to improve quality
  • Use AI to personalize emails
  • Limit requests to avoid API limits
  • Store leads before outreach

🎥 Watch My Automation Tutorials

I share n8n workflows, lead gen systems, and AI automations on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Q: Is Apollo free?
Apollo has limited free credits.

Q: Can I automate outreach?
Yes, using Gmail or other email APIs.

Q: Can I use AI personalization?
Yes, integrate OpenAI with n8n.


SEO Title:

Meta Description: Learn how to use n8n with Apollo API to automate lead generation and outreach workflows.

Tuesday, 21 April 2026

n8n MySQL Tutorial: How to Automate Database Workflows

n8n + MySQL Tutorial

How to Use n8n with MySQL for Database Automation

Learn how to connect n8n to MySQL, run queries, insert records, update rows, and automate database workflows.

If you want to automate your database tasks, combining n8n with MySQL is a great setup. MySQL stores your data, while n8n helps automate what happens before and after every database action.

💡 Example: when a form is submitted, n8n can save the lead to MySQL, send a Telegram alert, and update Google Sheets automatically.

What You’ll Learn

  • How to connect MySQL to n8n
  • How to run SELECT queries
  • How to INSERT new rows
  • How to UPDATE records
  • How to DELETE data safely
  • How to use MySQL in real workflows

Why Use n8n with MySQL?

MySQL is one of the most common relational databases for web apps, CRMs, dashboards, and internal systems. n8n helps you automate how data enters, changes, and moves across your systems.

  • Save form submissions to a database
  • Read customer or order data automatically
  • Update records after payment or approval
  • Delete old records on schedule
  • Sync MySQL data with email, Telegram, CRMs, and APIs

Step 1: Prepare Your MySQL Database

Before connecting n8n, make sure your MySQL server is running and you have:

  • Host
  • Port
  • Database name
  • Username
  • Password

It is best to create a dedicated database user for n8n instead of using your main admin account.

⚠️ Security tip: give the n8n database user only the permissions it actually needs.

Step 2: Add MySQL Credentials in n8n

In n8n, create a new MySQL credential and enter your connection details.

  1. Open Credentials in n8n
  2. Create a new MySQL credential
  3. Enter host, port, database, username, and password
  4. Save and test the connection

Once connected, you can use MySQL inside your workflows to query and modify database records.

Step 3: Read Data with SELECT

The most common database action is reading data. In MySQL, this is done with the SELECT statement.

SELECT id, full_name, email
FROM customers
ORDER BY id DESC;

In n8n, you can use a MySQL node or a query-based setup to run this and return rows for the next node in your workflow.

Step 4: Insert New Rows

To save new data, use INSERT.

INSERT INTO customers (full_name, email, phone)
VALUES ('John Doe', 'john@example.com', '09171234567');

This is useful for leads, registrations, orders, contact form entries, and chatbot submissions.

Step 5: Update Existing Records

Use UPDATE when you need to change existing rows.

UPDATE customers
SET phone = '09998887777'
WHERE id = 1;

This is useful for updating order status, customer details, payment state, or workflow progress.

Step 6: Delete Records Carefully

Use DELETE only when needed, and always include a clear WHERE condition to avoid removing everything by mistake.

DELETE FROM customers
WHERE id = 1;
Warning: running DELETE without a WHERE clause can remove all rows from a table.

Step 7: Use Dynamic Data from Previous Nodes

One of the best parts of n8n is that you can use values from previous nodes inside your database logic.

Example expression:

{{ $json.email }}

n8n also supports referencing data from earlier nodes when building more advanced workflows.

Example n8n + MySQL Workflow

Webhook
   ↓
Set
   ↓
MySQL (INSERT lead)
   ↓
MySQL (SELECT latest data)
   ↓
Telegram
   ↓
Gmail

In this workflow:

  • A webhook receives a form submission
  • A Set node formats the incoming data
  • MySQL inserts the record
  • Another MySQL step reads the saved row
  • Telegram and Gmail notify your team

Real Use Cases

Lead capture systems
Order and payment tracking
Attendance and RFID systems
CRM and admin dashboards

Best Practices

  • Use a separate MySQL user for n8n
  • Back up your database before testing destructive queries
  • Test SELECT first before running UPDATE or DELETE
  • Log important outputs during development
  • Keep table and column names clear and consistent

Common Errors and Fixes

1. Connection failed
Check host, port, username, password, and whether the MySQL server accepts remote connections.

2. Access denied
The database user may not have the right privileges.

3. Query returned nothing
Review your table name, WHERE clause, and incoming data.

4. Wrong data inserted
Check your n8n expressions and field mappings carefully.

5. Update or delete affected too many rows
Always verify your WHERE condition before executing the query.

Watch My Automation Videos on YouTube

I share n8n workflows, automation tutorials, and AI system ideas on my YouTube channel.

▶ Visit My YouTube Channel

FAQ

Can I use n8n to insert data into MySQL automatically?
Yes. n8n can receive data from forms, APIs, spreadsheets, or webhooks and save it into MySQL automatically.

Can I update MySQL rows from n8n?
Yes. You can use update queries to change values such as status, amount, timestamps, or user details.

Can I use MySQL with Telegram, Gmail, or Google Sheets in the same workflow?
Yes. That is one of the biggest strengths of n8n.


SEO Title

n8n MySQL Tutorial: How to Automate Database Workflows

Meta Description

Learn how to use n8n with MySQL to automate database queries, inserts, updates, deletes, and connected workflow actions.

n8n OpenRouter Tutorial: Build Multi-Model AI Automation Workflows

n8n + OpenRouter Tutorial How to Use n8n with OpenRouter for Multi-Model AI Automation Learn how to ...