WhatsApp Product Catalog Chatbot with Database State Management - n8n Workflow

Deploy a dynamic WhatsApp product catalog bot using n8n workflow. Integrate PostgreSQL for conversational state and inventory lookup with this powerful n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

E-commerce businesses needing automated customer service via WhatsApp.
Developers looking for advanced n8n templates integrating real-time chat APIs and databases.
Automation specialists who manage complex conversational flows using the n8n node ecosystem.
Sales teams needing a scalable, always-on product information tool.

Overview

Building effective conversational bots requires robust state management, especially when integrating product data. This powerful n8n workflow solves this by using PostgreSQL to track user status and retrieve relevant product listings dynamically. It transforms the standard WhatsApp experience into an interactive catalog interface. By utilizing this n8n template, users can quickly deploy a sophisticated bot capable of handling initial greetings, main menu navigation, list displays, and detailed product cards. This specific n8n workflow ensures a smooth, non-linear conversation flow by checking the user's historical interaction state before processing new commands, significantly improving bot reliability and user experience. This comprehensive approach differentiates this as a highly effective n8n solution for WA automation.

How it Works

This n8n workflow begins when the WhatsApp Trigger n8n node receives an incoming message.


  1. Initialization and Status Check: The flow first moves to the Initialization n8n node to prepare the incoming data. Then, the Get Bot Status PostgreSQL n8n node queries the database to determine if the user is a first-time contact or mid-conversation.

  2. Start or Resume: The Start? If n8n node directs the flow. If the user is new (or restarting), the Starts WhatsApp n8n node sends an initial greeting, and the Upsert Bot Status PostgreSQL n8n node updates the database, setting the initial state. This establishes the context for the n8n workflow.

  3. Command Interpretation: If the user is mid-conversation, the flow bypasses the start sequence and enters the Commands Switch n8n node, which routes the message based on keywords or structure, making this a smart n8n workflow.

  4. Menu and Listing Logic: Commands related to the main menu are handled by the Main Menu WhatsApp n8n node. Commands requesting product listings hit the List? If n8n node.

  5. Catalog Retrieval: If a list is requested, the Get Card products PostgreSQL n8n node queries the catalog database. The results are aggregated and formatted using the Union Number with Question Set n8n node and the Union list Summarize n8n node.

  6. Response Delivery: Finally, the formatted list is sent back to the user via the List Cards WhatsApp n8n node, providing the dynamic product catalog. If the input indicates a specific product selection (the false branch of List?), a sequence of PostgreSQL n8n nodes fetches specific item details before the Card WhatsApp n8n node sends the rich product card. This robust n8n workflow handles all steps seamlessly.

Installation Guide

To install this automation using this n8n template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON and import it into your n8n instance via the Workflows section. This forms the basis of your new n8n automation.

  2. WhatsApp Credentials: Locate the WhatsApp Trigger and the various WhatsApp n8n node instances (e.g., Starts, Main Menu). You must configure your Meta/WhatsApp credentials (API Key, Phone Number ID, etc.) for each of these n8n nodes.

  3. PostgreSQL Credentials: Set up credentials for the PostgreSQL connection used by Get Bot Status, Upsert Bot Status, and all product-related PostgreSQL n8n nodes. Ensure the database structure contains tables for botstatus (to track user state) and productcatalog (or similar, for inventory data).

  4. Activation: Ensure the tables and connection details match the SQL queries configured within the PostgreSQL n8n nodes. Once credentials are set, activate the n8n workflow to begin receiving messages via the WhatsApp Trigger.

Node Details

This n8n workflow leverages specialized n8n nodes for seamless integration:

WhatsApp Trigger: The core starting n8n trigger. It listens for all incoming messages sent to the configured WhatsApp number, initiating the n8n workflow.
Function: Starts the conversation flow upon message receipt.
Key Configuration: Configured webhook ID specific to the WhatsApp integration.
Initialization (Set n8n node): Pre-processes the data payload from the WhatsApp Trigger, typically extracting sender ID and message content for use in later n8n nodes.
Postgres n8n nodes (Get Bot Status, Upsert Bot Status, Get Card products, etc.): These are crucial database n8n nodes. They handle all state management (checking current user status) and data retrieval (fetching product catalog details).
Function: Maintain conversational context and dynamically fetch product inventory.
Key Configuration: Requires PostgreSQL database connection credentials and specific SQL queries defined for upserting status and selecting product data.
If n8n node (Start?, List?): Core corelogicflow_control n8n nodes used to create branching paths based on boolean conditions (e.g., is this the first message? Is the user requesting a list?).
Switch n8n node (Commands): Directs the flow based on the textual content of the user's message, routing commands like menu requests or specific product numbers to the correct subsequent n8n node path.
WhatsApp n8n nodes (Starts, Main Menu, List Cards, Card): These output n8n nodes are responsible for formatting and sending responses back to the user on WhatsApp.
Function: Deliver greetings, menus, formatted lists, and detailed product cards.
Key Configuration: Each output node uses specific template IDs or custom message structures appropriate for the WhatsApp API.

Related n8n Workflows

Paid

Nodes: 8 Nodes
Updated: December 26 2025
View all
Created by
Andrew
Andrew

Analyst-Developer

Featured*