Skip to main content

Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework

Workflow preview

Workflow preview
100%
Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n template demonstrates how to deploy an AI workflow in production while simultaneously running a robust, data driven Evaluation Framework to ensure quality and optimize costs. Use Cases Mod...

Best for

  • Lead Generation automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.sentimentanalysis, n8n-nodes-base.gmail, n8n-nodes-base.gmailtrigger, n8n-nodes-base.evaluationtrigger, n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-base.evaluation, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mihai Farcas.

Original n8n.io source

1.1 Workflow description

Title
Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework
Workflow name
Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework

This n8n template demonstrates how to deploy an AI workflow in production while simultaneously running a robust, data-driven Evaluation Framework to ensure quality and optimize costs.

Use Cases

Model Comparison: Quickly A/B test different LLM models (e.g., Gemini 3 Pro vs. Flash Lite) for speed and cost efficiency against your specific task.

Prompt Regression: Ensure that tweaks to your system prompt do not introduce new errors or lower the accuracy of your lead categorization.

Production Safety: Guarantee that test runs never trigger real-world actions like sending emails to a client or sales team.

Requirements

A configured Gmail Trigger (or equivalent email trigger).

A Google Gemini account for the LLM models.

An n8n Data Table containing your "Golden Dataset" of test cases and ground truths.

How it Works

The workflow contains two distinct, parallel execution paths:

Production Path:

The Gmail Trigger monitors for new emails.

The email text is routed through the Sentiment Analysis node, which categorizes the lead as Positive, Neutral, or Negative.

Check if Evaluating nodes verify the current execution mode. If it is not an evaluation run (the Fail branch), the lead is routed to the corresponding Send Email node for action.

Evaluation Path:

The When fetching a dataset row trigger pulls test cases (input text and expected sentiment/ground truth) from an n8n Data Table.

Each test case loops through the same Sentiment Analysis node.

The Check if Evaluating nodes route this path to the Success branch, skipping the real email actions.

The Save Output node writes the model's prediction to the Data Table.

The Set Metrics node uses the Categorization metric to compare the prediction against the ground truth, returning a score (0 or 1) to measure accuracy.

Key Technical Details

Model Switching: Multiple Google Gemini Chat Model nodes are connected via the Model input on the Sentiment Analysis node, allowing you to easily swap and compare models without changing the core logic.

Edge Case Handling: The System Prompt Template in the Sentiment Analysis node is customized to handle tricky inputs, such as negative feedback about a competitor that should be classified as a Positive lead.

Metrics: The workflow uses the built-in Categorization metric, which is ideal for classification tasks like sentiment analysis, to provide objective evidence of performance.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sentiment Analysis

Type / Role
@n8n/n8n-nodes-langchain.sentimentAnalysis - sentimentAnalysis
Config choices
Version 1.1

Block 2 - Send Hot Lead Email

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 3 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.2

Block 4 - Send Marketing Insights Email

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 5 - Send Follow-up Notification

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 6 - When fetching a dataset row

Type / Role
n8n-nodes-base.evaluationTrigger - evaluationTrigger
Config choices
Version 4.7

Block 7 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 8 - Google Gemini 3 PRO

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 9 - Google Gemini 2.5 Flash Lite

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 10 - Google Gemini 2.5 Flash

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 11 - Set Metrics

Type / Role
n8n-nodes-base.evaluation - evaluation
Config choices
Version 4.8

Block 12 - Save Output

Type / Role
n8n-nodes-base.evaluation - evaluation
Config choices
Version 4.8

Block 13 - Check Neutral

Type / Role
n8n-nodes-base.evaluation - evaluation
Config choices
Version 4.8

Block 14 - Check Positive

Type / Role
n8n-nodes-base.evaluation - evaluation
Config choices
Version 4.8

Block 15 - Check Negative

Type / Role
n8n-nodes-base.evaluation - evaluation
Config choices
Version 4.8

Block 16 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework
Complexity advanced
Nodes 20
Categories Lead Generation, AI Summarization
Author Mihai Farcas
Published 15 Dec 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/11832/11832.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Sales lead routing with Gemini Sentiment Analysis & Model Evaluation Framework do?

This n8n template demonstrates how to deploy an AI workflow in production while simultaneously running a robust, data driven Evaluation Framework to ensure quality and optimize costs. Use Cases Mod...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Lead Generation, AI Summarization use case.