Build your agent
Behavior rules & triggers
Behavior rules let the agent do more than chat — fire a CTA, capture a lead, route to a human — based on signals like keywords, URL patterns, scroll depth, idle time, or message count. Rules are evaluated server-side during prompt assembly and client-side for UI affordances.
Rule structure
Every rule has three essential pieces:
- Kind — one of
cta,lead_capture,route,curated. - Conditions — JSON describing when the rule activates: keywords, URL patterns, scroll depth, idle duration, message count.
- Action — JSON describing what to do when it fires.
Rules also carry an enabled flag and a priority integer. When multiple rules match the same turn, higher priority wins.
Visitor-side triggers
The widget watches a few lightweight signals locally — no extra request to the server:
- Scroll depth — fires past a percentage threshold.
- Idle — fires after N seconds without interaction.
- Exit intent — fires when the cursor moves toward the top of the viewport.
- URL match — pattern-based page detection.
Because these are local, response is instant.
Rule kinds
- CTA — renders a card with title, description, and one or two buttons (open URL, send message, capture lead, dismiss).
- Curated — bypasses RAG with a fixed answer, ideal for pricing, legal language, or support routing where consistency matters. See Curated answers.
- Lead capture — triggers an inline form after a conversation milestone (message count, low-confidence detection, intent signal).
- Route — escalates to a human operator when complexity indicators emerge.
Management & testing
Rules are edited at /app/agents/{id}/behavior with a kind-aware builder. The runtime allows up to 20 enabled rules per widget init — additional rules are silently skipped, so prune aggressively.
Variants can be A/B tested via Experiments and validated end-to-end in the Playground.
Note. Rules and curated answers serve overlapping use cases. As a rule of thumb, use curated answers for “exact-question → exact-answer” mappings, and behavior rules for “visitor signal → UI action”.
Time-on-page trigger
The time rule kind fires a fixed number of seconds after the page loads, independent of what the visitor does — useful for opening the bar with a proactive nudge once someone has lingered long enough to be worth engaging. Configure it with the Delay (seconds) field; the widget stores it as { "seconds": N } (default 30) in the rule's conditions. Evaluation is local to the widget, so the fire is instant with no extra request.
Like every trigger, it also carries cooldown_seconds (default 300) so a re-visit within the window doesn't fire again. Don't confuse time with idle: idle counts seconds of inactivity (no mouse, scroll, or keypress), whereas time counts wall-clock seconds on the page.
Abandoned-cart trigger
The abandoned_cart rule kind fires when a visitor has a non-empty cart that has sat idle past a threshold — the moment to re-engage a shopper who's drifting away from checkout. Configure it with the Cart idle (minutes) field, stored as { "idle_minutes": N } (default 5).
This trigger needs the WordPress/WooCommerce companion plugin: the plugin injects the live cart state the widget watches, so on a plain snippet install (no plugin) abandoned_cart has nothing to read and won't fire. Both time and abandoned_cart are part of the validated rule-kind set — exit_intent, idle, scroll, time, returning, utm, abandoned_cart, url — and are edited from the same agent Behavior triggers builder.