AI Sales Agent for WhatsApp using RAG and PDF Knowledge Base - n8n Workflow

Automate customer service on WhatsApp using this n8n workflow. Deploy an AI Sales Agent powered by GPT-4o and a PDF-based RAG knowledge base for instant product query answers using the n8n trigger.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Businesses needing 24/7 customer support automation via WhatsApp.

  • Organizations looking to deploy a Retrieval-Augmented Generation (RAG) system using internal PDFs.

  • Developers seeking robust n8n templates for advanced AI agent deployments.

  • Users wanting to integrate the OpenAI GPT-4o model with real-time communication channels.

Overview

This comprehensive n8n workflow provides a powerful solution for automating product support via WhatsApp. It leverages advanced AI techniques, specifically RAG, to ensure answers are factual and based directly on your supplied product documentation (a PDF brochure). Instead of deploying complex, expensive chatbot infrastructure, you can use this simple n8n setup. The workflow first creates a high-quality vector store from the PDF. Then, using the WhatsApp n8n trigger, it intercepts incoming messages. The core AI Sales Agent n8n node utilizes conversation memory and the custom RAG tool to pull relevant information before generating a helpful, professional response using the GPT-4o model. This approach significantly reduces human support load while improving response quality and speed.

How it Works

This n8n workflow operates in two main phases: setup and live execution.

Phase 1: Knowledge Base Setup (One-Time Run)


  1. Download PDF: The initial step uses a Manual Trigger and an HTTP Request n8n node to download the product brochure (a PDF file).

  2. Extract Data: The Extract from File n8n node processes the PDF, converting its contents into raw text.

  3. Vectorization: The text is split into manageable chunks, embedded using the Embeddings OpenAI1 n8n node (text-embedding-3-small), and then stored in the Product Catalogue (In-Memory Vector Store). This prepares the RAG knowledge base.

Phase 2: Live Conversation Execution


  1. Incoming Message: The automation is initiated by the WhatsApp Trigger n8n node when a customer sends a message.

  2. Message Filter: A Switch n8n node checks the message type. If it is not a 'text' message (e.g., audio, image), the flow is diverted to immediately reply that non-text messages are unsupported, using a WhatsApp n8n node.

  3. AI Processing: If the message is text, it proceeds to the central AI Sales Agent n8n node.

  4. RAG and Memory: The agent uses the Window Buffer Memory to maintain conversation context with the specific user. It then calls the Vector Store Tool, which queries the Product Catalogue vector store to retrieve contextually relevant information from the PDF.

  5. Response Generation: The OpenAI Chat Model (GPT-4o) n8n node synthesizes the user query, the conversation history, and the retrieved facts to generate a precise answer.

  6. Final Reply: The resulting text output from the agent is sent back to the customer via the final WhatsApp n8n node, completing the execution of this powerful n8n workflow.

Installation Guide

To deploy these n8n templates successfully, follow these steps:


  1. Import Workflow: Copy the provided n8n workflow JSON and paste it into your n8n instance.

  2. Set Up Credentials:

Configure your OpenAI API credentials for the OpenAI Chat Model and Embeddings OpenAI n8n nodes.
Set up your WhatsApp account credentials for the WhatsApp Trigger and subsequent WhatsApp sending n8n nodes, ensuring webhooks are properly configured to receive incoming messages.

  1. Knowledge Base Setup: Locate the manual trigger node ('When clicking ‘Test workflow’'). This part of the n8n workflow only needs to run once.

Ensure the URL in the get Product Brochure HTTP Request n8n node points to your correct product PDF.
Execute the manual trigger to download the PDF, extract the content, and populate the In-Memory Vector Store. You must run this setup step before activating the main WhatsApp Trigger n8n node.

  1. Activation: Once setup is complete and credentials are configured, activate the main n8n workflow to start listening for incoming WhatsApp messages.

Node Details

WhatsApp Trigger: This crucial n8n trigger monitors your specified WhatsApp webhook for new incoming messages, launching the n8n workflow upon detection.
get Product Brochure (HTTP Request): Downloads the raw PDF file containing the product catalog knowledge base.
Extract from File: Specifically configured for operation: pdf, this n8n node parses the binary PDF data and extracts all the text content.
Recursive Character Text Splitter: Used during the setup phase to break the large text document into smaller, optimized chunks for better vector embedding and Retrieval-Augmented Generation (RAG).
Embeddings OpenAI: Utilizes the text-embedding-3-small model to convert the text chunks into dense vector representations.
Create Product Catalogue (Vector Store In-Memory): This n8n node acts as the in-memory database, storing the vector embeddings of the product information. It is set to mode: insert and clears existing data before insertion.
AI Sales Agent (Agent n8n node): The primary logic handler. It receives the user's message, manages context via memory, and determines if it needs to use the Vector Store Tool before consulting the GPT-4o model.
Window Buffer Memory: Manages the multi-turn conversation, ensuring the AI agent remembers previous questions and answers during the current customer session.
Vector Store Tool: An integral part of the RAG system. This tool allows the AI Sales Agent n8n node to dynamically query the product catalogue vector store for relevant facts, limiting hallucinations.
OpenAI Chat Model (GPT-4o): Provides the core linguistic intelligence for the agent, generating high-quality, conversational, and factual replies based on the retrieved context.
Handle Message Types (Switch n8n node): Implements flow control logic, diverting non-text messages to a different path to ensure the AI agent only processes supported text input.
Reply To User (WhatsApp): The final action n8n node, responsible for sending the AI agent’s generated response back to the original WhatsApp sender.

Related n8n Workflows

Free

Nodes: 15 Nodes
Updated: December 26 2025
View all
Created by

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

Featured*