AI Segment Builder
Describe your target audience in plain English and let SegOps generate the segment definition automatically using a multi-step AI reasoning pipeline.
Accessing the AI Builder#
Open any segment and click the AI Builder tab next to the Rule Builder tab. A chat panel opens on the right side of the screen. You can use the AI builder for both new and existing segments.
Prompt Patterns That Work Well#
The AI works best with specific, quantitative descriptions. Use phrasing like:
- “Users who placed more than 3 orders in the last 90 days”
- “Customers who spent over $500 total and haven't visited in 30 days”
- “Users in the US who started a trial but never purchased”
- “Anyone who viewed the /pricing page at least once and hasn't converted”
- “High-value customers: total revenue over $1000, at least 5 orders, last order within 60 days”
- “Cart abandoners: added to cart but never placed an order in the last 14 days”
order_placed, cart_add). If you have registered Event Schemas, the AI uses those as context for better accuracy.How It Works#
Under the hood, the AI builder uses a LangGraph 3-node flow:
- Classify — the model identifies what kind of audience is being requested (recency, monetary, event-count, property-based, sequence, etc.)
- Plan — the model produces a structured plan mapping each part of the description to a specific condition type and parameters
- Compile — the plan is converted into a valid Segment DSL JSON document
The response streams token-by-token via Server-Sent Events, so you see the AI thinking in real time. When the final DSL is ready, it is displayed in the chat panel for your review.
Review and Edit Before Saving#
The AI-generated definition is shown as an editable condition list. You can:
- Accept the definition as-is and click Apply to Segment
- Edit individual conditions in the rule builder before applying
- Ask a follow-up question (e.g., “Change the order threshold to 5”)
- Discard and try a different prompt
The AI definition is not saved until you click Save Definition in the rule builder. Until then, no version snapshot is created.
Example Output#
For the prompt “Customers who spent over $500 total and haven't visited in 30 days”, the AI produces:
Limitations#
- Complex event sequences— highly specific ordered sequences (e.g., “viewed pricing, then started checkout, then abandoned, then came back within 1 hour”) may require manual refinement.
- Custom event schema required — the AI is more accurate when Event Schemas are defined. Without them, it may use generic property names.
- Math constraints— expressions like “in the top 10% by revenue” cannot be expressed in the current DSL; use a known threshold instead.
- Nested logic — the AI produces flat AND/OR logic; (A OR B) AND C patterns require manual editing.
Streaming UI#
The chat panel displays the AI's reasoning in real time as it streams. You will see the model classify the request, plan the conditions, and produce the final JSON before it is rendered as an editable rule list. If the stream stalls, refresh the panel — network issues can interrupt SSE connections.