Skip to main content

Send post-purchase emails from Postgres with Gmail and Groq AI

Workflow preview

Workflow preview
100%
Send post-purchase emails from Postgres with Gmail and Groq AI preview
Open on n8n.io

1. Workflow Overview

How it works This workflow monitors new orders from a Postgres database and sends a confirmation email instantly. It then waits until the expected delivery time and continuously checks the delivery...

Best for

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

Tools used

n8n-nodes-base.wait, n8n-nodes-base.code, n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.scheduletrigger, n8n-nodes-base.postgres, n8n-nodes-base.if, @n8n/n8n-nodes-langchain.lmchatgroq

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 emails from Postgres with Gmail and Groq AI
Workflow name
Send post-purchase emails from Postgres with Gmail and Groq AI

How it works

This workflow monitors new orders from a Postgres database and sends a confirmation email instantly. It then waits until the expected delivery time and continuously checks the delivery status. Once delivered, it uses AI to generate product usage tips and emails them to the customer. After two weeks, it sends personalized complementary product recommendations to drive repeat purchases.

Step-by-step

  • Trigger new orders from database

  • Schedule Trigger – Runs every 2 minutes to check for new orders.

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

  • Order Placed Ack. – Sends an order confirmation email via Gmail.

  • Track delivery status dynamically

  • Wait until product get deliver – Pauses workflow until estimated delivery time.

  • Select rows from a table – Retrieves latest order status.

  • If – Checks whether the order is delivered.

  • Wait for a day – Rechecks daily until delivery is confirmed.

  • Send AI-powered product usage tips

  • Get Product Usage Tips – Uses AI agent to generate helpful tips.

  • Groq Chat Model – Provides LLM capability for content generation.

  • Format AI response – Converts AI output into clean HTML list format.

  • Send Tips to User – Emails tips to the customer.

  • Upsell complementary products after delay

  • Wait for 2 weeks – Delays follow-up communication.

  • Get Complementary Products – Generates related product suggestions.

  • Groq Chat Model1 – Powers recommendation generation.

  • Code in JavaScript – Formats recommendations into HTML.

  • Send Tips to User1 – Sends upsell email with recommendations.

Why use this?

  • Automates full post-purchase lifecycle without manual intervention
  • Improves customer experience with timely and helpful communication
  • Increases repeat purchases through personalized upsell emails
  • Reduces support queries by proactively sending usage guidance
  • Scales easily for growing eCommerce operations

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 - Format AI response

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

Block 4 - Order Placed Ack.

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

Block 5 - Get Product Usage Tips

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 6 - Send Tips to User

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

Block 7 - Get Complementary Products

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 8 - Code in JavaScript

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

Block 9 - Send Tips to User1

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

Block 10 - Schedule Trigger

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

Block 11 - Execute a SQL query

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

Block 12 - If

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

Block 13 - Select rows from a table

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

Block 14 - Wait for a day

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

Block 15 - Groq Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGroq - lmChatGroq
Config choices
Version 1

Block 16 - Groq Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatGroq - lmChatGroq
Config choices
Version 1

Block 17 - Sticky Note1

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

Block 18 - Sticky Note2

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

Block 19 - Sticky Note3

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

Block 20 - Step -1 Trigger & Order Detection

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

Block 21 - Sticky Note

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

3. Summary Table

Workflow Send post-purchase emails from Postgres with Gmail and Groq AI
Complexity advanced
Nodes 21
Categories Lead Nurturing, Multimodal AI
Author Avkash Kakdiya
Published 18 Mar 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/14144/14144.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 emails from Postgres with Gmail and Groq AI do?

How it works This workflow monitors new orders from a Postgres database and sends a confirmation email instantly. It then waits until the expected delivery time and continuously checks the delivery...

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, Multimodal AI use case.