Skip to main content

Send post-purchase email sequences with Postgres, Gmail and OpenAI

Workflow preview

Workflow preview
100%
Send post-purchase email sequences with Postgres, Gmail and OpenAI preview
Open on n8n.io

1. Workflow Overview

How it works This workflow automates customer communication after an order is placed. It detects new orders, sends a confirmation email, waits until delivery is completed, and then follows up with ...

Best for

  • Lead Nurturing automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.wait, n8n-nodes-base.gmail, n8n-nodes-base.scheduletrigger, n8n-nodes-base.postgres, n8n-nodes-base.stickynote, n8n-nodes-base.code, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.openai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Avkash Kakdiya.

Original n8n.io source

1.1 Workflow description

Title
Send post-purchase email sequences with Postgres, Gmail and OpenAI
Workflow name
Send post-purchase email sequences with Postgres, Gmail and OpenAI

How it works

This workflow automates customer communication after an order is placed. It detects new orders, sends a confirmation email, waits until delivery is completed, and then follows up with AI-generated product tips. Finally, it sends AI-powered upsell recommendations after a defined delay. The workflow runs on a schedule and requires no manual handling.

Step-by-step

  • Step 1 — Order detection and confirmation

  • Schedule Trigger – Runs at a fixed interval to check for new orders.

  • Postgres – Execute a SQL query – Fetches recently created orders from the database.

  • Gmail – Send message – Sends an order confirmation email to the customer.

  • Step 2 — Delivery status monitoring

  • Wait – Pauses the workflow until the expected delivery window.

  • Postgres – Select rows – Checks the delivery status of the order.

  • If – Verifies whether the product is marked as delivered.

  • Wait – Delays one day and repeats the check if delivery is not completed.

  • Step 3 — Product usage tips (AI)

  • OpenAI – Message a model – Generates short and practical usage tips for the product.

  • Code – Formats the AI output into clean HTML bullet points.

  • Gmail – Send message – Emails the usage tips to the customer.

  • Step 4 — Upsell recommendations (AI)

  • Wait – Delays for two weeks after tips are sent.

  • OpenAI – Message a model – Creates complementary product recommendations.

  • Code – Formats the recommendations for email delivery.

  • Gmail – Send message – Sends the upsell email to the customer.

Why use this?

  • Ensures timely and relevant customer communication
  • Prevents sending tips before the product is delivered
  • Improves onboarding with AI-generated usage guidance
  • Increases repeat purchases through smart upsell emails
  • Fully automated using database, email, and AI integrations

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Wait until product get deliver

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 2 - Wait for 2 weeks

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 3 - Order Placed Ack.

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 4 - Send Tips to User

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 5 - Send Tips to User1

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.2

Block 6 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.3

Block 7 - Execute a SQL query

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 8 - Select rows from a table

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.6

Block 9 - Wait for a day

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 10 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Step -1 Trigger & Order Detection

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Format AI response3

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Code in JavaScript1

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - If2

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 18 - Message a model

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 2.1

Block 19 - Message a model1

Type / Role
@n8n/n8n-nodes-langchain.openAi - openAi
Config choices
Version 2.1

3. Summary Table

Workflow Send post-purchase email sequences with Postgres, Gmail and OpenAI
Complexity advanced
Nodes 19
Categories Lead Nurturing, AI Summarization
Author Avkash Kakdiya
Published 10 Feb 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/13274/13274.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Send post-purchase email sequences with Postgres, Gmail and OpenAI do?

How it works This workflow automates customer communication after an order is placed. It detects new orders, sends a confirmation email, waits until delivery is completed, and then follows up with ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Lead Nurturing, AI Summarization use case.