Automate Data Flows with N8N
Promptfoo example for evaluating n8n AI agent workflows through a webhook-triggered provider.
Why it matters
Orchestrate and automate complex data workflows by integrating with N8N. This asset enables seamless data extraction, transformation, and loading across various applications and databases.
Outcomes
What it gets done
Connect to N8N to trigger automated workflows.
Extract data from various sources.
Perform ETL (Extract, Transform, Load) operations.
Query and move data between systems.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/pfoo-n8n-agent | bash Steps
Steps in the chain
Overview
N8N Agent
A promptfoo example for evaluating n8n AI agent workflows via a webhook provider, with auto-parsed response formats, a custom transformResponse option, and multi-turn session handling. Use when an AI agent is built as an n8n workflow and needs evaluating like any other promptfoo provider. Not usable without a self-hosted n8n instance exposing a webhook-triggered agent workflow.
What it does
This promptfoo example evaluates n8n AI agents and workflows via the n8n provider, using a self-hosted n8n instance and a webhook-triggered AI agent workflow.
npx promptfoo@latest init --example n8n-agent
It points promptfooconfig.yaml at the workflow's webhook URL (n8n:https://your-n8n-instance.com/webhook/your-agent-id), sends test inputs, and captures whatever the workflow returns. The provider auto-parses common n8n response shapes - {"output": ...}, {"response": ...}, {"message": {"content": ...}}, or an array of {"json": {"output": ...}} - or a custom shape via a transformResponse JavaScript expression, for example json.data.agentMessage. Config options cover url, method (default POST; GET sends rendered fields as query parameters), headers, a Nunjucks-templated body (object form preferred for JSON), and session handling via sessionHeader, sessionParser, and sessionField, so multi-turn tests can keep a conversation scoped to one session using sessionId in test variables or a multi-turn strategy.
When to use - and when NOT to
Use it when an AI agent is built as an n8n workflow (a Webhook trigger plus an AI Agent or OpenAI node) and needs evaluating like any other promptfoo provider. It is not usable without a self-hosted n8n instance exposing a webhook-triggered agent workflow.
Inputs and outputs
Input is an n8n workflow with a Webhook trigger that returns the agent's response, its webhook URL configured in promptfooconfig.yaml, and optionally N8N_API_KEY if the webhook requires authentication. Output is evaluation results viewable via promptfoo view, with the agent's response auto-extracted from a common n8n format or via a custom transformResponse expression.
Integrations
Calls the n8n webhook directly over HTTP; credentials should live in environment-backed headers rather than being embedded in the webhook URL. The provider uses a fingerprinted display ID and skips response caching, so tokenized URLs and session-bearing requests don't enter cache diagnostics or storage - though URLs still appear in configuration and outbound requests.
Who it's for
Teams building AI agents as n8n workflows who want to evaluate agent responses with promptfoo instead of testing manually.
Source README
n8n-agent (n8n AI Agent Evaluation)
You can run this example with:
npx promptfoo@latest init --example n8n-agent
This example demonstrates how to evaluate n8n AI agents and workflows using the n8n provider.
Prerequisites
- A self-hosted n8n instance with a webhook-triggered workflow
- An AI agent workflow that accepts messages and returns responses
Setup
- Create an n8n workflow with a Webhook trigger node
- Add your AI agent logic (e.g., AI Agent node, OpenAI node)
- Configure the workflow to return the agent's response
- Update
promptfooconfig.yamlwith your webhook URL:
providers:
- id: n8n:https://your-n8n-instance.com/webhook/your-agent-id
Environment Variables
export N8N_API_KEY=your-api-key # If your webhook requires authentication
Running the Example
### Run the evaluation
npx promptfoo eval
### View results
npx promptfoo view
Configuration Options
url: Webhook URL (alternative to specifying in provider path)method: HTTP method (default:POST);GETsends rendered body fields as query parametersheaders: Additional request headersbody: Custom request body template with Nunjucks support; prefer object form for JSON payloadstransformResponse: JavaScript expression to extract outputsessionHeader: Request header name for the session IDsessionParser: JavaScript expression to extract a session IDsessionField: Request body field for a supplied session ID
For multi-turn runs, pass sessionId in test variables or use a multi-turn strategy so sessions
remain scoped to one conversation. Keep webhook credentials in environment-backed headers rather
than embedding them in webhook URLs. The provider uses a fingerprinted display ID and skips
response caching so tokenized URLs and session-bearing requests do not enter response-cache
diagnostics or storage; URLs still remain in configuration and outbound requests.
Response Formats
The provider automatically handles common n8n response formats:
{ "output": "Response text" }
{ "response": "Agent response" }
{ "message": { "content": "Hello" } }
[{ "json": { "output": "Result" } }]
For custom formats, use transformResponse:
config:
transformResponse: 'json.data.agentMessage'
For more information, see the n8n Provider documentation.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.