Building a Next Best Action AI Engine with n8n: Precise Recommendations for Upsell, Cross-sell, and Retention

A Reddit user built an AI sales recommendation engine with n8n, using hard product catalog constraints to suppress hallucination.
A Reddit user built a "Next Best Action" engine with n8n that aggregates customer usage, tickets, purchased products, and other signals for Gemini to output a single action and product. The key design injects the Postgres product catalog into the prompt, forcing the model to pick only real products and structurally suppressing hallucination; a code layer then re-validates, strong opportunities with confidence 70+ go to Slack, and all results are logged. The stack uses free tiers of n8n Cloud, Gemini, Slack, and Supabase, with a demo of 4 simulated customers. The author also asks whether the threshold should be tuned by segment, suggesting calibration with real conversion data first.
Problem: Three Blind Spots in Sales Recommendations
Traditional upsell and cross-sell recommendations often rely on a sales rep's experience and judgment. The author of the original post points out that a customer's usage data, support tickets, and purchased product mix all affect recommendation quality, but in reality nobody checks these dimensions for every single account. This leads to two consequences: first, high-potential upgrade opportunities get missed; second, customers are recommended products they don't need or that the company doesn't even sell.
The entry point of this workflow is pragmatic—it doesn't pursue a complex recommendation algorithm, but instead aggregates scattered customer signals, hands them to a large model for structured judgment, and then uses a code layer for validation as a fallback.

Workflow Breakdown: From Customer Data to Slack Notifications
The entire process can be divided into four stages.
Data input: Customer data includes fields such as plan type, usage, purchased products, customer tenure in months, and open tickets. The demo version uses 4 simulated customers to make it easy to quickly validate the logic.
Catalog injection: The product catalog is read from the products table in Postgres and incorporated into the prompt. This is the most critical part of the entire design—the model can only choose products from this table, so it's impossible for it to fabricate plans the company doesn't sell. The author emphasizes that as long as this table is changed, the recommendation results will change accordingly.
AI decision-making: The Gemini-powered AI Agent node outputs a structured JSON answer containing the action type (upsell, cross-sell, retention, or none), the specific product, a confidence score, and a brief rationale. Note that this uses an Agent node without tools—essentially having the model return fixed-structure JSON rather than letting the model autonomously call external tools.
Validation and distribution: A code step validates the AI answer, checking whether the recommended product actually exists in the catalog. Those with confidence of 70 or above and an action that isn't none are considered "strong opportunities" and pushed to Slack for the sales team to follow up; meanwhile, all recommendation results are written back to Postgres for record-keeping.
Why Product Catalog Constraints Matter More Than Prompt Engineering Tricks
Many people spend their energy polishing prompts when building LLM applications, but this project offers a different approach: using external data sources as hard constraints.
When the model is restricted to only selecting products from a Postgres table, the outlet for hallucination is greatly narrowed. Even if the model's understanding of a customer is off, the product names it outputs are at least real and sellable. This "catalog as whitelist" approach is far more reliable than repeatedly emphasizing "don't fabricate products" in the prompt, because the former is a structural constraint while the latter is merely a soft request.
The author also performs secondary validation at the code layer, which amounts to adding a gate between the model output and the business system. This pattern is worth learning from for any scenario that needs AI output to translate into business actions: the model is responsible for judgment, and the code is responsible for gatekeeping.
LLM hallucination refers to a model generating content that appears plausible but is factually nonexistent or incorrect; in product recommendation scenarios, this manifests as fabricating nonexistent plans or services. Common mitigation methods include prompt emphasis, few-shot examples, and post-processing of outputs, but these are all soft constraints—the model can still overstep. "Catalog as whitelist" is a structural constraint: injecting the list of selectable products as external knowledge into the prompt and validating at the code layer whether the output belongs to that list, which is equivalent to establishing a hard gate between the model and the business system, structurally preventing fabricated products from flowing downstream.
Free Tech Stack and Two Practical Lessons
The project uses entirely free tiers: n8n Cloud, Gemini, Slack, and Supabase (Postgres). For individual developers or small teams wanting to validate an idea, the startup cost of this combination is essentially zero.
The author shares two lessons learned from pitfalls. First, you must validate AI output in code and verify that the product is in the catalog before the message enters Slack—this is exactly the gatekeeping logic mentioned earlier. Second, the Slack message text must use Expression mode; otherwise {{ }} will be displayed as plain text verbatim rather than being parsed as a variable. Such details may seem trivial, but they are key to whether the workflow can actually run successfully.
n8n is an open-source workflow automation tool that supports visual node orchestration, integrates with hundreds of services, and offers a free cloud tier—suitable for quickly building AI prototypes. Supabase is an open-source backend-as-a-service (BaaS) based on Postgres, providing database, authentication, storage, and other features; its free tier can be used for validating small projects. Gemini is Google's series of large language models, offering free API call quotas. Slack is a team collaboration and notification platform, often used to receive automated alerts or business reminders. What these tools share is that they're quick to get started with and cost nothing to launch—very suitable for individual developers or small teams doing proof-of-concept work.
Should the Confidence Threshold Be Fixed or Tuned by Segment?
At the end of the post, the author raises an open question: is a confidence of 70 as the cutoff for strong opportunities trustworthy, or should it be tuned separately by customer segment?
This question touches on the core tension of AI-assisted sales. A fixed threshold is simple to implement and predictable in behavior, but decision difficulty varies greatly across customer groups—a single upgrade action for a large customer involves a higher amount of money and should reasonably require higher confidence, while actions for long-tail customers carry lower risk and the threshold can be relaxed appropriately. On the other hand, segment-based tuning requires enough historical data to calibrate and may actually introduce noise during the cold-start phase.
From an engineering perspective, a more prudent path is to first store the threshold together with the recommendation results in the database, and after accumulating data for a period, review the actual conversion of "strong opportunities" and use real feedback to calibrate the threshold, rather than designing complex dynamic rules from the start.
Limitations and Applicable Boundaries
It should be clear that this project is currently demonstrative in nature: it runs on simulated data, the AI Agent has no tools, and the output is single-turn structured JSON. It can prove the process is feasible, but it's still far from production-ready—real-world customer data cleaning, A/B validation of recommendation results, and a feedback loop with the sales team all require additional work.
However, as a reusable skeleton, its value lies in having run through the chain of "data aggregation—model judgment—code validation—human follow-up" and in using product catalog constraints to solve the most troublesome hallucination problem in LLM deployment. For teams exploring how to embed AI into sales processes, this is an extremely low-cost starting point.
Background
The AI Agent node is a component in n8n specifically for integrating large language models; it supports capabilities such as binding tools and memory, but this workflow uses an "Agent node without tools"—essentially a structured output node that follows a system prompt and returns JSON. This approach is more controllable from an engineering standpoint: the model doesn't need to autonomously decide which external API to call; it only needs to generate answers in a fixed format based on the injected context, making subsequent code validation and workflow orchestration easier.
One-line Summary
A Reddit user built an AI sales recommendation engine with n8n, using hard product catalog constraints to suppress hallucination.
Paragraph Summary
A Reddit user built a "Next Best Action" engine with n8n that aggregates signals such as customer usage, tickets, and purchased products, and has Gemini output a single action and product. The core design is to inject the product catalog from Postgres into the prompt so the model can only choose from real products, structurally suppressing hallucination; the code layer then re-validates whether the product exists, strong opportunities with confidence above 70 are pushed to Slack, and all results are stored in the database. The entire stack uses the free tiers of n8n Cloud, Gemini, Slack, and Supabase, and the demo is based on 4 simulated customers. The author also raises an open question about whether the confidence threshold should be tuned by customer segment, suggesting calibrating with real conversion data first.
Related articles

Gemini 4 Neon Hands-On: Value King or Confident Catastrophe?
Gemini 4 Neon review: 1M-token context, four thinking levels, 201 files in one KingBench4 pass at one-tenth Fable 5.2's cost—but it hallucinates fake data, leaves 7 symlink escapes, and bricks keyboards.

Google Gemini 4 Neon Hands-On: 6 3D Works That Impress and Fail
Hands-on with Google Gemini 4 Neon on a 3060 laptop: 6 3D works tested. Sunshower Fishing Harbor and mechanical keyboard impress; soft-body physics and faces fall short.

Gemini 4 Neo Web Novel Writing Test: Faint AI Flavor, Textured Dialogue
Bilibili creator's first-look review of Gemini 4 Neo for Chinese web novel writing: testing a Three Kingdoms transmigration opening with faint AI flavor, emotionally textured dialogue, and strong crisis building, plus comparison of 4A/4H/4C models and full workflow demos.