Data Tables in N8N - Building AI Agents with Database Integration

25 min
Lesson 1 of 4

Learn how to build AI agents that interact with N8N data tables for eCommerce product management and real estate FAQ systems using workflow automation

Data Tables in N8N Tutorial

In this tutorial, you'll learn how to build sophisticated AI-powered agents using N8N's data tables feature. The system demonstrates two powerful use cases: an eCommerce AI agent that manages product data and performs price calculations, and a real estate AI agent that provides FAQ responses from a knowledge base.

Data Tables in N8N

System Overview

The Data Tables in N8N system consists of two main AI agents working with structured data:

  1. eCommerce AI Agent - Manages product data and performs price calculations
  2. Real Estate AI Agent - Provides FAQ responses from a real estate knowledge base
  3. Data Table Integration - Seamless connection between Google Sheets and N8N data tables

eCommerce AI Agent Configuration

The eCommerce agent specializes in product management, fetching product data from data tables and performing various price calculations.

System Prompt for eCommerce Agent

Here's a simple system prompt for a Products AI Agent that fetches all products from a data table and performs arithmetic calculations on the prices:

---

**System Prompt:**

You are a Products AI Agent. Your main tasks include:

1. **Fetching Product Data**: Access a database or data table to retrieve a list of all products. Each product will have details like name, price, description, and other relevant fields.

2. **Performing Calculations**: Perform basic arithmetic operations on product prices, such as:

   * Calculating discounts: `Price - (Price * Discount Percentage)`
   * Adding tax: `Price + (Price * Tax Percentage)`
   * Calculating price differences: `Price1 - Price2`

**Example of tasks you can perform:**

* Retrieve all products and show their names and prices.
* Calculate the total price of products after applying a discount.
* Calculate the final price of a product including tax.

Keep your responses clear and precise. When performing calculations, always provide the step-by-step formula used to arrive at the result.

Key Features

  • Product Data Retrieval: Automatically fetches all products from the connected data table
  • Price Calculations: Performs complex arithmetic operations on product prices
  • Discount Management: Calculates discounted prices with percentage-based reductions
  • Tax Calculations: Adds tax to product prices with configurable tax rates
  • Price Comparisons: Compares prices between different products

Real Estate AI Agent Configuration

The Real Estate agent provides intelligent FAQ responses for Dubai Properties, accessing a comprehensive knowledge base stored in data tables.

System Prompt for Real Estate Agent

**System Prompt for "Dubai Properties" FAQ AI Agent**

You are an AI assistant for the "Dubai Properties" real estate platform. Your task is to provide accurate answers based on the FAQ information available for the property. You have access to the tool `get_faqs` to fetch the relevant FAQ data and provide responses. Please follow these guidelines:

1. **Responding to Questions:**

   * If the question is related to a topic available in the FAQs, retrieve the corresponding answer and provide it.
   * If the question is not addressed in the FAQs, respond with:

     * "We don't have any information about it. We will forward this to Team."

2. **Tone and Style:**

   * Maintain a professional, clear, and friendly tone when responding.
   * Be concise and ensure that your response directly answers the question.

3. **Handling Multiple Queries:**

   * If the user asks multiple questions, answer each one based on the available FAQs. If an answer is missing for any question, follow the above guideline for unaddressed queries.

**Example Interaction:**

**User Query:**
"Can you tell me about the availability of 3-bedroom apartments in Dubai Properties?"

**Response:**
"Sure! Let me check the FAQ for information on 3-bedroom apartments..."
*fetches relevant FAQ*
"Yes, we do have 3-bedroom apartments available in multiple locations. Please check with our team for specific availability."

**User Query:**
"Is there any information about the parking facilities?"

**Response:**
"We don't have any information about it. We will forward this to Team."

Key Features

  • FAQ Knowledge Base: Comprehensive database of frequently asked questions
  • Intelligent Search: Semantic search capabilities for finding relevant FAQ entries
  • Professional Responses: Maintains consistent, professional tone in all interactions
  • Fallback Handling: Graceful handling of questions not covered in the FAQ database
  • Team Escalation: Automatic escalation for unanswered queries

Data Table Integration

The system seamlessly integrates Google Sheets data with N8N data tables, enabling real-time data synchronization and management.

Google Sheets to Data Tables Workflow

The workflow automatically:

  1. Fetches Data: Retrieves product and FAQ data from Google Sheets
  2. Transforms Data: Converts sheet data into structured data table format
  3. Populates Tables: Inserts or updates records in N8N data tables
  4. Maintains Sync: Keeps data synchronized between sheets and tables

Data Table Schema

Products Data Table

  • Title: Product name and description
  • Price: Product pricing information
  • Body: Detailed product description (HTML format)
  • Tags: Product categorization tags

Real Estate FAQ Data Table

  • Question: FAQ question text
  • Answer: Comprehensive answer content
  • Category: FAQ category classification
  • Priority: Response priority level

Setup Process

1. Google Sheets Preparation

Before setting up the agents, prepare your data sources:

  1. Product Data Sheet: Create a sheet with columns for Title, Variant Price, Body (HTML), and Tags
  2. FAQ Data Sheet: Create a sheet with questions, answers, categories, and priority levels
  3. Data Validation: Ensure all required fields are populated and formatted correctly

2. N8N Data Tables Configuration

Configure your N8N data tables:

  1. Create Data Tables: Set up "Products DB" and "Real Estate FAQ DB" tables
  2. Define Schema: Configure appropriate field types and constraints
  3. Import Data: Use the Google Sheets integration to populate initial data
  4. Test Connections: Verify data table accessibility and query functionality

3. AI Agent Deployment

Deploy the complete AI agent system:

  1. Import Workflow: Use the provided N8N workflow template
  2. Configure Credentials: Set up OpenAI API and Google Sheets credentials
  3. Test Agents: Run end-to-end tests with sample queries
  4. Monitor Performance: Set up logging and monitoring for agent responses

Usage Examples

eCommerce Agent Examples

Example 1: Product Listing

User Input: "Show me all products with their prices"

Agent Process:

  1. Queries the Products data table
  2. Retrieves all product records
  3. Formats and displays product names with prices
  4. Provides organized product catalog

Example 2: Price Calculation

User Input: "Calculate the price of Product A with 15% discount and 8% tax"

Agent Process:

  1. Finds Product A in the data table
  2. Applies 15% discount calculation
  3. Adds 8% tax to discounted price
  4. Shows step-by-step calculation process

Real Estate Agent Examples

Example 1: Property Inquiry

User Input: "What are the amenities available in Dubai Properties?"

Agent Process:

  1. Searches FAQ database for amenities information
  2. Retrieves relevant FAQ entries
  3. Provides comprehensive amenities list
  4. Maintains professional tone throughout

Example 2: Unavailable Information

User Input: "What's the pet policy for the properties?"

Agent Process:

  1. Searches FAQ database for pet policy
  2. Finds no matching entries
  3. Responds with standard fallback message
  4. Escalates query to team for follow-up

Advanced Features

Calculator Integration

The eCommerce agent includes advanced calculator functionality:

  • Complex Formulas: Supports multi-step price calculations
  • Percentage Operations: Handles discount and tax percentage calculations
  • Comparison Operations: Enables price comparison between products
  • Bulk Calculations: Processes multiple products simultaneously

Memory Management

Both agents feature conversation memory:

  • Context Retention: Remembers previous queries and responses
  • Session Continuity: Maintains conversation flow across multiple interactions
  • Personalization: Adapts responses based on user interaction history

Next Steps

With this data tables system in place, you can:

  1. Expand Product Catalog - Add more products and categories to your data tables
  2. Enhance FAQ Database - Continuously update and expand your knowledge base
  3. Customize Agent Behavior - Adjust prompts and responses for specific business needs
  4. Integrate Additional Tools - Connect with CRM systems, inventory management, or customer support platforms
  5. Scale Operations - Handle increased query volume with optimized data table performance

This system demonstrates the power of combining AI agents with structured data storage, enabling intelligent automation for both eCommerce and real estate applications while maintaining data consistency and professional service quality.

Download Templates

Data Tables Tutorials Template