Skip to main content

Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs

Workflow preview

Workflow preview
100%
Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Workflow Execution Link: Watch Execution Video Workflow Pre requisites Step 1: Supabase Setup First, replace the keys in the "Save the embedding ...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.whatsapptrigger, n8n-nodes-base.googledocs, n8n-nodes-base.code, n8n-nodes-base.httprequest, n8n-nodes-base.supabase, n8n-nodes-base.aggregate, n8n-nodes-base.stickynote, n8n-nodes-base.manualtrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by iamvaar.

Original n8n.io source

1.1 Workflow description

Title
Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs
Workflow name
Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs
Workflow Execution Link:

Watch Execution Video

Workflow Pre-requisites

Step 1: Supabase Setup

First, replace the keys in the "Save the embedding in DB" & "Search Embeddings" nodes with your new Supabase keys. After that, run the following code snippets in your Supabase SQL editor:

  1. Create the table to store chunks and embeddings:

    CREATE TABLE public."RAG"
    (
        id bigserial PRIMARY KEY,
        chunk text NULL,
        embeddings vector(1024) NULL
    )
    TABLESPACE pg_default;
    
  2. Create a function to match embeddings:

    DROP FUNCTION IF EXISTS public.matchembeddings1(integer, vector);
    
    CREATE OR REPLACE FUNCTION public.matchembeddings1(
        match_count integer,
        query_embedding vector
    )
    RETURNS TABLE (
        chunk text,
        similarity float
    )
    LANGUAGE plpgsql
    AS $$
    BEGIN
        RETURN QUERY
        SELECT
            R.chunk,
            1 - (R.embeddings <=> query_embedding) AS similarity
        FROM public."RAG" AS R
        ORDER BY R.embeddings <=> query_embedding
        LIMIT match_count;
    END;
    $$;
    

Step 2: Create Knowledge Base

Create a new Google Doc with the complete knowledge base about your business and replace the document ID in the "Content for the Training" node.

Step 3: Get Together AI API Key

Get a Together AI API key and paste it into the "Embedding Uploaded document" node and the "Embed User Message" node.

Step 4: Setup Meta App for WhatsApp Business Cloud

  1. Go to https://business.facebook.com/latest/settings/apps, create an app, and select the use case "Connect with customer through WhatsApp". Copy the Client ID and Client Secret and add them to the first node.

  2. Go to that newly created META app in the app dashboard, click on the use case, and then click on "customise...". Go to the API setup, add your number, and also generate an access token on that page. Now paste the access token and the WhatsApp Business Account ID into the send message node.

Part A: Document Preparation (One-Time Setup)

1. When clicking ‘Execute workflow’

  • Type: manualTrigger
  • Purpose: Manually starts the workflow for preparing training content.

2. Content for the Training

  • Type: googleDocs
  • Purpose: Fetches the document content that will be used for training.

3. Splitting into Chunks

  • Type: code
  • Purpose: Breaks the document text into smaller pieces for processing.

4. Embedding Uploaded document

  • Type: httpRequest
  • Purpose: Converts each chunk into embeddings via an external API.

5. Save the embedding in DB

  • Type: supabase
  • Purpose: Stores both the chunks and embeddings in the database for future use.

Part B: Chat Interaction (Realtime Flow)

1. WhatsApp Trigger

  • Type: whatsAppTrigger
  • Purpose: Starts the workflow whenever a user sends a WhatsApp message.

2. If

  • Type: if
  • Purpose: Checks whether the incoming WhatsApp message contains text.

3. Embend User Message

  • Type: httpRequest
  • Purpose: Converts the user’s message into an embedding.

4. Search Embeddings

  • Type: httpRequest
  • Purpose: Finds the top matching document chunks from the database using embeddings.

5. Aggregate

  • Type: aggregate
  • Purpose: Merges retrieved chunks into one context block.

6. AI Agent

  • Type: langchain agent
  • Purpose: Builds the prompt combining user’s message and context.

7. Google Gemini Chat Model

  • Type: lmChatGoogleGemini
  • Purpose: Generates the AI response based on the prepared prompt.

8. Send message

  • Type: whatsApp
  • Purpose: Sends the AI’s reply back to the user on WhatsApp.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - WhatsApp Trigger

Type / Role
n8n-nodes-base.whatsAppTrigger - whatsAppTrigger
Config choices
Version 1

Block 2 - Content for the Training

Type / Role
n8n-nodes-base.googleDocs - googleDocs
Config choices
Version 2

Block 3 - Splitting into Chunks

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - Embedding Uploaded document

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 5 - Save the embedding in DB

Type / Role
n8n-nodes-base.supabase - supabase
Config choices
Version 1

Block 6 - Aggregate

Type / Role
n8n-nodes-base.aggregate - aggregate
Config choices
Version 1

Block 7 - Search Embeddings

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 8 - Embend User Message

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 9 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - When clicking ‘Execute workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 12 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 13 - Send message

Type / Role
n8n-nodes-base.whatsApp - whatsApp
Config choices
Version 1

Block 14 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2.2

Block 15 - If

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

3. Summary Table

Workflow Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs
Complexity advanced
Nodes 15
Categories Internal Wiki, AI RAG
Author iamvaar
Published 23 Sept 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/8865/8865.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build a knowledge-based WhatsApp assistant with RAG, Gemini, Supabase & Google Docs do?

Workflow Execution Link: Watch Execution Video Workflow Pre requisites Step 1: Supabase Setup First, replace the keys in the "Save the embedding ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.