Automated AI Agent Testing using Evaluation Node and Gemini - n8n Workflow

Learn to build a robust n8n workflow for automated AI evaluation. Use the n8n Evaluation node, Google Gemini, and Google Sheets to test and score AI Agent performance automatically. Access powerful n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI/ML Engineers needing to automate QA testing for their Large Language Model (LLM) prompts.
Data scientists who use Google Sheets to manage test datasets and ground truths.
n8n users interested in mastering advanced flow control and the specialized n8n Evaluation tool.
Developers looking for practical n8n templates integrating AI agents and data validation.

Overview

Testing the reliability and accuracy of AI Agents is crucial before deployment. This sophisticated n8n workflow provides a robust solution for automated AI quality assurance. It solves the problem of manual verification by connecting Google Sheets—where your test questions (inputs) and expected answers (ground truths) are stored—directly to an AI Agent powered by Google Gemini.

The core of this n8n automation leverages the specialized n8n Evaluation node, which operates in two distinct modes: fetching test data and setting metrics. The workflow automatically sends a prompt to the AI Agent, captures its response, writes the actual output back to the sheet, and finally uses a second LLM to assign a 'Correctness' score based on how closely the AI Agent's answer matches the expected answer. This n8n workflow offers reliable, hands-free quality testing for complex AI automations.

How it Works

This n8n workflow is designed with two distinct paths: a structured evaluation path and a manual execution path.


  1. Triggering the Evaluation: The primary evaluation path starts with the When fetching a dataset row n8n trigger, which pulls one row (input text and expected output) from the designated Google Sheets evaluation dataset.

  2. AI Agent Processing: The input text is passed to the AI Agent n8n node, which uses the Google Gemini Chat Model and the Calculator tool to process the query and generate a response.

  3. Flow Control: The workflow hits the Evaluation? n8n node, which checks if the current execution is part of an evaluation run. In evaluation mode, the flow continues down the true path.

  4. Recording Output: The Get output n8n node saves the AI Agent's response, and the Set output Evaluation n8n node writes this actual output back to the Google Sheet against the corresponding test case.

  5. Metric Scoring: The crucial step involves the Corectness Evaluation n8n node. This node uses the Google Gemini Chat Model1 to analyze the difference between the actual output and the expected output (ground truth), generating an objective 'Correctness' score (metric).

  6. Recording Metrics: Finally, the Set correctness n8n node takes this calculated metric and writes the final score back to the Google Sheet, completing the automated test cycle. This efficient use of the n8n node system ensures comprehensive testing.

For manual runs, the workflow is initiated by the When clicking ‘Execute workflow’ n8n trigger, uses a default test query, passes through the AI Agent, and exits via the Return chat response node.

Installation Guide

To use this n8n workflow template, follow these steps:


  1. Import: Copy the entire n8n workflow JSON provided and import it into your n8n instance.

  2. Google Sheets Setup: You must clone the sample Google Sheet provided in the sticky note's instructions. Ensure this sheet contains 'input' and 'expected_output' columns.

  3. Credentials Setup:

Google Sheets: Set up your Google Sheets OAuth2 API credentials. This must have read/write access to the sheet used for evaluation.
Google Gemini (PaLM/Generative AI): Configure your Google Gemini credentials for both Google Gemini Chat Model and Google Gemini Chat Model1 (required for both AI operations and evaluation scoring).

  1. Configure Evaluation Trigger: Open the When fetching a dataset row n8n trigger and select your cloned Google Sheet and the relevant tab (Foglio1 or equivalent).

  2. Configure Evaluation Setter Nodes: Verify that the Set output Evaluation and Set correctness n8n nodes are also pointed to your specific Google Sheet and document ID.

  3. Activation: Save and activate the n8n workflow. Use the 'Run evaluation' button on the trigger node to initiate the automated scoring process.

Node Details

When fetching a dataset row (Evaluation Trigger n8n trigger): This special n8n trigger node initiates the evaluation process by connecting to Google Sheets, fetching one row of test data (input query and expected answer).
AI Agent (Langchain Agent n8n node): Serves as the primary system under test. It receives the input query, is configured with a helpful system message, and has access to the Calculator tool for numerical tasks.
Google Gemini Chat Model (Language Model n8n node): Provides the language model capabilities for the AI Agent to execute complex instructions and generate the initial output.
Evaluation? (Evaluation n8n node - Check Operation): Acts as a conditional switch, detecting whether the current execution run was started by the Evaluation Trigger or manually, allowing the n8n workflow to branch correctly.
Set output Evaluation (Evaluation n8n node - Set Output Operation): This n8n node is responsible for writing the actual response generated by the AI Agent back into the Google Sheet dataset under the actual_output column.
Corectness (Evaluation n8n node - Set Metric Operation): The core scoring component. It compares the actualAnswer against the expectedAnswer using the specified Google Gemini Chat Model1 to generate a metric score (Correctness), effectively using an LLM to grade another LLM's performance. This is a powerful application of the n8n node.


  • Set correctness (Evaluation n8n node - Set Output Operation): Writes the final 'Correctness' metric score, calculated by the preceding n8n node, back to the Google Sheet to complete the evaluation record.

Related n8n Workflows

Free

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

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza

Featured*