This AI agent can remember everything and provide tailored information about your business, like if it were the best sales assistant you’ve ever had
Table of Contents
- Introduction: Understanding AI-Powered Database Conversations
- What You Need to Know Before Starting
- Understanding the Core Technologies
- Prerequisites and Account Setup
- Step-by-Step Implementation Guide
- Configuring Your RAG Agent with Memory
- Testing and Optimisation
- Troubleshooting Common Issues
- Best Practices for Small Businesses
- Conclusion and Next Steps
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
What You Need to Know Before Starting
Before diving into the technical implementation, it’s crucial to understand what you’re building and why each component matters for your business. This section will help you make informed decisions about whether this solution is right for your organisation and what you can expect from the implementation process.
📊 Business Impact
- Traditional data access is slow or requires technical skills.
- A RAG agent acts like an intelligent data assistant: it retrieves, analyses, and connects insights.
- It learns from past questions and gets smarter over time — ideal for small businesses.
⏱ Time Investment & Learning
- Setup takes 4–8 hours total, depending on complexity.
- No need to learn technical tools — just ask questions naturally.
- Be patient during setup; rushing can lead to poor performance.
🧩 Data Requirements
- Works best with structured data in databases like Supabase.
- Consolidate your CRM, e-commerce, and spreadsheet data into one place.
- Clean, consistent data = better results, but it handles imperfections too.
🔐 Security & Privacy
- Supabase offers strong security: encryption, access control, and compliance.
- OpenAI doesn’t train on your data, but always check provider policies.
- Add extra protections if handling sensitive info (e.g. data masking, audits).
Requirements
- n8n: v1.70 or later
- Wassenger account: Sign up for free to get API access
- API Key: obtain your API key here
- WhatsApp number: At least one WhatsApp number connected to Wassenger
- OpenAI API credentials: you can get them from here
- Google Account
- Supabase account
Important! 💬 If you’re new to using n8n with Wassenger, check out our setup guide to get started quickly.
Now, let’s create our new AI Agent! 🤖
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Step-by-Step Implementation Guide
Now that you have your accounts set up and credentials gathered, it’s time to build the actual RAG agent workflow within n8n. This section provides a detailed, step-by-step guide to creating the workflow with Wassenger, configuring each node, and connecting the different components. Follow these instructions carefully, referring back to your gathered credentials and the n8n documentation as needed.
Step 1: Create Your Wassenger Account
Sign up for a Wassenger account to get instant WhatsApp API access without Meta’s WABA approval process. Wassenger offers several advantages for this type of bot:
- Instant activation: Start building your memory bot immediately
- No template restrictions: Allow natural conversations without pre-approved templates
- Rich media support: Exchange images, documents, and other media types
- Advanced webhook system: Seamlessly integrate with n8n
Step 2: Install the Official Wassenger Node in n8n
- In n8n, go to Settings > Community Nodes
- Search for “n8n-nodes-wassenger” and install it
- Add your Wassenger API key to n8n
Step 3: Setting Up the Trigger Node
Okay, now that we are inside our new Workflow, we are going to create the connection with Wassenger in the following way:
Click on ‘Add first step’
Then search for “Wassenger”. Remember, you need to install the Wassenger node first. If you haven’t done it yet, check out our related article here.
Then select the ‘On new inbound message received’ trigger
A window like this will open
Now, we need to add our Wassenger API credentials to connect n8n with Wassenger:
- Go to the API key page in Wassenger and copy the given API key or create one
2. And copy it into the n8n trigger
Then, select the connected WhatsApp number on Wassenger that you want to trigger the event and go back to your canvas
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
4. Connect your Wassenger Webhook to n8n
Now, for n8n to receive all message notifications when a contact texts you, we need to set up a new webhook
- Go to the Webhooks page here
- Create a new Webhook
Then
- Name your webhook
- Add the webhook URL that you will find in the first node we created in n8n
3. Select the number you want to transfer messages from
4. Select the event message:in:new
5. Save your new Webhook in Wassenger
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
5. Connect the OpenAI chat Model
A window like this will open, and we will insert our OpenAI credentials
Create an OpenAI account and find your credentials here
Then add it to n8n
Now we will add a system message to indicate to the IA some extra instructions, like who the AI is talking to (Customer) and the precise time of the conversation:
You are an AI assistant that helps users query our company database hosted on Supabase (PostgreSQL).
You have access to tools that can list database tables, describe table schemas (columns and types), and execute SQL queries.
When a user asks a question, first determine which tables might contain the relevant information. Use the schema tools if necessary to understand the table structure.
Then, formulate a precise SQL query to retrieve the data. Execute the query using the SQL tool. Finally, synthesize the retrieved data into a clear, natural language response for the user.
Always prioritize accuracy and rely solely on the data retrieved from the database. If the necessary information isn't available, state that clearly.
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥
6. Adding Tools for Database Interaction
The AI Agent needs tools to interact with your Supabase database. These tools allow the agent to explore the database structure and execute queries based on user requests. You’ll add these tools within the AI Agent node’s configuration under the “Tools” section.
- Postgres Memory node: Add a memory node from your AI agent
Now, set the credentials from your Supabase project. Create yours here
A new view will open, select PSQL from the Connection Type
Now, refer to the ‘Transaction Pooler’
And we will configure the postgres credentials from the given information
And:
- Host
- User
- The password you set when creating the Projecto on Supabase
- Port: normally
6543
Now, test the workflow:
And if you head back to Supabase, you will see a new table called ‘n8n_chat_histories’
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥
7. Add the Supabase Vecto Store
And set up the credentials:
Then
And copy the API key
Now add the API key to n8n and save
Now we will add a SQL script to initialize your database
-- Enable the pgvector extension to work with embedding vectors
create extension vector;
-- Create a table to store your documents
create table documents(
id bigserial primary key,
content text, -- corresponds to Document.pageContent
metadata jsonb, -- corresponds to Document.metadata
embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);
-- Create a function to search for documents
create function match_documents(
query_embedding vector(1536),
match_count int default null,
filter jsonb DEFAULT '{}'
) returns table(
id bigint,
content text,
metadata jsonb,
similarity float
)
language plpgsql
as $
#variable_conflict use_column
begin
return query
select
id,
content,
metadata,
1 -(documents.embedding <= > query_embedding) as similarity
from documents
where metadata @> filter
order by documents.embedding <= > query_embedding
limit match_count;
end;
$;
Then, copy it here:
After clicking run, we should get this message
Now, we should have a new list called Documents
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥
8. Add the information about your Business to Vectorize
Now, we are going to add a Google Drive node called ‘Download File’
Then:
- Set all the credentials for Google with n8n
If you don’t know how to connect your Google account to n8n, watch this tutorial
2. Select the file that contains all the information about your Business. Create one or import all your Business data like: Pricing, plans, FAQs, etc.
If you test the step, you will get the binary file of your Drive Doc:
Now, we will add the ‘Supabase Vector Store’ node using the ‘Add documents to vector store’ action:
And select the table we created on Supabase earlier called ‘Documents’
Now, we will add the ‘Embeddings’ node using OpenAI and the ‘Default data loader’
Inside the ‘Default Data Loader’ set the file as Binary
Now we can test the Supabase node to get the information in our List
Now we go back to the Supabase Vector Store
- Select ‘Retrieve Documents’
- Enter the name of the file you downloaded from Google Drive ‘Health Clinic’ for this tutorial
- Select the tale from Supabase that you will use as we selected previously
Then, add the ‘Embeddings’
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥
9. Add the Wassenger node to send a message back to your customers
And configure the module
- Credentials to connect with: Wassenger Key account
- Resource: Send Message
- Operation: Send Text Message
- WhatsApp number: Your Connected Number
- Target: Phone
- Target:
{{ $(Wassenger Trigger’).item.json.data.fromNumber }}` - Message:
{{ $json.output }}
And there we have it! Our bot is fully configured! Now we can test the workflow to verify that everything is working correctly.
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥
Here you can find the full workflow JSON ready to use
{
"name": "AI Agent with Supabase And Postgres",
"nodes": [
{
"parameters": {
"webhookName": "n8n postgres",
"device": "device_id",
"events": ["message:in:new"]
},
"type": "n8n-nodes-wassenger.wassengerTrigger",
"typeVersion": 1,
"position": [0, 0],
"id": "62962ca0-705b-4838-bd83-f33d4c5ee920",
"name": "Wassenger Trigger",
"webhookId": "6e6c612c-3234-4049-8c60-097d7d8cc423",
"credentials": {
"wassengerApiKey": {
"id": "9du3UAbFSzEaTSQE",
"name": "WhatsApp API key"
}
}
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [220, 220],
"id": "ba68b0b8-16d3-422b-8481-90b88a771f24",
"name": "OpenAI Chat Model"
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $json.data.id }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [360, 220],
"id": "cd126557-052b-4c2f-a3cb-4ce2ec3f39c1",
"name": "Postgres Chat Memory"
},
{
"parameters": {
"operation": "download",
"fileId": {
"__rl": true,
"value": "1H6f5cFCiyg6i1Up4DjnExdBsZZaiZFT956G3Cl-I2lo",
"mode": "list",
"cachedResultName": "Health Clinic",
"cachedResultUrl": "GET_URL"
},
"options": {}
},
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 3,
"position": [1080, 400],
"id": "f9e8d30b-4923-4dd0-9bcc-7f535919ff7c",
"name": "Google Drive"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [1160, 660],
"id": "46c51c13-f629-4cf8-97c2-fbe9c4bd2a76",
"name": "Embeddings OpenAI"
},
{
"parameters": {
"mode": "retrieve-as-tool",
"toolName": "healthClinic",
"toolDescription": "Use this to get information about the health clinic",
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1.1,
"position": [540, 220],
"id": "a0d25c4e-c77a-4316-a26e-b77184549902",
"name": "Supabase Vector Store1"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
"typeVersion": 1.2,
"position": [500, 400],
"id": "a992c5ce-820c-4c2d-9ed8-89d5e62621e8",
"name": "Embeddings OpenAI1"
},
{
"parameters": {
"dataType": "binary",
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
"typeVersion": 1,
"position": [1360, 660],
"id": "a92fd932-349e-4c10-8b74-bb556b31bc58",
"name": "Default Data Loader"
},
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
"typeVersion": 1,
"position": [1320, 840],
"id": "f2c3d2eb-e607-4143-b417-838bdb9a446d",
"name": "Recursive Character Text Splitter"
},
{
"parameters": {
"mode": "insert",
"tableName": {
"__rl": true,
"value": "documents",
"mode": "list",
"cachedResultName": "documents"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
"typeVersion": 1.1,
"position": [1360, 400],
"id": "d2a763c5-885a-41b1-8d9a-868035c17278",
"name": "Supabase Vector Store2"
},
{
"parameters": {
"device": "device_id",
"phone": "={{ $('Wassenger Trigger').item.json.data.fromNumber }}",
"message": "={{ $json.output }}",
"options": {}
},
"type": "n8n-nodes-wassenger.wassenger",
"typeVersion": 1,
"position": [680, 0],
"id": "ccc66b83-1545-483c-9577-1ae60ab0ee3b",
"name": "Wassenger"
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.data.body }}",
"options": {
"systemMessage": "You are an AI assistant that helps users query our company database hosted on Supabase(PostgreSQL).You have access to tools that can list database tables, describe table schemas(columns and types), and execute SQL queries.When a user asks a question, first determine which tables might contain the relevant information.Use the schema tools if necessary to understand the table structure.Then, formulate a precise SQL query to retrieve the data.Execute the query using the SQL tool.Finally, synthesize the retrieved data into a clear, natural language response for the user.Always prioritize accuracy and rely solely on the data retrieved from the database.If the necessary information isn't available, state that clearly."
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.8,
"position": [280, 0],
"id": "d18faa47-f3bf-471c-bd2c-cbefd59b108c",
"name": "AI Agent"
}
],
"pinData": {},
"connections": {
"Wassenger Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Google Drive": {
"main": [
[
{
"node": "Supabase Vector Store2",
"type": "main",
"index": 0
}
]
]
},
"Embeddings OpenAI": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store2",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Supabase Vector Store1": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Embeddings OpenAI1": {
"ai_embedding": [
[
{
"node": "Supabase Vector Store1",
"type": "ai_embedding",
"index": 0
}
]
]
},
"Default Data Loader": {
"ai_document": [
[
{
"node": "Supabase Vector Store2",
"type": "ai_document",
"index": 0
}
]
]
},
"Recursive Character Text Splitter": {
"ai_textSplitter": [
[
{
"node": "Default Data Loader",
"type": "ai_textSplitter",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Wassenger",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
}
}
Measuring Success and ROI
Establish metrics to measure the success and return on investment of your RAG agent system:
- Time Savings: Track how much time the system saves in data analysis tasks compared to previous methods. This can be measured through user surveys or by comparing the time required for similar analyses before and after implementation.
- Usage Patterns: Monitor how frequently the system is used, which types of queries are most common, and which team members are getting the most value from it. This information can guide future optimizations and expansions.
- Decision-Making Impact: Assess how the improved access to data insights affects business decisions. Look for examples where the RAG agent provided information that led to positive business outcomes.
- Cost-Benefit Analysis: Regularly review the operational costs of the system against the value it provides. This includes not just the direct costs of the services used, but also the opportunity costs of the time invested in implementation and maintenance.
Why Wassenger Outperforms Other WhatsApp API Solutions for Memory Bots
- No approval delays: Start building your memory bot immediately without waiting for Meta’s WABA approval process
- No template restrictions: Create natural, conversational responses without the limitations of pre-approved templates
- Richer interactions: Include images, documents, videos, and other media in your automated responses
- Easier setup: The official n8n node eliminates complex configuration steps
- More affordable: Wassenger is typically more cost-effective than WABA-based providers
Ready to Transform Your Customer Conversations?
With Wassenger, n8n, and Google Gemini, your small business can create a WhatsApp bot that truly remembers your customers, building stronger relationships, increasing satisfaction, and driving loyalty through personalised interactions.
🚀 🤖 Try Wassenger free for 7 days and see how easy it is to create an AI chatbot for WhatsApp. For technical questions, explore our comprehensive API documentation or test integration scenarios with our API Tester featuring over 100 examples. 🔥























































