HomeAI AgentsHow to Build an AI Chatbot…
AI Agents

How to Build an AI Chatbot That Queries Your Baserow Database with n8n

How to Build an AI Chatbot That Queries Your Baserow Database with n8n

Your team keeps pinging you with the same questions: “What’s the status on the Carter account?” or “How many orders came in from Texas last week?” The answers already live in your database — the problem is that nobody wants to learn how to query it. What if they could just ask, in plain English, and get the answer back in seconds? That’s exactly what you’ll build in this guide: an AI chatbot powered by n8n, OpenAI GPT-4o Mini, and Baserow that lets anyone on your team talk to your data without writing a single query.

Prefer to skip the setup? Grab the ready-made template → and be up and running in under 10 minutes.

What You’ll Build

  1. A user opens the n8n chat widget and types a question like “Show me all pending orders from California.”
  2. An AI agent interprets the question, queries your Baserow database for matching records, and formats the results.
  3. The chatbot replies with a clear, readable answer — no SQL, no filters, no training needed.
  4. Follow-up questions work naturally because the chatbot remembers the conversation context.

How It Works — The Big Picture

The whole system is a single n8n workflow with four connected components. The Chat Trigger receives the user’s message, passes it to an AI Agent that decides what to look up, queries Baserow through a built-in tool, and streams the answer back — all while keeping a memory buffer so the conversation flows naturally.

┌──────────────────────────────────────────────────────────────────────┐
│  AI CHATBOT — QUERY BASEROW DATABASE                                │
│                                                                      │
│  [Chat Trigger] ──→ [Database Query Agent] ──→ Chat Response         │
│                           │       │                                  │
│                    ┌──────┘       └──────┐                           │
│                    ↓                     ↓                           │
│           [OpenAI GPT-4o Mini]   [Conversation Memory]               │
│                                         │                            │
│                                  [Query Baserow]                     │
│                                    (AI Tool)                         │
└──────────────────────────────────────────────────────────────────────┘
  

What You’ll Need

  • A self-hosted or cloud n8n instance (version 1.0 or later)
  • An OpenAI account with an API key — GPT-4o Mini costs roughly $0.15 per million input tokens, so this is very affordable
  • A Baserow account (free tier works) with at least one database table containing the data you want to query
  • About 15 minutes to set everything up from scratch

Estimated build time: 15–20 minutes from scratch, or under 5 minutes with the template.

Building the Chatbot — Step by Step

1 Chat Trigger (Chat Trigger Node)

This is the entry point. The Chat Trigger node creates a built-in chat widget inside n8n where users can type their questions. When someone sends a message, the node captures the text and passes it downstream.

  1. In your n8n canvas, click Add node and search for Chat Trigger.
  2. Drop it on the canvas. The default settings work — no configuration needed.
  3. This node will automatically generate a chat URL you can share, or you can embed the widget on any page.

After this node fires, the data looks like this:

{
  "chatInput": "Show me all pending orders from California",
  "sessionId": "a7f3e2b1-9c4d-4e8a-b5f6-1234567890ab"
}
💡

Tip: Each conversation gets a unique sessionId. The memory node uses this to keep separate conversation threads — so multiple people can chat at the same time without mixing up context.

2 Database Query Agent (AI Agent Node)

The AI Agent is the brain of this workflow. It receives the user’s question, decides whether it needs to query the database, calls the Baserow tool if needed, and composes a human-readable response. Think of it as a smart middleman between your user and your data.

  1. Add an AI Agent node and connect it to the Chat Trigger’s output.
  2. Open the node settings and find the System Message field under Options.
  3. Paste this system prompt (customize it to describe your specific data):
You are a helpful data assistant. Your job is to answer user questions by querying the connected Baserow database.

Rules:
1. Always use the Baserow tool to look up real data before answering.
2. If the user asks a question you cannot answer from the database, say so clearly.
3. Format numbers, dates, and lists in a readable way.
4. Keep answers concise — summarize large result sets instead of dumping raw rows.
5. If the query returns no results, suggest the user rephrase or check their filters.
💡

Tip: The more specific your system prompt is about your data schema, the better the agent performs. If your table has columns like order_status, customer_state, and total_amount, mention them in the prompt so the agent knows exactly what fields to filter on.

3 OpenAI GPT-4o Mini (Chat Model Node)

This node provides the language model that powers the agent’s reasoning. GPT-4o Mini is the sweet spot here — it’s fast, cheap (fractions of a cent per query), and accurate enough for database lookups and conversational responses.

  1. Add an OpenAI Chat Model node (@n8n/n8n-nodes-langchain.lmChatOpenAi).
  2. Connect it to the AI Language Model input on the Agent node (the bottom-left connector).
  3. Set the Model to gpt-4o-mini.
  4. Under Options, set Temperature to 0.3 — you want factual, consistent answers, not creative ones.
  5. Set Max Tokens to 2048 — enough for detailed responses without runaway costs.
  6. Select your OpenAI credential (or create a new one by pasting your API key).
📌

You can swap in gpt-4o for more complex reasoning, but for most database Q&A tasks, GPT-4o Mini handles the job well and costs about 10x less.

4 Conversation Memory (Buffer Window Memory Node)

Without memory, every message would be a brand-new conversation. The Buffer Window Memory node stores the last 12 exchanges so the agent understands context. When a user asks “What about New York?” right after asking about California orders, the agent knows they mean orders from New York.

  1. Add a Window Buffer Memory node.
  2. Connect it to the AI Memory input on the Agent node (the bottom-center connector).
  3. Set Session ID Type to From Input — this uses the Chat Trigger’s session ID automatically.
  4. Set Context Window Length to 12. This means the agent remembers the last 12 messages (6 pairs of user + assistant).
💡

Tip: If your users tend to ask long, multi-part questions, increase the window to 20. If you want to save on token costs, drop it to 6. The trade-off is context awareness vs. cost per conversation.

5 Query Baserow (Baserow Tool Node)

This is where the magic happens. The Baserow Tool node gives the AI Agent the ability to search, filter, and read rows from your Baserow table. The agent decides when to use it and what to search for — you just need to point it at the right table.

  1. Add a Baserow node (specifically the Baserow Tool variant for AI agents).
  2. Connect it to the AI Tool input on the Agent node (the bottom-right connector).
  3. Select your Baserow credential (API token — you’ll find this in your Baserow account settings).
  4. Set the Database ID — you can find this in your Baserow URL: https://baserow.io/database/YOUR_ID.
  5. Set the Table ID — click into any table and check the URL for the table number.

When the agent calls this tool, it gets back rows like this:

[
  {
    "id": 142,
    "order_id": "ORD-2026-0891",
    "customer_name": "James Carter",
    "customer_email": "james.carter@gmail.com",
    "customer_state": "CA",
    "order_status": "Pending",
    "total_amount": 249.99,
    "created_at": "2026-04-07"
  },
  {
    "id": 143,
    "order_id": "ORD-2026-0892",
    "customer_name": "Emily Rodriguez",
    "customer_email": "emily.rodriguez@outlook.com",
    "customer_state": "CA",
    "order_status": "Pending",
    "total_amount": 89.50,
    "created_at": "2026-04-08"
  }
]

The agent then reads this data, formats it, and responds to the user with something like: “There are 2 pending orders from California — one for James Carter ($249.99) and one for Emily Rodriguez ($89.50), totaling $339.49.”

The Data Structure

Your Baserow table is the foundation of this whole system. The chatbot can only answer questions about data that exists in your table, so the schema matters. Here’s an example for an order tracking table:

Column Type Example Description
order_id Text ORD-2026-0891 Unique order identifier
customer_name Text James Carter Full name of the customer
customer_email Email james.carter@gmail.com Customer contact email
customer_state Text CA Two-letter US state code
order_status Single Select Pending Current status: Pending, Shipped, Delivered, Cancelled
total_amount Number 249.99 Order total in USD
created_at Date 2026-04-07 Date the order was placed
📌

Column names should be descriptive and snake_case. The AI agent uses column names to understand what each field contains, so customer_state works much better than col_7. If your existing table has cryptic column names, consider renaming them — it makes a real difference in answer quality.

Here’s what the data lifecycle looks like with a few sample rows:

order_id customer_name customer_state order_status total_amount
ORD-2026-0891 James Carter CA Pending $249.99
ORD-2026-0887 Sarah Thompson TX Shipped $175.00
ORD-2026-0879 Michael Chen NY Delivered $312.50

Full System Flow

┌─────────────────────────────────────────────────────────────────────────┐
│                                                                         │
│  USER types question          n8n CHAT WIDGET                           │
│  "Show pending CA orders"  →  [Chat Trigger]                            │
│                                     │                                   │
│                                     ▼                                   │
│                            [Database Query Agent]                       │
│                             GPT-4o Mini brain                           │
│                                │         │                              │
│                      ┌─────────┘         └──────────┐                   │
│                      ▼                              ▼                   │
│             [Conversation Memory]          [Query Baserow]              │
│              12-message window              Reads table rows            │
│                                                    │                    │
│                                                    ▼                    │
│                                          ┌─────────────────┐           │
│                                          │  BASEROW TABLE   │           │
│                                          │  Orders, Leads,  │           │
│                                          │  Inventory, etc. │           │
│                                          └─────────────────┘           │
│                                                    │                    │
│                      ▼                             │                    │
│           Agent formats answer  ◄──────────────────┘                    │
│                      │                                                  │
│                      ▼                                                  │
│  USER receives      "There are 2 pending orders                         │
│  formatted answer    from California totaling $339.49"                  │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘
  

Testing Your Workflow

  1. Save your workflow and make sure all four nodes are connected (Chat Trigger → Agent, with the model, memory, and tool feeding into the Agent’s sub-connectors).
  2. Click Chat in the bottom-right of the n8n canvas to open the built-in chat panel.
  3. Type a simple question: How many rows are in the table? — This tests the basic connection.
  4. Ask a filtered question: Show me all orders from California — This tests the agent’s ability to apply filters.
  5. Ask a follow-up: Which of those are still pending? — This tests conversation memory.
  6. Ask something the database can’t answer: What's the weather in Chicago? — The agent should politely decline.
Problem Likely Cause Fix
Agent says “I don’t have access to any tools” Baserow Tool node not connected to the Agent’s AI Tool input Check the connection — it should link to the wrench/tool connector on the Agent node, not the main input
Agent returns empty results for valid queries Wrong Database ID or Table ID in the Baserow node Double-check both IDs against your Baserow URL — they’re numeric IDs, not names
“Authentication failed” error Invalid or expired Baserow API token Generate a new token in Baserow → Settings → API tokens, and update the credential in n8n
Follow-up questions don’t work Memory node not connected or Session ID not set Ensure the Buffer Window Memory connects to the AI Memory port, and Session ID Type is set to “From Input”
Responses are slow (10+ seconds) Large table with thousands of rows Add a view filter in Baserow to limit the rows the tool can access, or switch to a more targeted query setup

Frequently Asked Questions

Can I use this with a free Baserow account?

Yes. Baserow’s free tier includes API access, which is all this workflow needs. The free plan supports up to 3,000 rows per table. If your dataset is larger, you’ll need a paid Baserow plan or a self-hosted instance.

How much does it cost to run per month?

Very little. GPT-4o Mini charges roughly $0.15 per million input tokens and $0.60 per million output tokens. A typical database query conversation uses about 2,000–4,000 tokens total. If your team runs 100 queries per day, you’re looking at maybe $2–5 per month in OpenAI costs. The n8n and Baserow free tiers cover everything else.

Can I connect multiple tables to the same chatbot?

Yes — add additional Baserow Tool nodes for each table and connect them all to the Agent’s AI Tool input. The agent will decide which table to query based on the user’s question. Just make sure your system prompt describes what each table contains so the agent picks the right one.

Can I embed the chat widget on my website?

n8n’s Chat Trigger generates a URL that you can embed as an iframe or integrate with n8n’s chat widget library. For production use, you might want to swap the Chat Trigger for a Webhook node and build a custom frontend — but for internal team use, the built-in widget works great.

What if I want to use Google Sheets instead of Baserow?

Swap the Baserow Tool node for a Google Sheets Tool node (or use an HTTP Request tool with the Sheets API). The rest of the workflow stays the same. Baserow has an edge for structured queries because it supports filters natively, but Google Sheets works fine for smaller datasets.

Is my data sent to OpenAI?

Yes — the rows retrieved from Baserow are sent to OpenAI as part of the prompt so the model can formulate an answer. If you’re working with sensitive data, review OpenAI’s data usage policy or consider using a self-hosted LLM (like Ollama) instead of GPT-4o Mini.

Get the Baserow AI Chatbot Template

Skip the setup — get the pre-built workflow JSON, a step-by-step setup guide, and a credentials walkthrough so you’re live in under 5 minutes.

Get the Template →

Instant download · Works on n8n Cloud and self-hosted

What’s Next?

  • Add a Slack or Telegram interface — replace the Chat Trigger with a Slack or Telegram trigger so your team can query the database directly from their messaging app.
  • Connect multiple data sources — add Airtable, Google Sheets, or a Postgres database alongside Baserow to build a unified data assistant.
  • Add write capabilities — extend the agent with a Baserow “create row” tool so users can add or update records through the chat (e.g., “Mark order ORD-2026-0891 as shipped”).
  • Schedule automated reports — add a Schedule Trigger that runs a predefined query every morning and sends the results to your team channel.
n8n
Baserow
OpenAI
GPT-4o Mini
AI Agent
chatbot
database automation
no-code