Back to Integrations
integrationOpenAI node
integrationPostgres node

OpenAI and Postgres integration

Save yourself the work of writing custom integrations for OpenAI and Postgres and use n8n instead. Build adaptable and scalable AI, Langchain, Development, and Data & Storage workflows that work with your technology stack. All within a building experience you will love.

How to connect OpenAI and Postgres

  • Step 1: Create a new workflow
  • Step 2: Add and configure nodes
  • Step 3: Connect
  • Step 4: Customize and extend your integration
  • Step 5: Test and activate your workflow

Step 1: Create a new workflow and add the first step

In n8n, click the "Add workflow" button in the Workflows tab to create a new workflow. Add the starting point – a trigger on when your workflow should run: an app event, a schedule, a webhook call, another workflow, an AI chat, or a manual trigger. Sometimes, the HTTP Request node might already serve as your starting point.

OpenAI and Postgres integration: Create a new workflow and add the first step

Step 2: Add and configure OpenAI and Postgres nodes

You can find OpenAI and Postgres in the nodes panel. Drag them onto your workflow canvas, selecting their actions. Click each node, choose a credential, and authenticate to grant n8n access. Configure OpenAI and Postgres nodes one by one: input data on the left, parameters in the middle, and output data on the right.

OpenAI and Postgres integration: Add and configure OpenAI and Postgres nodes

Step 3: Connect OpenAI and Postgres

A connection establishes a link between OpenAI and Postgres (or vice versa) to route data through the workflow. Data flows from the output of one node to the input of another. You can have single or multiple connections for each node.

OpenAI and Postgres integration: Connect OpenAI and Postgres

Step 4: Customize and extend your OpenAI and Postgres integration

Use n8n's core nodes such as If, Split Out, Merge, and others to transform and manipulate data. Write custom JavaScript or Python in the Code node and run it as a step in your workflow. Connect OpenAI and Postgres with any of n8n’s 1000+ integrations, and incorporate advanced AI logic into your workflows.

OpenAI and Postgres integration: Customize and extend your OpenAI and Postgres integration

Step 5: Test and activate your OpenAI and Postgres workflow

Save and run the workflow to see if everything works as expected. Based on your configuration, data should flow from OpenAI to Postgres or vice versa. Easily debug your workflow: you can check past executions to isolate and fix the mistake. Once you've tested everything, make sure to save your workflow and activate it.

OpenAI and Postgres integration: Test and activate your OpenAI and Postgres workflow

Generate Instagram content from top trends with AI image generation

How it works

This automated workflow discovers trending Instagram posts and creates similar AI-generated content. Here's the high-level process:

  1. Content Discovery & Analysis
    Scrapes trending posts from specific hashtags
    Analyzes visual elements using AI
    Filters out videos and duplicates

  2. AI Content Generation
    Creates unique images based on trending content
    Generates engaging captions with relevant hashtags
    Maintains brand consistency while being original

  3. Automated Publishing
    Posts content directly to Instagram
    Monitors publication status
    Sends notifications via Telegram

Set up steps

Setting up this workflow takes approximately 15-20 minutes:

  1. API Configuration (7-10 minutes)
    Instagram Business Account setup
    Telegram Bot creation
    API key generation (OpenAI, Replicate, Rapid Api)

  2. Database Setup (3-5 minutes)
    Create required database table
    Configure PostgreSQL credentials

  3. Workflow Configuration (5-7 minutes)
    Set scheduling preferences
    Configure notification settings
    Test connection and permissions

Detailed technical specifications and configurations are available in sticky notes within the workflow.

Nodes used in this workflow

Popular OpenAI and Postgres workflows

+4

AI-Powered Lead Generation with Apollo, GPT-4, and Telegram to Database

AI-Powered Lead Generation with Apollo, GPT-4, and Telegram to Database Overview This intelligent lead generation workflow transforms voice commands or text input into verified prospect lists through automated Apollo.io scraping. The system processes natural language requests, extracts search parameters using AI, and delivers clean, verified contact data directly to your database. Key Features 🎤 Voice & Text Input Processing Voice Recognition**: Converts audio messages to text using OpenAI's transcription API Natural Language Processing**: AI agent interprets requests and extracts search criteria Flexible Input**: Supports both voice commands and text messages 🔍 Smart Lead Scraping Apollo.io Integration**: Automated scraping using official Apollo.io API Dynamic URL Generation**: Builds search URLs based on extracted parameters Intelligent Parsing**: Processes location, industry, and job title criteria ✅ Email Verification & Filtering Verified Emails Only**: Filters results to include only verified email addresses Duplicate Prevention**: Compares against existing database to avoid duplicates Data Quality Control**: Ensures high-quality prospect data 📊 Automated Data Management Database Integration**: Automatic storage in PostgreSQL/Supabase Structured Data**: Organizes contacts with complete profile information Real-time Updates**: Instant database updates with new prospects How It Works Input Processing: Receive voice message or text command AI Analysis: Extract search parameters (location, industry, job titles) URL Construction: Build Apollo.io search URL with extracted criteria Data Scraping: Retrieve prospect data via Apollo.io API Email Verification: Filter for verified email addresses only Duplicate Check: Compare against existing database records Data Storage: Save new prospects to database Confirmation: Send success notification with count of new leads Supported Search Parameters Location**: City, state, country combinations Industry**: Business sectors and verticals Job Titles**: Executive roles, departments, seniority levels Company Size**: Organization scale and employee count Data Fields Extracted Contact Information First Name & Last Name Email Address (verified only) LinkedIn Profile URL Phone Number (when available) Professional Details Current Job Title Company Name Industry Seniority Level Employment History Location Data City & State Country Full Location String Company Information Website URL Business Industry Organization Details Technical Architecture Core Components n8n Workflow Engine**: Orchestrates the entire process OpenAI Integration**: Powers voice transcription and AI analysis Apollo.io API**: Source for prospect data PostgreSQL/Supabase**: Database storage and management API Integrations OpenAI Whisper API for voice transcription OpenAI GPT for natural language processing Apollo.io API for lead data retrieval Supabase API for database operations Use Cases Sales Teams Quickly build prospect lists for outreach campaigns Target specific industries or job roles Maintain clean, verified contact databases Marketing Professionals Generate targeted lead lists for campaigns Research prospects in specific markets Build comprehensive contact databases Business Development Identify potential partners or clients Research competitive landscapes Generate contact lists for networking Recruitment Find candidates in specific locations Target particular job roles or industries Build talent pipeline databases Benefits ⚡ Speed & Efficiency Voice commands for instant lead generation Automated processing eliminates manual work Batch processing for large prospect lists 🎯 Precision Targeting AI-powered parameter extraction Flexible search criteria combinations Industry and role-specific filtering 📈 Data Quality Verified email addresses only Duplicate prevention Structured, consistent data format 🔄 Automation End-to-end automated workflow Real-time database updates Instant confirmation notifications Setup Requirements Prerequisites n8n workflow platform OpenAI API access Apollo.io API credentials PostgreSQL or Supabase database Messaging platform integration Configuration Steps Import workflow into n8n Configure API credentials Set up database connections Customize search parameters Test with sample voice/text input Customization Options Search Parameters Modify location formats Add custom industry categories Adjust job title variations Set result limits Data Processing Customize field mappings Add data validation rules Implement additional filters Configure output formats Integration Options Connect to CRM systems Add email marketing tools Integrate with sales platforms Export to various formats Success Metrics Processing Speed**: Voice-to-database in under 30 seconds Data Accuracy**: 95%+ verified email addresses Automation Level**: 100% hands-free operation Scalability**: Process 500+ leads per request Transform your lead generation process with intelligent automation that understands natural language and delivers verified prospects directly to your database.

Generate Instagram Content from Top Trends with AI Image Generation

How it works This automated workflow discovers trending Instagram posts and creates similar AI-generated content. Here's the high-level process: Content Discovery & Analysis Scrapes trending posts from specific hashtags Analyzes visual elements using AI Filters out videos and duplicates AI Content Generation Creates unique images based on trending content Generates engaging captions with relevant hashtags Maintains brand consistency while being original Automated Publishing Posts content directly to Instagram Monitors publication status Sends notifications via Telegram Set up steps Setting up this workflow takes approximately 15-20 minutes: API Configuration (7-10 minutes) Instagram Business Account setup Telegram Bot creation API key generation (OpenAI, Replicate, Rapid Api) Database Setup (3-5 minutes) Create required database table Configure PostgreSQL credentials Workflow Configuration (5-7 minutes) Set scheduling preferences Configure notification settings Test connection and permissions Detailed technical specifications and configurations are available in sticky notes within the workflow.
+3

Natural Language Database Queries with Dual-Agent AI & PostgreSQL Integration

AI Database Assistant with Smart Query's & PostgreSQL Integration Description: 🚀 Transform Your Database into an Intelligent AI Assistant This workflow creates a smart database assistant that safely handles natural language queries without crashing your system. Features dual-agent architecture with built-in query limits and PostgreSQL optimization – perfect for commercial applications! ✅ Ideal for: SaaS developers building database search features 🔍 Database administrators providing safe AI access 🛡️ Business teams needing user-friendly data queries 📊 Anyone wanting ChatGPT-like database interaction 🤖 🔧 How It Works 1️⃣ User asks a question – "Show me top 10 popular products" 2️⃣ Main AI Agent – Interprets the request and ensures safety limits 3️⃣ SQL Sub-Agent – Generates precise PostgreSQL queries 4️⃣ Database executes – Returns formatted, limited results safely ⚡ Setup Instructions 1️⃣ Prepare Your Database Ensure PostgreSQL is accessible from n8n Note your table structure and column names Set up database connection credentials 2️⃣ Customize the Templates Replace [YOUR_TABLE_NAME] with your actual table name Update [YOUR_FIELDS] with your column names Modify examples to match your use case Important**: Keep all LIMIT clauses intact! 3️⃣ Configure the Agents Copy Main Agent system message to your primary AI node Copy Sub-Agent system message to your SQL generator node Connect the sub-workflow between both agents 4️⃣ Test & Deploy Test with sample queries like "Show me 5 recent items" Verify query limits work (max 50 results) Deploy and monitor performance 🎯 Why Use This Workflow? ✔️ System Protection – Built-in limits prevent crashes from large queries ✔️ Natural Language – Users ask questions in plain English ✔️ Commercial Ready – Generic templates work with any database ✔️ Dual-Agent Safety – Smart interpretation + precise SQL generation ✔️ PostgreSQL Optimized – Handles complex schemas and data types 🚨 Critical Features Query Limits**: Default 10, maximum 50 results (can be modified) Error Prevention**: No unlimited data retrieval Smart Routing**: Natural language → Safe SQL → Formatted results Customizable**: Works with any PostgreSQL database schema 🔗 Start building your AI database assistant today – safe, smart, and scalable!
+2

Automate Blog-to-Social Media with GPT-4 for LinkedIn, X, and Reddit

Turn your blog into a set-and-forget content engine: every new article is instantly repurposed into channel-specific social posts with visuals, keeping your brand visible on LinkedIn, X, and Reddit without extra copywriting time. Perfect for lean marketing teams who want consistent, always-on distribution from a single source of content. How it works • Watches your blog RSS feed (or receives a single URL) and detects new articles. • Saves each post in Postgres so every article is only processed once. • Fetches the article HTML, extracts the main body content and sends it to OpenAI (GPT-4.1). • OpenAI creates platform-optimized copy: 1 LinkedIn post, 1 X/Twitter post, 1 Reddit post + image prompts. • Generates on-brand images with OpenAI and publishes everything automatically to LinkedIn, X, and Reddit. • You can also trigger it manually or via webhook whenever you want to push a specific campaign. Setup Steps • Time: around 20–40 minutes for someone familiar with n8n and the platforms. • Create a Postgres table “rss_items” with fields: guid (PRIMARY KEY), title, link, published_at. • Add credentials in n8n for: – Postgres – OpenAI – LinkedIn OAuth2 – X/Twitter OAuth2 + OAuth1 (for media upload) – Reddit OAuth2 • In the RSS node, set your blog feed URL (for example: https://yourblog.com/feed). • In the webhook node, confirm the URL/path you want external tools or other workflows to call with a “link” field. • Run the manual trigger with one test blog URL to verify: – Article content is extracted correctly. – AI returns LinkedIn/X/Reddit posts and image prompts. – Posts and images appear correctly on all social accounts. • Once tests look good, enable the Schedule Trigger so Blog2Social AI runs automatically at your chosen interval.
+9

AI Personal Assistant with GPT-4o, RAG & Voice for WhatsApp using Supabase

🧠 Intelligent AI Assistant with RAG & Voice for WhatsApp – Built with GPT-4o & Supabase 📌 About this workflow and its creator Hi! I’m Amanda, a creator of intelligent automations using n8n and Make. I’ve been building AI-powered workflows for over 2 years, always focused on usability and innovation. This one here is very special to me – a truly advanced AI assistant that reads, listens, interprets and responds like a real human 🤖✨ This ready-to-use workflow acts as a powerful AI personal assistant capable of understanding messages via voice, text, documents, or even images. It supports full multi-channel operation (WhatsApp via Evolution API, Instagram, Facebook, and more), and includes advanced RAG capabilities using Supabase + GPT-4o. It’s designed to be highly extensible, with memory, prompt update tools, and knowledge base management. ⚙️ What this workflow does 💬 Understands user input via text, document, audio or image (voice, OCR, PDF) 🎤 Transcribes and interprets voice messages using OpenAI Whisper 🧠 Understands prompts and user commands using GPT-4o via LangChain agent 🗂️ Searches knowledge base using RAG + Supabase vector DB 📄 Accepts documents and automatically indexes them for future questions 🧾 Summarizes documents and stores metadata in Supabase 🗃️ Offers memory support (PostgreSQL chat memory per user session) 📧 Sends replies through WhatsApp (Evolution API), Instagram, Facebook, etc. 📅 Manages schedules (via tool integration with Google Calendar) 📬 Sends and searches emails (with support tools) 🛠 Modular and expandable structure (tools for saving knowledge, deleting, updating prompt) 🔧 Setup Instructions n8n Hosting This workflow requires n8n self-hosted (or n8n Cloud with custom credentials + community nodes enabled). Create required databases Use the provided SQL queries inside the setar_supabase_tabelas_vectoriais, criar_cerebro, and criar_rag_controle nodes to initialize: documents table for RAG cerebro table for prompt memoria_chat for session memory rag_controle for summaries and indexing Credentials needed OpenAI API (for chat, embeddings and Whisper transcription) Redis (for managing message buffer) Supabase (for vector store + metadata) Postgres (for memory and prompts) Evolution API (or other messaging platforms) Webhook Set the webhook path to receive messages from your Evolution or WhatsApp API provider. Configure ‘Set’ node In the config node, adjust: adminNumero: your personal WhatsApp or admin number evolutionApiKey: your private API key utilizacaoApenasViaAdmin: toggle if this should only respond to admin numbers Tool connections Ensure the supporting workflows are also imported and connected for: Emails Knowledge management Calendar events 📎 Notes This workflow uses LangChain agents, OpenAI GPT-4o, Supabase, Redis, and PostgreSQL. It includes multiple “sticky notes” inside the workflow with explanations. Ideal for businesses, consultants, and developers looking to offer an intelligent and extendable AI chatbot experience. 🛍 Want to use this on your system? ❤️ Buy workflows: https://iloveflows.com ☁️ Use n8n Cloud with my partner link: https://n8n.partnerlinks.io/amanda
+18

💅 AI Agents Generate Content & Automate Posting for Beauty Salon Social Media 📲

💅 AI Agents Generate Content & Automate Posting for Beauty Salon Social Media 📲 Who Is This For? This workflow is for beauty salons who want consistent, high‑quality social media content without writing every post manually. It also suits agencies and automation builders who manage multiple beauty brands and want a reusable, AI‑driven posting system they can adapt per client. What Problem Is This Workflow Solving? Many beauty businesses struggle to post regularly because research, copywriting, and design all take time and marketing skills. This workflow automates research, writing, image creation, and posting, so your channels stay active and relevant while you focus on clients and services. What This Workflow Does Generates short, engaging posts tailored to a beauty‑salon audience (hair, nails, skincare, make‑up, self‑care) using an AI agent. Uses Tavily Internet Search to pull up‑to‑date information and trends based on a reference link or topic. Turns each post into a detailed, photorealistic image prompt and creates a matching visual with an AI image model (for example, gpt‑image‑1 or other connected providers). Automatically sends the final text and image to Telegram, and can be extended to other social platforms from the Split Out node. How It Works Trigger the workflow Scheduled automatic generation:** Run the parent workflow on a schedule (for example, once per day at 9 AM) to publish new content regularly. Google Sheets trigger:** Generate content when a new row with a reference link or topic is added to your sheet. Use it when you manage ideas or briefs in Google Sheets and want the workflow to react as soon as a new idea appears. RSS Feed trigger:** Start the workflow when new items appear in a selected RSS feed. Ideal for turning fresh blog posts, news, or industry updates into social media content or automated summaries. Meta (Facebook/Instagram) webhook:** Use the Meta Reference trigger to fire the workflow on incoming webhooks from Meta (for example, new comments, messages, or events). Helpful when you want to auto‑respond, log activity, or generate follow‑up content from Meta activity. Airtable trigger:** Start the workflow when records in a selected Airtable base/table change (for example, a new idea, brief, or status update), so your posts react instantly to updates in your Airtable content board. Postgres trigger:** Fire the workflow when new rows are inserted or existing rows are updated in a connected PostgreSQL table, letting you drive content generation from events in your app database or Supabase‑style back end. Manual start:* Hit Execute workflow* whenever you want to spin up a batch of posts on demand, test new prompt settings, or debug the flow step by step. Research and generate copy The GENERATE TEXT agent calls Tavily to gather fresh information on the topic. It writes a post under 1024 characters with a hook, practical tips, relevant hashtags, and a closing line with your salon address and contact. Create the visual The GENERATE PROMPT agent converts the post into a single, clear description of the scene (client, service, salon interior, lighting, mood) with a strict “no text on image” rule. An image model such as gpt‑image‑1 or one of the HTTP image APIs renders a matching beauty visual. Distribute the content The Split Out node fans out the result so Telegram receives a photo post with the generated caption. Additional social or content nodes (for example Facebook, LinkedIn, X, template tools) can be wired after this step for multi‑channel posting. How to Customize This Workflow to Your Needs Brand voice** Edit the system message in the GENERATE TEXT node to adjust tone (luxury, friendly, clinical, playful), language, services, and city. Update the final address and phone line to match your salon details. Topics and triggers** Point the Google Sheets Trigger to your own document ID, sheet, and columns for ideas, links, or campaign themes. Use the Schedule Trigger for fully automatic posting or rely on the Manual Trigger for controlled, batch generation sessions. Models and providers** Swap GPT‑5 llm and the default image model for alternatives such as Mistral, Gemini, Anthropic, DeepSeek, or custom HTTP image APIs by enabling the corresponding nodes and adding credentials. Channels and outputs** Connect or remove social nodes after Split Out depending on which platforms you actively use. Add extra processing steps (for example resizing images or adding UTM parameters) before each channel if needed. Visual style** Tweak the GENERATE PROMPT instructions to control composition (close‑up vs. full‑body), color palette, lighting, and overall salon aesthetic, while keeping the constraint of no text or logos in the image.

Build your own OpenAI and Postgres integration

Create custom OpenAI and Postgres workflows by choosing triggers and actions. Nodes come with global operations and settings, as well as app-specific parameters that can be configured. You can also use the HTTP Request node to query data from any app or service with a REST API.

OpenAI supported actions

Message a Model
Generate a model response with GPT 3, 4, 5, etc. using Responses API
Classify Text for Violations
Check whether content complies with usage policies
Analyze Image
Take in images and answer questions about them
Generate an Image
Creates an image from a text prompt
Edit Image
Edit an image
Generate Audio
Creates audio from a text prompt
Transcribe a Recording
Transcribes audio into text
Translate a Recording
Translates audio into text in English
Delete a File
Delete a file from the server
List Files
Returns a list of files that belong to the user's organization
Upload a File
Upload a file that can be used across various endpoints
Create
Create a conversation
Get
Get a conversation
Remove
Remove a conversation
Update
Update a conversation
Generate
Creates a video from a text prompt

Postgres supported actions

Delete
Delete an entire table or rows in a table
Execute Query
Execute an SQL query
Insert
Insert rows in a table
Insert or Update
Insert or update rows in a table
Select
Select rows from a table
Update
Update rows in a table

OpenAI and Postgres integration details

Use case

Save engineering resources

Reduce time spent on customer integrations, engineer faster POCs, keep your customer-specific functionality separate from product all without having to code.

Learn more

FAQs

  • Can OpenAI connect with Postgres?

  • Can I use OpenAI’s API with n8n?

  • Can I use Postgres’s API with n8n?

  • Is n8n secure for integrating OpenAI and Postgres?

  • How to get started with OpenAI and Postgres integration in n8n.io?

Need help setting up your OpenAI and Postgres integration?

Discover our latest community's recommendations and join the discussions about OpenAI and Postgres integration.
Artem
Mikhail Savenkov
Honza Pav
sérgio eduardo floresta filho
Andrew adawdad

Looking to integrate OpenAI and Postgres in your company?

Over 3000 companies switch to n8n every single week

Why use n8n to integrate OpenAI with Postgres

Build complex workflows, really fast

Build complex workflows, really fast

Handle branching, merging and iteration easily.
Pause your workflow to wait for external events.

Code when you need it, UI when you don't

Simple debugging

Your data is displayed alongside your settings, making edge cases easy to track down.

Use templates to get started fast

Use 1000+ workflow templates available from our core team and our community.

Reuse your work

Copy and paste, easily import and export workflows.

Implement complex processes faster with n8n

red iconyellow iconred iconyellow icon