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
"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.Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates that
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
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
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.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.Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
"greet.hello" Intent has been recognized.Inverted Match
Inverted Match
In this example, configure the assertion as follows:
Validates that the
"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.Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
username Slot has been recognized.Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates that the
password Slot hasn’t been recognized.Context Assertion
Validates the data in the Context object against the data provided in the input field.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.Examples
Exact Match
Exact Match
In this example, configure the assertion as follows:
Validates only that the
waiting_for_input State is active.Inverted Assertion
Inverted Assertion
In this example, configure the assertion as follows:
Validates only that the
error_state State isn’t active.