- The Sales and Marketing Agent built with H2O Super Agent combines three CatBoost predictive models, for churn, customer lifetime value, and segmentation, with generative AI to produce personalized recommendations per customer.
- The churn prediction model uses more than 120 engineered features with Optuna hyperparameter tuning and auto threshold optimization to flag at risk customers.
- The agent's RAG-powered recommendations use h2oGPTe to ingest customer data and business documents into collections, then generate personalized insights per customer or segment.
- The campaign creation system makes up to 8 concurrent parallel LLM calls to produce full HTML reports with dynamically injected charts, falling back to single request mode if parallelization fails.
- The agent's prompt template system manages more than 20 h2oGPTe fields across 12 default templates with version control and JSON import and export.
We recently built a custom sales and marketing agent that combines predictive ML with generative AI capabilities. Here's what went into it and how it works.
Sales and marketing teams have plenty of data, but using it effectively is the real challenge. Traditional marketing often relies on guesswork, casting a wide net and hoping for the best.
While standard AI can predict numbers (like who might leave), and Generative AI can write text, combining them into a useful tool is difficult.
In this post, we introduce a Sales & Marketing Agent built with H2O Super Agent. This system bridges the gap between raw data and action. It combines predictive models—which identify risks and opportunities—with Generative AI to create personalized recommendations and reports for every customer based on needs, behavior and lifetime value.
This is a technical overview of how the agent is designed: the modeling stack, feature engineering pipeline, RAG integration, prompt management system, and the infrastructure that holds it all together.
The Core ML Stack
The foundation is three CatBoost models handling different prediction tasks:
- Churn prediction uses 120+ engineered features with Optuna hyperparameter tuning. It outputs probabilities with auto-threshold optimization to flag at-risk customers.
- CLV forecasting predicts 90-day customer lifetime value using RFM-based features selected through mutual information scoring.
- Customer segmentation combines both models to classify customers into five profiles: VIPs, Steady Buyers, Onboarders, Churn Risks, and Dormant accounts.
Feature Engineering Pipeline
The preprocessing layer generates features across eight categories: recency, frequency, monetary value, product preferences, behavioral patterns, temporal trends, engagement metrics, and trajectory indicators. Product interactions get embedded into 16 dimensions using TruncatedSVD. The pipeline automatically maps columns across different data schemas.
RAG-Powered Recommendations
We integrated H2O GPTe for context-aware recommendations using retrieval-augmented generation. The system ingests customer data and business documents into collections, then generates personalized insights per customer or segment.
For campaign creation, we built a multi-part HTML generator that makes parallel LLM calls—up to 8 concurrent requests—to produce full reports with dynamically injected charts. It falls back to single-request mode if parallelization fails.
Prompt Template System
Managing LLM behavior required a proper template system. We built version-controlled prompt templates covering 20+ H2O GPTe fields (system prompts, queries, summaries, reflection prompts). The system includes 12 default templates and supports import/export in JSON.
There's also an interactive testing module where you can run prompts against real data and iteratively refine them through a chat interface.
Email Campaigns
The agent generates email copy for five campaign types: retention, re-engagement, upsell, loyalty rewards, and special offers. SMTP integration handles batch sending to customer segments with HTML and plain text formats. Drafts get previewed before sending.
Data Handling
The upload manager accepts CSV, PDF, DOCX, TXT, HTML, JSON, and images through drag-and-drop. Documents automatically feed into H2O GPTe collections for RAG. There's a multi-format viewer for inspecting uploaded files.
Analytics Layer
We built an interactive dashboard with 11+ Plotly charts showing order trends, segment distributions, CLV histograms, churn gauges, and more. Global KPIs track revenue, active customers, total orders, and average order value. The customer 360° view displays complete order history, RFM scores, churn probabilities, and product preferences.
Architecture Notes
Background job processing handles async tasks like recommendation generation with real-time status tracking. The config manager centralizes H2O GPTe settings, SMTP configuration, and template assignments with connection testing.
Export functionality outputs customer profiles and at-risk lists as CSV, HTML campaigns as downloads, and recommendation bundles in ZIP format.
Wrapping Up
This agent demonstrates how predictive and generative AI can work together effectively—ML models identify patterns and quantify risk, while LLMs translate those insights into actionable recommendations and content. The architecture is straightforward: solid feature engineering yields accurate predictions that provide context for relevant LLM outputs. It's not revolutionary, but it's practical. The modular design means you can swap components, experiment with different models, or adjust prompt strategies without rebuilding everything. If you're working on similar problems, start with your data pipeline and feature quality—everything else builds from there.
:quality(75))