Skip to main content

Split test different agent prompts with Supabase and OpenAI

Workflow preview

Workflow preview
100%
Split test different agent prompts with Supabase and OpenAI preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Split Test Agent Prompts with Supabase and OpenAI Use Case Oftentimes, it's useful to test different settings for a large language model in production against various metrics. Split testing is a go...

Best for

  • Engineering automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.supabase, n8n-nodes-base.if, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.memorypostgreschat, 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 Chris Carr.

Original n8n.io source

1.1 Workflow description

Title
Split test different agent prompts with Supabase and OpenAI
Workflow name
Split test different agent prompts with Supabase and OpenAI

Split Test Agent Prompts with Supabase and OpenAI

Use Case

Oftentimes, it's useful to test different settings for a large language model in production against various metrics. Split testing is a good method for doing this.

What it Does

This workflow randomly assigns chat sessions to one of two prompts, the baseline and the alternative. The agent will use the same prompt for all interactions in that chat session.

How it Works

  1. When messages arrive, a table containing information regarding session ID and which prompt to use is checked to see if the chat already exists
  2. If it does not, the session ID is added to the table and a prompt is randomly assigned
  3. These values are then used to generate a response

Setup

  1. Create a table in Supabase called split_test_sessions. It needs to have the following columns: session_id (text) and show_alternative (bool)
  2. Add your Supabase, OpenAI, and PostgreSQL credentials
  3. Modify the Define Path Values node to set the baseline and alternative prompt values.
  4. Activate the workflow and test by sending messages through n8n's inbuilt chat
  5. Experiment with different chat sessions to test see both prompts in action

Next Steps

  • Modify the workflow to test different LLM settings such as temperature
  • Add a method to measure the efficacy of the two alternative prompts

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 - When chat message received

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

Block 2 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.7

Block 3 - Check If Session Exists

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

Block 4 - If Session Does Exist

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 5 - Assign Path To Session

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

Block 6 - Define Path Values

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 8 - Postgres Chat Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryPostgresChat - memoryPostgresChat
Config choices
Version 1.3

Block 9 - Sticky Note1

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

Block 10 - Sticky Note

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

Block 11 - Sticky Note2

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

Block 12 - Get Correct Prompt

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Sticky Note6

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

Block 14 - Sticky Note8

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

Block 15 - Sticky Note5

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

Block 16 - Sticky Note3

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

3. Summary Table

Workflow Split test different agent prompts with Supabase and OpenAI
Complexity advanced
Nodes 16
Categories Engineering, AI Chatbot
Author Chris Carr
Published 24 Feb 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2992/2992.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 Split test different agent prompts with Supabase and OpenAI do?

Split Test Agent Prompts with Supabase and OpenAI Use Case Oftentimes, it's useful to test different settings for a large language model in production against various metrics. Split testing is a go...

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 Engineering, AI Chatbot use case.