How to Use Assertions
Assertions include an input field where you can provide the text or data you want to validate during the Playbook run. Assertions are case-sensitive. The text, Intent names, Slot names, and data fields that you enter in the input field must match exactly what you want to validate. Specific assertion types include an option to validate only a portion of the provided text or data:- Use fuzzy search — for text assertions.
- Use partial comparison — for data and context assertions.
Fuzzy Search Examples
Fuzzy Search Examples
Pattern | Feature | Matches |
---|---|---|
My order | Case Insensitivity | my order , MY ORDER |
Differences in spaces |
| |
Newlines |
| |
Escaped Characters | My\norder , My\torder |
"status": "active"
JSON property or the word "error"
in the AI Agent’s response.
Assertion Types
Text Assertion
Validates text in the AI Agent’s response against the expected text or pattern provided in the input field.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the text or pattern provided in the input field. |
Use fuzzy search | Option | Allows partial matches in the AI Agent’s response. |
Text | Input field | Sets the exact text or pattern to validate. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates that
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use fuzzy search | Deactivated |
Text | Your order has been confirmed |
Your order has been confirmed
is present in the AI Agent’s response.
Fails if We have received your order
is in the AI Agent’s response.Fuzzy Search
Fuzzy Search
In this example, configure the assertion as follows:
Validates that
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use fuzzy search | Activated |
Text | "order" |
Your order has been confirmed
and We have received your order
are in the AI Agent’s response.
Fails if We are preparing your purchase
is in the AI Agent’s response.Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates that the AI Agent’s response doesn’t include
Parameter | Value |
---|---|
Invert assertion | Activated |
Use fuzzy search | Activated |
Text | "error" |
error
, for example, Your order will be shipped shortly
.
Fails if the AI Agent’s response includes error
, for example, We found an error while processing your order
.Data Assertion
Validates the AI Agent message’s data fields and JSON structures against the data provided in the input field. If the AI Agent’s response doesn’t include any data fields, the Assertion checks data fields in the user input.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the JSON structure provided in the input field or the user input. |
Use partial comparison | Option | Allows matches of a subset of the data structure to validate. |
Data | Input field | Sets the data structure to validate in JSON format. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only the exact JSON object provided in the input field.
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use partial comparison | Deactivated |
Data |
Partial Comparison
Partial Comparison
In this example, configure the assertion as follows:
Validates any JSON structure that contains the JSON object provided in the input field, for example:Fails if the JSON structure doesn’t contain the JSON object provided in the input field, for example:
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use partial comparison | Activated |
Data |
Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates any JSON structure that doesn’t contain the JSON object provided in the input field, for example:
Parameter | Value |
---|---|
Invert assertion | Activated |
Use partial comparison | Activated |
Data |
Intent Assertion
Validates that the Intent provided in the input field has been recognized in the user input.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the Intent provided in the input field. |
Intent | Input field | Sets the Intent name to validate. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Intent | "greet.hello" |
"greet.hello"
Intent has been recognized.Inverted Match
Inverted Match
In this example, configure the assertion as follows:
Validates that the
Parameter | Value |
---|---|
Invert assertion | Activated |
Intent | "cancel.order" |
"cancel.order"
Intent hasn’t been recognized.Slot Assertion
Validates that the Slot provided in the input field has been recognized in the user input.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the Slot provided in the input field. |
Slot | Input field | Sets the Slot name to validate. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Slot | username |
username
Slot has been recognized.Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates that the
Parameter | Value |
---|---|
Invert assertion | Activated |
Slot | password |
password
Slot hasn’t been recognized.Context Assertion
Validates the data in the Context object against the data provided in the input field.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the context data provided in the input field |
Use partial comparison | Option | Allows matches of a subset of the context data to validate. |
Context data | Input field | Sets the context data to validate in JSON format. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only the exact JSON object provided in the input field.
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use partial comparison | Deactivated |
Context data |
Partial Match
Partial Match
In this example, configure the assertion as follows:
Validates any context data that contains the JSON object provided in the input field, for example:Fails if the JSON structure doesn’t contain the JSON object provided in the input field, for example:
Parameter | Value |
---|---|
Invert assertion | Deactivated |
Use partial comparison | Activated |
Context data |
Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates any JSON structure that doesn’t contain the JSON object provided in the input field, for example:
Parameter | Value |
---|---|
Invert assertion | Activated |
Use partial comparison | Activated |
Context data |
State Assertion
Validates the conversation state.Parameter | Type | Description |
---|---|---|
Invert assertion | Option | Sets the assertion to validate the absence of the State provided in the input field. |
State | Input field | Sets the State name to validate. |
Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
Parameter | Value |
---|---|
Invert assertion | Deactivated |
State | waiting_for_input |
waiting_for_input
State is active.Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates only that the
Parameter | Value |
---|---|
Invert assertion | Activated |
State | error_state |
error_state
State isn’t active.