Ensure required data tables exist using OpenAI and Google Gemini
Go to WorkflowDescription
Quick overview
This workflow is called by another n8n workflow to ensure a specific n8n Data Table exists, checking existing tables first and creating the table with an OpenAI-powered agent and Data Table tools when it is missing.
How it works
Receives inputs from an Execute Workflow trigger containing a target Data Table name and a desired table structure.
Lists all existing n8n Data Tables and iterates through them to look for a table with the requested name.
When a matching table is found, it records a flag in execution data to indicate the table already exists.
If no matching table is found, it sends the requested table name and columns to an OpenAI chat model via an AI agent.
The AI agent selects an appropriate n8n Data Table tool (1–5 columns supported) and creates the new Data Table with the generated column names.
Setup
Add an OpenAI API credential for the OpenAI Chat Model used by the AI agent.
Ensure the workflow is executed by another workflow that passes table_name and table_structure as inputs to the Execute Workflow trigger.
Confirm the n8n instance has Data Tables enabled and that the executing user has permission to list and create tables.
Requirements
Master Workflow providing table_name and table_structure
Additional info
Automatically create table if not exists from a SubNode