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
Sync Postgres leads to Google Sheets with n8n

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

Learn how to Build this Workflow with AI:

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.


Sync Postgres leads to Google Sheets with n8n

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.