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”.