Skip to main content

Send AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq

Workflow preview

Workflow preview
100%
Send AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq preview
Open on n8n.io

1. Workflow Overview

How it works This workflow automatically detects completed orders in PostgreSQL and prepares them for AI based post purchase communication. It enriches each order with customer, product, and paymen...

Best for

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

Tools used

n8n-nodes-base.postgrestrigger, n8n-nodes-base.postgres, n8n-nodes-base.splitinbatches, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatgroq, n8n-nodes-base.code, n8n-nodes-base.gmail, n8n-nodes-base.merge

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 AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq
Workflow name
Send AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq

How it works

This workflow automatically detects completed orders in PostgreSQL and prepares them for AI-based post-purchase communication. It enriches each order with customer, product, and payment data, then generates a personalized message using an AI agent. The message is delivered via email and WhatsApp and finally logged in Google Sheets for tracking and auditing.

Step-by-step

  • Step 1: Fetch and prepare completed orders for AI processing

  • Postgres Trigger – Watches the orders table for updates and initiates the workflow.

  • Postgres (Execute query) – Fetches only orders marked as completed.

  • Split In Batches – Loops through completed orders safely and sequentially.

  • Postgres (Execute query) – Retrieves full customer, product, and payment details using joins.

  • AI Agent – Generates a personalized post-purchase message using order data.

  • Groq Chat Model – Supplies the language model used by the AI agent.

  • Merge – Combines AI-generated text with database results for downstream use.

  • Step 2: Deliver messages and log post-purchase communication

  • Code – Formats AI output into clean email and WhatsApp message templates.

  • Gmail – Sends the post-purchase email to the customer.

  • WhatsApp – Sends the same message via WhatsApp.

  • Set – Flags email and WhatsApp messages as successfully sent.

  • Google Sheets – Appends customer, order, and communication details.

  • Wait – Pauses before continuing to process the next completed order.

Why use this?

  • Automates post-purchase communication with zero manual effort.
  • Ensures consistent, personalized messaging across email and WhatsApp.
  • Adapts message tone automatically based on payment status.
  • Creates a centralized audit log in Google Sheets.
  • Scales easily as order volume grows.

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 - Postgres Trigger1

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

Block 2 - Execute a SQL query2

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

Block 3 - Loop Over Items1

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 4 - Execute a SQL query3

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

Block 5 - AI Agent1

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

Block 6 - Groq Chat Model1

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

Block 7 - Format AI response1

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

Block 8 - Send a message1

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

Block 9 - Merge1

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 10 - Send message1

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

Block 11 - Edit Fields1

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 12 - Append row in sheet1

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 13 - Wait1

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

Block 14 - Sticky Note3

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

Block 15 - Sticky Note4

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

Block 16 - Sticky Note5

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

3. Summary Table

Workflow Send AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq
Complexity advanced
Nodes 16
Categories Lead Nurturing, AI Chatbot
Author Avkash Kakdiya
Published 13 Jan 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/12673/12673.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 AI-powered post-purchase emails and WhatsApp messages from PostgreSQL to Google Sheets with Groq do?

How it works This workflow automatically detects completed orders in PostgreSQL and prepares them for AI based post purchase communication. It enriches each order with customer, product, and paymen...

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 Chatbot use case.