Avatar
Custom Rules & JSON Schema
Write deterministic Avatar Studio custom rules in JSON Code Mode across data, action, page, domain, and topic scopes. Overview Avatar Studio evaluates every...
On this page (11 sections)
Overview
Avatar Studio evaluates every visitor question, page context, and action against a deterministic policy engine before calling the AI model. You can author custom rules in Code Mode using a strict JSON object (rule.json).
All custom rules are saved as draft first, can be tested against live scenarios in the sidebar, and take effect when enabled or published.
Rule JSON Schema
{
"name": "Protect unpublished pricing",
"description": "Do not disclose internal or draft pricing.",
"scope": "data",
"target": {
"categories": ["internal_pricing", "draft_discounts"]
},
"effect": "deny",
"message": "Only publicly listed prices can be shared.",
"conditions": {
"visitorState": "anonymous",
"pages": ["/pricing", "/enterprise/*"]
},
"priority": 50,
"status": "draft"
}
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Rule title (1–120 characters). |
description | string | No | Optional summary of what the rule does (max 2000 chars). |
scope | string | Yes | One of "data", "action", "page", "domain", or "topic". |
target | object | Yes | Scope-specific target object (see table below). |
effect | string | Yes | One of "deny", "allow", "require_confirmation", "redact", "escalate", or "fixed_message". |
message | string | Conditional | Visitor-facing message. Required when effect is "fixed_message", optional when "deny". |
conditions | object | No | Optional filter object (visitorState, pages, pageGroups). |
priority | number | No | Integer 0–100 (default 50). Higher numbers run first within the same effect tier. |
status | "draft" | No | New edits always validate as "draft". |
Scopes & Target Formats
Each scope requires a specific key inside target:
| Scope | Required target Key | Value Format | Example |
|---|---|---|---|
data | categories | string[] (snake_case) | { "categories": ["internal_pricing", "stock_levels"] } |
action | actions | string[] (snake_case) | { "actions": ["cancel_order", "book_appointment"] } |
page | patterns | string[] (URL path or /*) | { "patterns": ["/checkout/*", "/admin/*"] } |
domain | domains | string[] (hostname or *.domain) | { "domains": ["app.example.com", "*.example.com"] } |
topic | keywords | string[] (phrases, 2–80 chars) | { "keywords": ["competitor x", "unreleased roadmap"] } |
Effects Reference
| Effect | Runtime Behavior |
|---|---|
deny | Blocks the request or action and returns message (or a safe refusal). |
fixed_message | Returns the exact message string without invoking the LLM. |
require_confirmation | Requires explicit visitor confirmation before executing an action. |
escalate | Hands the conversation off to your human support flow. |
redact | Masks matching data categories before processing. |
allow | Explicitly permits the target when no higher-precedence deny or mandatory rule blocks it. |
Conditions & Priority
Use conditions to narrow when a rule applies:
"conditions": {
"visitorState": "anonymous",
"pages": ["/pricing", "/plans/*"],
"pageGroups": ["checkout", "account"]
}
visitorState:"anonymous"or"authenticated"(omit to match all visitors).
pages: Array of path prefixes or wildcard patterns starting with/.
pageGroups: Array of logical page group keys (snake_case).
Examples by Scope
1. Data Rule (scope: "data")
{
"name": "Allow order status for signed-in visitors",
"scope": "data",
"target": {
"categories": ["order_status", "bookings"]
},
"effect": "allow",
"conditions": {
"visitorState": "authenticated"
},
"priority": 60
}
2. Action Rule (scope: "action")
{
"name": "Confirm before cancelling orders",
"scope": "action",
"target": {
"actions": ["cancel_order", "change_order_address"]
},
"effect": "require_confirmation",
"priority": 70
}
3. Page Rule (scope: "page")
{
"name": "Disable avatar on internal admin paths",
"scope": "page",
"target": {
"patterns": ["/admin/*", "/internal/*"]
},
"effect": "deny",
"message": "The assistant is disabled on administration pages.",
"priority": 80
}
4. Topic Rule (scope: "topic")
{
"name": "Escalate billing refund disputes",
"scope": "topic",
"target": {
"keywords": ["chargeback", "refund dispute", "billing error"]
},
"effect": "escalate",
"priority": 65
}
---
Mandatory Platform Locks (M01–M15)
Custom rules cannot weaken mandatory platform rules:
- M01 / M03 (Locked Data):
card_number,cvv,bank_details,upi_credentials,password,one_time_code,auth_token,api_key,government_id, andspecial_category_datacan never be set toallow.
- M05 (Private Data): Private customer data (
order_status,account_summary,bookings,subscription_status) always requires anauthenticatedvisitor session at runtime.
- M07 (Critical Actions):
payment,account_deletion,password_change,credential_change,money_transfer, andlegal_acceptancecannot be enabled by a custom rule.