Creating an AI-Powered Data Analyst using n8n
Imagine having an AI system that can query a million rows of data. What would that mean for your business? In this article, we will explore how to build an AI data analyst using n8n, a no-code platform, to connect to any SQL database and generate insights instantly.
Introduction to the Project
The project involves building an AI-powered data analyst using n8n, a no-code platform, to connect to a BigQuery database and process over a million rows of data from a Google Analytics dataset. The goal is to create a system that can provide instant insights from data using natural language queries.
Dataset Overview
The dataset used for this project is the Google Analytics sample dataset in BigQuery, which contains around a million rows of traffic data from a Google merchandise store. The data includes information about traffic sources, content data, and user behavior on the website.
System Breakdown
The system consists of two main agents: the main agent and the database query tool. The main agent is responsible for understanding the user's intent, analyzing the query, and identifying the filters and tables to focus on when creating the SQL query. The database query tool, on the other hand, generates the equivalent SQL query and executes it against the BigQuery database.
Demo and Results
The system is demonstrated by asking several questions, including data exploration questions, such as finding the earliest and latest data points in the dataset, and more complex questions, such as counting the total number of sessions per month and finding the top five operating systems with the most traffic.
Database Query Tool
The database query tool is used to convert natural language queries into SQL queries and execute them against the BigQuery database. The tool uses a simple and fast language model, such as the GPT-3 Mini model, and is connected to a Postgres chat memory to keep track of the context.
Frontend and Logging
The system uses a simple Streamlit application as a frontend to communicate with the agent. The logs are tracked using a Google Sheets node, which makes it easy to monitor the agent and ensure it is outputting the correct SQL queries.
Results and Insights
The system is able to provide instant insights from the data, including the earliest and latest data points, the total number of sessions per month, and the top five operating systems with the most traffic. The results are presented in a user-friendly format, making it easy to understand and analyze the data.
Conclusion and Future Work
The project demonstrates the power of building an AI-powered data analyst using n8n and BigQuery. The system can be taken further by automating charts from the tables and visualizing the data in an automated way. The possibilities are truly endless, and the system can be used to provide instant insights from large datasets using natural language queries.
Final Thoughts
The project highlights the potential of using no-code platforms like n8n to build complex systems that can provide instant insights from large datasets. The system can be used in various industries, including marketing, finance, and operations, to make data-driven decisions.