Back to Integrations
integrationGoogle Sheets node
integrationPostgres node

Google Sheets and Postgres integration

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

How to connect Google Sheets 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.

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

Step 2: Add and configure Google Sheets and Postgres nodes

You can find Google Sheets 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 Google Sheets and Postgres nodes one by one: input data on the left, parameters in the middle, and output data on the right.

Google Sheets and Postgres integration: Add and configure Google Sheets and Postgres nodes

Step 3: Connect Google Sheets and Postgres

A connection establishes a link between Google Sheets 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.

Google Sheets and Postgres integration: Connect Google Sheets and Postgres

Step 4: Customize and extend your Google Sheets 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 Google Sheets and Postgres with any of n8n’s 1000+ integrations, and incorporate advanced AI logic into your workflows.

Google Sheets and Postgres integration: Customize and extend your Google Sheets and Postgres integration

Step 5: Test and activate your Google Sheets and Postgres workflow

Save and run the workflow to see if everything works as expected. Based on your configuration, data should flow from Google Sheets 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.

Google Sheets and Postgres integration: Test and activate your Google Sheets and Postgres workflow

Sync new data between two apps

This template shows how to sync data from one service to another. Specifically, in this example we're saving a new qualified lead from a Postgres database to a Google Sheets file.

Setup instructions are located inside the workflow template.

Nodes used in this workflow

Popular Google Sheets and Postgres workflows

+2

Qualify Real Estate Leads via SMS with GPT-4o, Twilio, and Google Sheets

🏡 AI-Powered Real Estate Lead Qualifier (n8n Workflow) Description This n8n workflow automates lead engagement and qualification for real estate buyers. When someone submits a form on your real estate website, the system instantly responds via SMS, starting a conversation powered by an AI Agent. The AI asks pre-qualifying questions (like budget, location, and timeline), logs the entire conversation, and then summarizes and sends the lead info to a real estate agent. Chat history is stored in a PostgreSQL database (via Supabase) and tied to each buyer's phone number. Key Features 📩 Instant SMS Response: Follows up immediately after form submission. 🤖 AI Chat-Based Qualification: Conversational agent gathers buyer needs and preferences. 🗂 Supabase Chat Memory: Stores chat history tied to the buyer’s phone number to maintain context. 📊 Lead Summary & Agent Handoff: Summarizes conversation and logs it to Google Sheets for the agent. 🔁 Customizable AI Questions: Easily edit the questions asked by the AI to suit your process. 🤝 Connect with Me Description I’m Robert Breen, founder of Ynteractive — a consulting firm that helps businesses automate operations using n8n, AI agents, and custom workflows. I’ve helped clients build everything from intelligent chatbots to complex sales automations, and I’m always excited to collaborate or support new projects. If you found this workflow helpful or want to talk through an idea, I’d love to hear from you. Links 🌐 Website: https://www.ynteractive.com 📺 YouTube: @ynteractivetraining 💼 LinkedIn: https://www.linkedin.com/in/robert-breen 📬 Email: [email protected]

AI Agent that updates its own rules to modify behavior

Video walkthrough https://www.youtube.com/watch?v=OwIFK-r-NtQ Summary of agent This agent can write and rewrite its own rules, allowing you to mold its behavior. It receives rules from a database as system instructions and has tools to create, edit, or delete them. This is a great baseline for new agent builds. You can tell it things like "Next time, use present tense when talking about this subject" and it will use a tool to save this as a rule, then receive that instruction in all future iterations. How to start using it Option 1: With a Postgres database (e.g., Supabase) Supabase Schema: Create a table (e.g., agent_rules) with the following columns: id: bigint (Primary Key, auto-incrementing) created_at: timestamp with time zone (Default: now()) rule_text: text agent: text Workflow Updates: Update the Postgres credentials in the "Get rules from database," "Insert rule into database," and "Execute query on rule database" nodes. Update the agent value (currently 'TestAgent') in the "Get rules from database" and "Insert rule into database" nodes if you want a different agent name. Update the Anthropic API credentials. Option 2: With Google Sheets Google Sheet Setup: Create a Google Sheet with columns for rule_text and agent. Workflow Updates: Example Google Sheets nodes are included. You will need to: Connect your Google Sheets credentials. Select your Google Sheet (with rule_text and agent columns) in all relevant Google Sheets nodes. Replace the existing Postgres nodes ("Get rules from database", "Insert rule into database", "Execute query on rule database") with the configured Google Sheets nodes. Update the agent value (currently 'TestAgent') in the Google Sheets nodes if you want a different agent name. Update the Anthropic API credentials. Agent Instructions: Update the agent's system message and remove the database schema section as it is no longer relevant

Query Google Sheets/CSV data through an AI Agent using PostgreSQL

Want to see it in action? Watch the full breakdown here: 📺 Video Link Template Description This n8n workflow empowers you to query structured financial data from Google Sheets or CSV files using AI-generated SQL. Unlike traditional vector database solutions that falter with numerical queries, this template leverages PostgreSQL for efficient data storage and an AI agent to dynamically create optimized SQL queries from natural language inputs. What It Does Retrieves data from Google Sheets or CSV files Infers the data schema and builds a PostgreSQL table Populates the table with your data Uses an AI agent to translate natural language questions into SQL queries Returns precise numerical results quickly and efficiently Why Use This? No SQL knowledge required—the AI generates queries for you Bypasses the inefficiencies and costs of vector database approaches Scales effortlessly without overwhelming the language model Fully free and open-source Setup Requirements Pre-Conditions PostgreSQL Database**: A running PostgreSQL instance (no specific extensions required beyond standard installation). Google Sheets Access**: A publicly accessible or shared Google Sheet URL with structured data (e.g., financial records). Need a starting point? Use this Sample Google Sheet Template. n8n Instance**: A working n8n setup with access to the Google Drive and PostgreSQL nodes. Step-by-Step Instructions Add Your Google Sheets URL Open the "Google Drive Trigger" node. Replace the placeholder URL with your Google Sheet’s link. Verify the sheet name matches your data source. Configure PostgreSQL Update the "PostgreSQL" nodes with your database credentials (host, database, user, password). The workflow automatically creates and populates the table based on your data schema. Run the Workflow Execute the workflow manually to set up the database. Once initialized, use the AI agent by asking questions like: "How much did I sell last week?" "What were the total sales for Product X in February?" (Optional) Automate Updates Add a "Schedule Trigger" node to sync your Google Sheets data with PostgreSQL on a regular basis. How It Works Schema Detection**: The workflow analyzes your Google Sheets or CSV data to infer its structure and create an appropriate PostgreSQL table. AI-Powered Queries**: An optimized AI agent converts your natural language questions into precise SQL queries, ensuring accurate results. Efficient Retrieval**: By using PostgreSQL instead of vector-based methods, this template avoids common pitfalls like slow performance or inaccurate numerical outputs. Tips for Success Ensure your Google Sheet or CSV has consistent column headers for smooth schema detection. Test with simple questions first to verify the AI agent’s query generation. Check out the n8n Template Submission Guidelines for more best practices.
+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.
+19

💾 Generate Blog Posts on Autopilot with GPT‑5, Tavily and WordPress

Who Is This For? This workflow is designed for marketers, content creators, agencies, and solo founders who want to publish long‑form posts with visuals on autopilot using n8n and AI agents. ​ Whether you run a blog, SaaS, personal brand, newsletter, or client accounts, this tool helps you keep a consistent content pipeline without manually writing every article, creating images, and posting to each platform one by one. ​ ​ 💪🏼 While the template is wired around classic blog + social media distribution, the underlying logic is universal. You can easily adapt it to any niche by editing prompts, swapping models, and re‑wiring nodes. You can plug in any LLM you like, from ChatGPT to Claude, Gemini, Mistral, DeepSeek, OpenRouter, or even local models through Ollama. ​ What Problem Is This Workflow Solving? 🤯 Most teams waste hours on the same repetitive loop: research a topic, gather links, write a blog post, craft social captions, generate visuals, upload everything to multiple platforms, and archive assets. ​ ​ 💎 This workflow solves that by automating the full content chain—from research and blog‑post generation to image creation, publishing across channels, and logging everything in your content database—so your feeds stay active while you focus on strategy, not busywork. ​ What This Workflow Does ✨ Generates in‑depth blog posts tailored to your topic and target audience, enriched with fresh references from the web via Tavily/SerpAPI search tools. ​ ✨ Creates an image prompt and title from the article, generates the visual with OpenAI Images (gpt-image-1), and converts it into a ready‑to‑use image file. ​ ✨ Automatically publishes content to your connected platforms (WordPress for blog posts, Telegram, X/Twitter, Facebook, LinkedIn) while saving images to Google Drive and logging each publication in Google Sheets for tracking. ​ How It Works? Surprisingly simple ☺️ The workflow is triggered by another n8n workflow or by one of several triggers (Facebook, RSS, Google Sheets, Airtable, Postgres) that pass in the blogTopic, targetAudience, and Telegram chatID. ​ ​ The Blog Post Agent (LLM with access to Tavily/SerpAPI) researches the topic, writes a structured article for the specified audience, and sends its output to the Image Prompt Agent, which turns the content into a visual prompt and title. ​ 🎯 The end result: you provide a topic, run the workflow, and receive a complete blog post, matching image, and ready‑made social posts shipped directly to your channels and archives—no manual copy‑paste. ​ How to Customize This Workflow to Your Needs 🎨 Switch AI models and fine‑tune prompts so the agent can handle your exact formats: tutorials, case studies, listicles, product updates, thought‑leadership pieces, or campaign landing posts. 🔍 Refine research sources inside Tavily/SerpAPI to prioritize the domains, blogs, and docs your audience trusts, keeping posts accurate and up to date. ⏰ Adjust posting cadence and schedules to align with peak engagement for your audience, mixing automated slots with manual “launch” runs for special announcements. 📱 Expand or trim channels as needed: keep just WordPress + LinkedIn, add Telegram as a content feed, or plug the workflow into additional automations like email campaigns or RSS feeds. 📊 Use Google Sheets as your content hub to store ideas, angles, CTAs, references, and performance notes so you can double‑down on topics and formats that perform best. 🎬 Swap images for video by replacing the image generation node with video tools (for example, Runway‑style APIs) if your strategy is video‑first while keeping the same prompt pipeline. 💾 Build a reusable prompt library in Sheets, Notion, or Airtable so you can rotate proven prompt patterns each month and keep quality high without reinventing the wheel. 🤖 The system will continuously generate blog posts, visuals, and social updates and publish them across your selected platforms while archiving everything in Drive and Sheets—keeping your brand visible, consistent, and professional with minimal ongoing effort.

Export AI Agent Conversation Logs from Postgres to Google Sheets

Overview This n8n workflow retrieves AI agent chat memory logs stored in Postgres and pushes them to Google Sheets, creating one sheet per session. It’s useful for teams building chat-based products or agents and needing to review or analyze session logs in a collaborative format. Who is it for Anyone with an AI Agent in Production storing the conversation logs in Postgres (or Supabase) who wants to see transcript and have control Product teams building AI agents or assistants. Teams that want to centralize conversation history for analysis or support. Anyone managing AI chat memory and needing to explore it in a spreadsheet. Prerequisites A Postgres database with a n8n_chat_histories table with an AI Agent connected to it. If you need an example, you can follow this tutorial Once done, you need to run the Postgresql query to add the created_at column (see Setup > Add a datetime column) Google Sheets access and OAuth credentials connected to n8n. A Google Sheets document set up as a template (see below). Google Sheets Template This workflow expects a Google Sheets file where each session will be stored in its own tab. A basic tab layout is duplicated and renamed with the session ID. 👉 Use this template as a starting point Note: You can hide the template after the first tabs have been created How it works Trigger The workflow can be launched manually or on a schedule (e.g. daily at noon). Retrieve sessions Runs a SQL query to get distinct session_id values from the n8n_chat_histories table. Loop over sessions For each session: Clears the corresponding sheet (if it exists). Duplicates the template tab. Renames it with the current session_id. Fetch messages Selects all messages linked to the session from Postgres. Append to sheet Adds each message to the Google Sheet with columns: Who: speaker role (user, assistant, etc.) Message: text content Date: timestamp from created_at, formatted yyyy-MM-dd hh:mm:ss Notes The sheet is cleared and rebuilt each run to ensure logs are up-to-date. If a sheet for a session doesn’t exist, it will be created by duplicating the first tab (template) You can group sessions under a persistent ID (like user_id) by overriding session_id in your memory config. Works perfectly with Supabase by using PG credentials from the connection pooler. 👉 If you're looking for a solution to better visualize and analyse conversations, reach out to us!

Build your own Google Sheets and Postgres integration

Create custom Google Sheets 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.

Google Sheets supported actions

Create
Create a spreadsheet
Delete
Delete a spreadsheet
Append or Update Row
Append a new row or update an existing one (upsert)
Append Row
Create a new row in a sheet
Clear
Delete all the contents or a part of a sheet
Create
Create a new sheet
Delete
Permanently delete a sheet
Delete Rows or Columns
Delete columns or rows from a sheet
Get Row(s)
Retrieve one or more rows from a sheet
Update Row
Update an existing row in a sheet

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

Google Sheets and Postgres integration tutorials

FAQs

  • Can Google Sheets connect with Postgres?

  • Can I use Google Sheets’s API with n8n?

  • Can I use Postgres’s API with n8n?

  • Is n8n secure for integrating Google Sheets and Postgres?

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

Need help setting up your Google Sheets and Postgres integration?

Discover our latest community's recommendations and join the discussions about Google Sheets and Postgres integration.
Mikhail Savenkov
Honza Pav
Sergey Komardenkov
sérgio eduardo floresta filho
Julian

Looking to integrate Google Sheets and Postgres in your company?

Over 3000 companies switch to n8n every single week

Why use n8n to integrate Google Sheets 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