Skip to content

Building AI Automation with n8n and Supabase RAG: An Engineering Case Study

Real engineering challenges and solutions most tutorials ignore

TL;DR

A technical deep-dive into building AI job application automation with n8n, Supabase RAG, and Gemini embeddings. Covers vector dimension mismatches, structured output handling, and production-grade fallback logic.

Why I Built This — And What It Has to Do With UK Business Automation

As a digital marketing agency based in West Drayton, London, we see first-hand how small businesses across the UK waste 15–20 hours per week on repetitive manual tasks — data entry, lead follow-ups, CRM updates. That is time that could be spent growing the business or serving customers.

I built an end-to-end AI automation system using n8n (open-source workflow automation), Supabase (PostgreSQL with pgvector for AI embeddings), and RAG (Retrieval-Augmented Generation). To stress-test this system under production conditions, I used my actual **Automation and Electrical Engineering CV** as the raw unstructured data baseline.

Engineering assets are notoriously complex for baseline LLMs due to specialized acronyms like PLC programming, SCADA architectures, and HMI design. By proving a RAG pipeline can flawlessly contextualize engineering documents without hallucinations, we demonstrate how this exact framework can safely handle sensitive corporate databases.

The same architecture we use in this project is the foundation for the AI and CRM automation systems we build for UK clients . This post documents the real engineering challenges — the ones most tutorials skip.

I am Muhammad Imran, founder of Exora Leads . I hold certifications from Google Analytics and SEMrush Academy. Everything in this post is from a real build, not a demo.

What Is n8n — And Why UK Businesses Are Choosing It Over Zapier

n8n is an open-source workflow automation platform that lets you connect apps, APIs, and AI models using a visual node-based editor. Unlike Zapier or Make, n8n gives you full control over your data and infrastructure — you can self-host it on your own server, which is critical for UK businesses that need to comply with GDPR and data protection regulations.

  • AI Agent nodes: Native support for LLM integrations (OpenAI, Gemini, Claude) with tool calling and reasoning capabilities.
  • Self-hosted option: Keep sensitive business data on UK-based servers. No third-party data sharing.
  • Visual workflow builder: Drag-and-drop nodes for HTTP requests, databases, email, and more.
  • Cost-effective: The free tier is generous. Self-hosted plans start at €20 per month versus Zapier's £50+ per month for similar capabilities.

How the AI Job Apply Automation Works — Step by Step

Step 1: CV Retrieval from Google Drive

The workflow starts by fetching the user's CV from Google Drive. n8n connects to the Google Drive API, searches for the latest CV document, and retrieves it as binary data. Before the AI can process it, we convert the binary file to plain text using a transformation node.

Google Drive cloud storage configuration showing raw CV PDF document retrieval setup for n8n AI ingestion layer.

*Figure 1.1: Production file infrastructure within Google Drive housing the unstructured source CV documents ready for native binary-to-text extraction.*

Step 2: Embedding Generation with Gemini

The CV text is sent to Google's Gemini text-embedding-004 model, which generates a 768-dimensional vector representation. This vector is stored in Supabase using the pgvector extension — enabling fast cosine similarity searches.

Step 3: RAG — Retrieval-Augmented Generation

Retrieval-Augmented Generation RAG workflow architecture diagram mapping Supabase pgvector embedding search and AI Agent node routing.

*Figure 1.2: End-to-end Cognitive RAG Mesh mapping semantic search matching via 768-dimension Supabase vector store matrices to structured JSON model outputs..*

When a new job posting is found, the job description is also embedded. The system queries Supabase to find the most relevant CV sections using cosine similarity. These chunks are injected into the AI Agent's prompt as context — so the model writes a tailored cover letter based on actual experience, not hallucinated content.

Step 4: AI Agent Drafting

The AI Agent node (powered by Gemini or OpenAI) receives the job description plus retrieved CV context and drafts a personalised cover letter. To ensure consistent output, I configured a structured output tool that forces the model to return a defined JSON schema with required keys: greeting, body, call_to_action, and sign_off.

Step 5: Telegram Notification and Google Drive Storage

Once the cover letter is drafted, the system sends it via Telegram and saves a copy to Google Drive. If the structured output check fails, the workflow routes to a fallback path using a smaller model with a tighter prompt — preventing crashes and keeping the pipeline running.

Visualizing the Production Architecture: Our 3-Zone Topology

As shown in our live production blueprint below, we don't build linear automation loops. We break our enterprise pipelines into three completely isolated functional zones to preserve data integrity and prevent hard execution breaks:

  1. The Ingestion Layer: Captures unstructured payloads, executing clean transformations before data hits our model nodes.
  2. The Cognitive RAG Mesh: Coordinates semantic retrieval using our specialized 768-dimension Supabase vector store configurations, enforcing strict JSON output validation.
  3. The Distributed Execution Engine: Fires parallel API requests to instantly update connected customer pipelines and trigger live communication logs.

Let's automate your workflows and build intelligent systems for your business.

Explore AI & CRM Automation →

Production grade n8n automation workflow canvas layout featuring multi-zone error handling triggers and Google Gemini AI node routing.

*Figure 1.3: Complete open-source n8n workflow architecture featuring Google Gemini and a native Supabase pgvector infrastructure.*

The Biggest Challenge I Faced — And How I Fixed It

Here is the issue that cost me three hours of debugging: my Supabase vector store returned zero results even though the workflow reported success.

The root cause was a vector dimension mismatch. My embedding model (Gemini text-embedding-004) outputs 768-dimension vectors, but my Supabase table's VECTOR column was defined as VECTOR(1536) — the OpenAI default. PostgreSQL silently rejected the inserts with no error. The workflow \"succeeded\" because n8n does not validate database write results by default.

The fix — drop and recreate the table with the correct schema:


CREATE TABLE cv_embeddings (
  id BIGSERIAL PRIMARY KEY,
  content TEXT,
  embedding VECTOR(768),
  metadata JSONB,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Cosine similarity query
SELECT content, metadata,
  1 - (embedding <=> '[query_embedding_here]') AS similarity
FROM cv_embeddings
ORDER BY similarity DESC
LIMIT 5;

If you are building n8n automation with Supabase RAG, always verify your vector dimensions match your embedding model before anything else. This one mistake cost half a day.

How This Architecture Powers Our Client Automation Builds

After building this system, the same RAG architecture became the foundation for several client automation and growth pipelines at Exora Leads. Instead of processing engineering CV assets, we hook the exact same vector framework up to internal enterprise data like technical catalogs, corporate B2B matrices, and lead databases:

  • Local SEO & Map Pack Systems: We use our Local SEO Agency West Midlands frameworks to capture high-intent buyer clicks across Edgbaston and Birmingham, routing incoming traffic directly into context-rich landing experiences.
  • Automated Lead Qualification: We deploy specialized workflows via our AI & CRM Automation Agency Birmingham to intercept inbound web leads, instantly running context checks to qualify and follow up with prospects via SMS or WhatsApp in under 60 seconds.
  • Enterprise Pipeline Growth: We sync these vector meshes with our B2B Lead Generation Birmingham engines, dynamically mapping new client requests directly to your business's available field engineering capacities.

If you want to see how this translates into a business result, read our lead generation guide or explore our AI and CRM automation service.

Deploying Automation Under UK GDPR & Data Governance Standards

When handling professional profiles, customer databases, or proprietary engineering documentation, data privacy cannot be an afterthought. Under the UK GDPR and Data Protection Act (DPA 2018), passing unencrypted business intelligence through third-party cloud aggregators introduces severe liability.

This is exactly why we champion self-hosted n8n configurations paired with secure Supabase environments on isolated UK infrastructure. By containerizing your database stack, your proprietary intellectual property and client interactions remain strictly enclosed within your business perimeter—completely protected from being ingested into open-web AI public training sets.

n8n Automation Pricing for UK Businesses [2026]

ServiceTypical CostDelivery Time
Simple workflow (1–3 nodes)£299–£4993–5 days
Medium workflow (4–8 nodes, AI integration)£599–£9991–2 weeks
Complex workflow (RAG, multi-step, error handling)£1,200–£2,5002–4 weeks
Ongoing maintenance and monitoring£99–£199 per monthMonthly

Results After 30 Days of Running the Automation

MetricBefore AutomationAfter Automation
Time spent per application25 minutes2 minutes (review only)
Applications per week12–1540–50
Follow-up consistencyInconsistent100% automated
Hours saved per week~18 hours

Conclusion — Ready to Automate Your UK Business?

Building AI-powered operational automation with n8n and Supabase is no longer just an interesting technical exercise — it is a foundational business necessity for UK companies that want to scale revenue without exponentially growing their headcount.

The exact context-aware RAG architecture that powers this multi-modal document pipeline is the very same baseline engine behind the automated growth funnels we design every day for B2B enterprises across West Drayton, West London, and the wider UK market.

If you want to eliminate your team's manual administrative bottlenecks, let’s audit your current setup. Book a discovery call today, and we will map out your operational workflows to show you precisely what can be automated—and exactly how many hours you will reclaim each week.

👉 Book Your Free Strategy Consultation

Ready to get started?

Let's automate your workflows and build intelligent systems for your business.

Explore AI & CRM Automation →

Frequently Asked Questions

What is n8n and can it be used to build AI automation workflows?
n8n is an open-source workflow automation tool that lets you connect apps, APIs, and AI models using a visual node-based editor. Yes — it supports AI Agent nodes, LLM integrations, and tool calling. It runs locally or on a cloud server, giving you full control over your data. For UK businesses, the self-hosting option is particularly valuable for GDPR compliance.
What is RAG and how does it work with Supabase?
RAG (Retrieval-Augmented Generation) is a technique where relevant data is fetched from a database at query time and injected into the AI model's prompt, rather than relying on the model's training data alone. With Supabase, you store text embeddings in a pgvector column and run cosine similarity queries to retrieve the most relevant chunks for a given input. This gives your AI accurate, up-to-date context without fine-tuning the model.
Why does my Supabase vector store return no results even when the workflow succeeds?
The most common cause is a vector dimension mismatch. If your embedding model outputs 768-dimension vectors but your table's VECTOR column is defined as VECTOR(1536), inserts silently fail with no error. Check that your table schema matches your model's output dimensions exactly — Gemini text-embedding-004 requires VECTOR(768). Drop and recreate the table with the correct definition, then re-run your ingestion workflow.
How do I handle inconsistent AI Agent outputs in n8n production workflows?
Use two layers of protection. First, add a structured output tool to the AI Agent node that forces the model to return a defined JSON schema with required keys. Second, add an IF node after the Agent that checks for those keys and routes failures to a simpler fallback workflow using a smaller model and tighter prompt. This combination prevents hard crashes and keeps the workflow running even when the primary model behaves unexpectedly.
How much does n8n automation cost for a UK small business?
Simple workflows (1–3 nodes) typically cost £299–£499 with a 3–5 day delivery. Medium workflows with AI integration run £599–£999 over 1–2 weeks. Complex RAG-based workflows with full error handling cost £1,200–£2,500 over 2–4 weeks. Ongoing maintenance is £99–£199 per month. Exora Leads builds and manages n8n automation for UK clients — contact us for a free workflow audit.

Comments

Leave a comment

0/1200