ChatGPTSalesCustomer supportAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

n8n Template: WhatsApp AI Chatbot (Text/Voice/Image/Document + RAG)

Auto-index Google Docs product documentation into MongoDB Atlas, receive multi-type WhatsApp messages, and answer with GPT-4o-mini using retrieval-augmented generation

ExperiencedStepsWorkflowPrompt
Who
Internal support teams, product specialists, and knowledge managers
You get
Users send text, audio, image, or document via WhatsApp; the system retrieves product docs and returns context-aware AI answers
You need
n8n · mongodb-atlas · whatsapp · google-docs

Constraints

Prerequisites: n8n instance; OpenAI API key; MongoDB Atlas cluster (vector search index required); Google Docs OAuth2 credentials; Meta WhatsApp Business account and API credentials; HTTP Header Auth credentials (for media downloads). Costs: OpenAI per-token, MongoDB Atlas per-cluster, WhatsApp Business API per-message.

What they did

Author thomasgpt (NovaNode) published an official template on n8n.io containing two workflows: Workflow one manually triggers import from Google Docs, chunks documents, generates OpenAI embeddings, and stores them in MongoDB Atlas vector database. Workflow two listens for WhatsApp messages via WhatsApp Trigger, supports four message types (text, audio, image, document), routes and preprocesses each type, then uses a Knowledge Base Agent with GPT-4o-mini, vector retrieval, and conversation memory to generate answers, finally replying via WhatsApp API.

How it went

The template description claims this solution reduces manual documentation search time for support agents, delivering accurate and quick AI answers via RAG (author_report). The template has 259,220 views on n8n.io.

Worth knowing

1) The Knowledge Base Agent's systemMessage is an empty string in the template and must be filled by the user; 2) The WhatsApp send node's phoneNumberId is hardcoded as 677680658761861 and must be replaced; 3) Simple Memory's sessionKey is based on the WhatsApp contact ID, sharing memory across multi-turn conversations for the same user; 4) The document processing branch uses a Code node to map calendar/xml MIME types, and unmapped types receive 'The File type you provided is unsupported.'; 5) This site has not tested the workflow (reproduction=not_tested); actual operation requires verifying credential permissions and webhook reachability.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • OpenAI Chat Model node: connect OpenAI API credentials.
  • Embeddings OpenAI node: connect OpenAI API credentials.
  • MongoDB Vector Search node: connect mongoDb credentials.
  • MongoDB Vector Store Inserter node: connect mongoDb credentials.
  • OpenAI Embeddings Generator node: connect OpenAI API credentials.
  • Google Docs Importer node: connect googleDocsOAuth2Api credentials.
  • WhatsApp Trigger node: connect whatsAppTriggerApi credentials.
  • OpenAI node: connect OpenAI API credentials.
  • OpenAI1 node: connect OpenAI API credentials.
  • Gets WhatsApp Voicemail Source URL node: connect whatsAppApi credentials.
  • Gets WhatsApp Image Source URL node: connect whatsAppApi credentials.
  • Gets WhatsApp Document Source URL node: connect whatsAppApi credentials.
  • Download Voicemail node: connect HTTP Header Auth credentials.
  • Download Image node: connect HTTP Header Auth credentials.
  • Download Document node: connect HTTP Header Auth credentials.
  • Send Unsupported Response node: connect whatsAppApi credentials.
  • Send Response node: connect whatsAppApi credentials.

Configuration to replace

  • Source template is n8n public workflow #4827 (~35 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-25

Steps

  1. Configure vector embeddings and document indexing environment

    Set up connections for the ingestion workflow: 1) Authorize Google Docs OAuth2 and enter the product document URL; 2) Connect MongoDB Atlas cluster in the MongoDB node credentials, specify collection name (e.g., n8n-template); 3) Ensure a vector search index exists on the collection with the same name configured in n8n (default data_index); 4) Create the index using the MongoDB search index template below.

    Setup guidance · Source text。MongoDB Atlas search index JSON definition; create via Atlas console or CLI

    {
      "mappings": {
        "dynamic": false,
        "fields": {
          "_id": { "type": "string" },
          "text": { "type": "string" },
          "embedding": {
            "type": "knnVector",
            "dimensions": 1536,
            "similarity": "cosine"
          },
          "source": { "type": "string" },
          "doc_id": { "type": "string" }
        }
      }
    }
  2. Configure WhatsApp Q&A workflow

    Configure connections for receiving and replying to WhatsApp messages: 1) Enter Meta account credentials in the WhatsApp Trigger and WhatsApp nodes to enable message receiving and sending; 2) Connect the MongoDB Vector Search node to the same collection (n8n-template) with index name data_index; 3) Set the system prompt in the Knowledge Base Agent node to reflect your company's tone, answering style, and business rules, ensuring it references the connected MongoDB collection for context retrieval.

  3. Execute document ingestion and indexing workflow

    Manually trigger 'Execute Workflow' to run the ingestion workflow. Flow: Google Docs Importer fetches document → Document Section Loader loads content with doc_id metadata → Document Chunker splits by markdown (chunkSize=3000, chunkOverlap=200) → OpenAI Embeddings Generator creates 1536-dim vectors → MongoDB Vector Store Inserter writes chunks and embeddings to Atlas. After successful run, the product documentation is indexed for semantic search.

    Setup guidance · Source text。Sticky Note instruction; reminder before manual workflow trigger

    Run this workflow manually to import and index Google Docs product documentation into MongoDB with vector embeddings for fast search.
  4. Run WhatsApp AI Q&A workflow

    The workflow is auto-triggered by WhatsApp Trigger. Incoming messages are routed by the Route Types Switch: Text extracts message body directly; Audio gets media URL via WhatsApp API, downloads via HTTP Request, then transcribed to text by OpenAI audio/translate; Image gets URL via WhatsApp API, downloads via HTTP Request, then analyzed by OpenAI image/analyze (gpt-4o-mini, detail=auto) to generate description; Document gets URL via WhatsApp API, downloads via HTTP Request, then a Code node maps file extensions, and a Route Document Types Switch routes by MIME type to Extract from PDF/XLS/XLSX nodes for text extraction, ultimately formatting as a text field. All branches feed into the Knowledge Base Agent, which uses Simple Memory (sessionKey based on user's WhatsApp ID) for multi-turn context, retrieves relevant document chunks via MongoDB Vector Search (retrieve-as-tool, toolName=productDocs), generates answers with OpenAI Chat Model (gpt-4o-mini), and sends replies via the Send Response WhatsApp node.

    Setup guidance · Source text。Sticky Note1 instruction; overall workflow capability summary

    This workflow listens for WhatsApp messages (text, audio, image, documents), converts them into embeddings, searches MongoDB, and uses GPT-4o-mini to provide context-aware answers with conversation memory.

    Execution prompt · Source text。Map text prompt node (n8n-nodes-base.set); maps WhatsApp text message body to text field output to Knowledge Base Agent

    ={{ $json.messages[0].text.body }}

    Execution prompt · Source text。Map image prompt node (n8n-nodes-base.set); merges OpenAI image analyze result with image caption into text field

    =User image description: {{ $json.content }}
    
    User image caption: {{ $('Route Types').item.json.messages[0].image.caption }}

    Execution prompt · Source text。Map document prompt node (n8n-nodes-base.set); merges document extraction result with caption and MIME type into text field

    =Parsed text: {{ $json.text || $json.data || $json }}
    
    Caption text: {{ $('Route Types').item.json.messages[0].document.caption }}
    
    MimeType: {{ $('Gets WhatsApp Document Source URL').item.json.mime_type }}

    Execution prompt · Source text。Map file extensions node (n8n-nodes-base.code); normalizes MIME types for Route Document Types Switch

    let requests = $("Download Document").all()
    
    requests.forEach((request) => {
      let mime_type = request.json.mime_type
    
      if (
        mime_type === "text/calendar" || 
        mime_type === "application/ics" || 
        mime_type === "text/x-calendar"
      ) {
        request.json.mime_type = "mapped/calendar"
      }
    
      if (
        mime_type === "application/xml" || 
        mime_type === "text/xml") {
        request.json.mime_type = "mapped/xml"
      }
    
      if (!mime_type) {
        request.json.mime_type = $('Gets WhatsApp Document Source URL').first().json.mime_type
      }
    })
    
    return requests;

Prompt you can copy

Setup guidance · Editorial suggestion。Give to setup assistant; confirm inputs, permissions, and test plan in order

This block is the prompt. Ads are never placed here.

You are setting up a WhatsApp AI support system on n8n. Proceed in this order: 1) Confirm you have an OpenAI API key, MongoDB Atlas cluster (M10+ for vector search), Google Docs document link, and Meta WhatsApp Business account; 2) Import this template workflow into n8n; 3) Configure all credentials (Google Docs OAuth2, MongoDB, OpenAI, WhatsApp Trigger, WhatsApp API, HTTP Header Auth); 4) Create a vector search index in MongoDB Atlas (index name data_index, dimensions 1536, similarity cosine); 5) First run the document ingestion workflow manually in test environment to verify chunking and embedding; 6) Configure WhatsApp webhook to point to your n8n instance; 7) Test sending text, voice, image, and PDF messages to verify each branch processes correctly and returns context-relevant answers.

This prompt is an editorial setup starter, not a node execution instruction. Node-specific prompts are in each step's prompts array.

Source

AI-powered WhatsApp chatbot for text, voice, images, and PDF with RAG · thomasgpt · n8n.io · 2025-06-09

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related