Sync Postgres Leads to Google Sheets with n8n Automation

This n8n workflow automates syncing qualified user leads from a Postgres database to Google Sheets, filtering out internal emails. Save time, reduce manual errors, and keep your sales team up-to-date effortlessly.
postgresTrigger
filter
googleSheets
+3
Workflow Identifier: 2429
NODES in Use: Postgres Trigger, Filter, Manual Trigger, Code, Google Sheets, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow automatically moves updated user data from a Postgres database to a Google Sheets file after removing certain users.
It stops emails with @n8n.io addresses from being added to sales leads.
This makes sure only real customers’ contacts are saved in the sheet.
The outcome is that the sales team has fresh, clean lead info to work with every day without doing any manual work.

The workflow listens for changes in the user data in Postgres.
It filters out emails containing n8n.io.
Then it formats the relevant data and adds or updates rows in Google Sheets.
A manual trigger and example data lets users test and see how the process works before going live.
This stops wasted time copying and pasting data.
It also reduces mistakes from outdated spreadsheets and missing important leads.

Step-by-Step Guide

How to use this workflow in production inside n8n

1. Download and Import the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open the n8n editor where you want to use the workflow.
  3. Click “Import from File” and select the downloaded file.

2. Configure Credentials and Settings

  1. Add Postgres credentials named “Postgres Product Analytics” if not already set up.
  2. Add Google Sheets OAuth2 credentials.
  3. Update Google Sheets document and sheet IDs inside the Google Sheets node if your sheet names or IDs are different.
  4. If needed, update any columns mapped in the Google Sheets node for id, email, and username.
  5. Confirm the Filter node filters out emails containing “n8n.io” as “notContains” to keep internal emails excluded.

3. Test the Workflow

  1. Run the Manual Trigger node by clicking “Execute Node”.
  2. Make sure the filter removes mock user data with internal emails properly.
  3. Check that Google Sheets node appends or updates the sample data correctly in the sheet.

4. Activate for Production

  1. Enable the Postgres Trigger node to start listening for live database updates.
  2. Save the workflow.
  3. Monitor executions in the n8n interface as new user data updates come in.

This will let the workflow run by itself whenever the database changes happen.
Using this method avoids building the workflow manually, so beginner users can get started easily.
For self hosting n8n, check self-host n8n for helpful details.

What This Workflow Uses

  • Postgres database: Supplies user data and sends updates triggering the workflow.
  • Google Sheets: Receives cleaned user data for sales teams to see and use.
  • Postgres Trigger node: Watches for updates on the users table.
  • Filter node: Removes users with @n8n.io emails not fit for outreach.
  • Manual Trigger node: Lets users run and test workflow manually.
  • Code node: Supplies example test data in a simple array format.
  • Google Sheets node: Appends or updates rows with filtered user info.

How the Workflow Works: Inputs → Processing → Outputs

Inputs

  • Live updates to rows in the Postgres users table trigger the workflow through the Postgres Trigger node.
  • For testing, a user manually activates the Manual Trigger node, which starts the flow with mock user data in the Code node.

Processing

  • The Filter node scans each user and excludes any with email containing n8n.io.
  • Accepted users then pass to the Google Sheets node.
  • The Google Sheets node adds new rows or updates existing ones based on matching the id field.

Outputs

  • The Google Sheets file contains only qualified leads with emails outside of internal domains.
  • The sales team can use this sheet confidently to contact valid prospective customers.

Customizations ✏️

  • Change email filtering: Edit the Filter node to exclude different email domains by adjusting the string inside the notContains rule.
  • Use a CRM instead of Google Sheets: Swap the Google Sheets node for integrations like HubSpot or Pipedrive to send leads directly to a CRM.
  • Activate real database triggers: Enable the Postgres Trigger node fully, ensuring Postgres supports event notifications correctly.

Troubleshooting 🔧

  • Workflow does not start on database update
    Cause: The Postgres Trigger node is disabled or Postgres notifications are not set.
    Fix: Enable the Postgres Trigger node and set up Postgres NOTIFY/LISTEN on the users table.
  • Internal emails are not filtered out
    Cause: The Filter node uses “contains” instead of “notContains”.
    Fix: Change filter condition to “notContains” with the correct field email.
  • Google Sheets updates fail
    Cause: Wrong Google Sheets credentials or sheet ID.
    Fix: Reauthenticate Google Sheets node and verify the document and sheet IDs.

Pre-Production Checklist ✅

  • Make sure the Postgres Trigger node is enabled and can receive update events.
  • Run the Manual Trigger node to test the workflow and confirm filtering works properly.
  • Check Google Sheets node settings and permissions on the targeted document.
  • Confirm that after live triggers, the Google Sheet updates as expected.

Deployment Guide

Turn on the Postgres Trigger node and save the workflow.
Watch execution logs in n8n’s user interface to see that new user data flows into Google Sheets.
Optionally, add a logging step to capture success or failure for monitoring.

Conclusion

✓ This workflow sends updated user data from Postgres into Google Sheets automatically.
✓ It removes internal @n8n.io emails so the sales list has only valid contacts.
✓ Automated syncing saves hours of manual work and reduces errors.
→ The result is always fresh, clean lead data ready for sales outreach.
→ Next steps could be linking leads directly to CRM or alerting sales when new leads arrive.


Frequently Asked Questions

Download the workflow file. Import it inside the n8n editor using ‘Import from File’. Add Postgres and Google Sheets credentials. Update any IDs if needed. Test by running the Manual Trigger node. Then enable the Postgres Trigger node to run live.
Check the Filter node condition. It should use ‘notContains’ with ’email’ field set to remove emails containing ‘n8n.io’. If it uses ‘contains’, the filter will work backwards.
Replace the Google Sheets node with CRM nodes like HubSpot or Pipedrive. Adjust fields and credentials accordingly.
The Postgres Trigger node may be disabled or Postgres is not configured to send notifications on the users table. Enable the node and set up database triggers for NOTIFY/LISTEN.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free