Availability rules
An availability rule controls which content the AI Agent can access during a conversation, based on the values of variables. A rule is set through the availability_rules field on a supported resource, such as a knowledge article. When a rule is set, the AI Agent can only use the resource on conversations where the variables’ values match the rule.
Rule schema
A rule is a two-level tree of conditions (a root group plus one level of nested groups):
conditions must contain at least one entry. A rule may contain at most 1000 conditions in total, counting every condition across the root and all nested condition groups.
See Performance recommendations when setting rules on articles in bulk.
Condition
variable— required. An object{ "id": "<variable id>" }identifying the variable to test. See Variable references.operator— required. The comparison to apply (see Operators below).value— required for non-unary operators; omit for unary operators (is_set,is_not_set).case_sensitive— optional, defaults tofalse. Only meaningful for the equality (equals,does_not_equal) and string (starts_with,ends_with,contains,does_not_contain) operators. Omitted from responses whenfalse.
ConditionGroup
A condition group applies a nested combinator to a list of conditions. Condition groups may contain only Condition objects — further nesting is not supported.
Variable references
A condition references a variable by its id:
The id is the stable identifier for a variable configured on your Agent. Look up the ids for your Agent through the Variables API.
Not every variable can be used in an availability rule. Variables whose value is set dynamically during a conversation aren’t available when a rule is evaluated, so referencing one returns a 400 with the Variable not usable in a rule error.
Operators
Unary operators (is_set, is_not_set) must not include a value field. Sending value with a unary operator returns a 400 error.
Validation errors
The API returns 400 for the following rule errors:
A validation failure returns a 400 with the error in the standard envelope:
Examples
Each example references variables by id. The ids below are illustrative — use the ids of the variables configured on your own Agent.
Language targeting
Match only when the conversation language (variable 5df263b7db5a7e6ea03fae9b) is English:
Presence targeting
Match only when a variable has a value. Here 664c0a1e9f3b2d4a8e7c1a02 is the loyalty_id variable, and the unary is_set operator takes no value:
Numeric comparison
Match only when a numeric variable exceeds a threshold. Here 664c0a1e9f3b2d4a8e7c1a07 is the loyalty_points variable:
Compound rule — any of several markets
Match on conversations from either Canada or the United States, where 664c0a1e9f3b2d4a8e7c1a04 is the region variable:
Compound rule — subscription plan with a nested group
Match paying users who are also on a higher loyalty tier, using a nested condition group. Here 664c0a1e9f3b2d4a8e7c1a05 is the subscription_plan variable and 664c0a1e9f3b2d4a8e7c1a06 is the loyalty_tier variable: