Skip to content
FlowHubFluxonLab
A
AI Automationfree

A/B Test AI Prompts with Supabase, Langchain Agent & OpenAI GPT-4o

by vanhonadapted from n8n official workflow galleryUpdated Aug 2026
RequiresAAI AgentOpenAI Chat ModelOpenAI Chat ModelPostgres Chat MemoryPostgres Chat MemorySupabaseSupabase
Share Post Share
ChWhen chat message receivedWhen chat messa…AgAI AgentCheck If Session ExistsCheck If Sessio…IfIf Session Does ExistIf Session Does…Assign Path To SessionAssign Path To …SeDefine Path ValuesDefine Path Val…OpenAI Chat ModelOpenAI Chat Mod…MPPostgres Chat MemoryPostgres Chat M…SeGet Correct PromptGet Correct Pro…123456789
1/5
STEPS · 9
Starts from a chat message

Split Test AI Prompts Using Supabase & Langchain Agent This workflow allows you to A/B test different prompts for an AI chatbot powered by Langchain and OpenAI. It uses Supabase to persist session state and randomly assigns users to either a baseline or alternative prompt, ensuring consistent prompt usage across the conversation. 🧠 Use Case Prompt optimization is crucial for maximizing the performance of AI assistants. This workflow helps you run controlled experiments on different prompt versions, giving you a reliable way to compare performance over time. ⚙️ How It Works When a message is received, the system checks whether the session already exists in the Supabase table. If not, it randomly assigns the session to either the baseline or alternative prompt. The selected prompt is passed into a Langchain Agent using the OpenAI Chat Model. Postgres is used as chat memory for multi-turn conversation support.

Tags

n8nreference-onlyagentlm-chat-open-aimemory-postgres-chatsupabase
Connects
AAI AgentopenaichatmodelOpenAI Chat ModelpostgreschatmemoryPostgres Chat MemorysupabaseSupabase
CategoryAI Automation
Triggermanual
Complexitycomplex
Nodes9
AddedSep 21, 2025

Related workflows

See all AI Automation
ACDgmail
free

AI: Summarize podcast episode and enhance using Wikipedia

The workflow automates the process of creating a summarized and enriched podcast digest, which is then sent via email. Note that to use this template, you need to be on n8n version 1.19.4 or later.

by n8n Team
AopenaichatmodelserpapigooglesearchS
free

Slack chatbot powered by AI

This workflow offers an effective way to handle a chatbot's functionality, making use of multiple tools for information retrieval, conversation context storage, and message sending. It's a setup tailored for a Slack environment, aiming to offer an interactive, AI-driven chatbot experience. Note that to use this template, you need to be on n8n version 1.19.4 or later.

by n8n Team
Agmailopenaichatmodeltelegram
free

Send daily AI news digests from RSS feeds with OpenAI, Telegram and Gmail

Quick overview This workflow runs every morning at 8 AM, pulls articles from multiple RSS feeds, deduplicates and trims the list, uses OpenAI (GPT-5 Mini) to write a short plain-text news digest, and delivers the same digest to a Telegram chat and a Gmail inbox. How it works Runs daily at 8:00 AM on a schedule. Splits your configured RSS feed URL list into individual feeds and fetches the latest articles from each one, continuing even if a feed fails. Removes duplicate articles by link, keeps only the newest items up to your maxArticles limit, and trims each item to title, link, publish date, and a short snippet. Combines all cleaned articles into a single JSON list and sends it to OpenAI (GPT-5 Mini) to select 5–8 top stories and generate a single plain-text digest under 3,500 characters. Sends the generated digest to your specified Telegram chat. Emails the same digest as a plain-text message through Gmail. Setup Add an OpenAI credential and ensure the GPT-5 Mini model is available in your account. Create a Telegram bot with @BotFather, add the Telegram credential in n8n, and set your target telegramChatId (for example by using @get_id_bot). Connect a Gmail account in n8n and set

by Manik Chandra Dhor