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 agent’s response.
Assertion types
Text assertion
Validates text in the 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 agent’s response.
Fails if We have received your order is in the 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 agent’s response.
Fails if We are preparing your purchase is in the agent’s response.Inverted assertion
Inverted assertion
In this example, configure the assertion as follows:
Validates that the agent’s response doesn’t include
error, for example, Your order will be shipped shortly.
Fails if the agent’s response includes error, for example, We found an error while processing your order.Data assertion
Validates the data fields and JSON structures of the agent’s message against the data provided in the input field. If the 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 |
|---|---|
| Check for absence | Deactivated |
| Use partial comparison | Deactivated |
| Expected 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 |
|---|---|
| Check for absence | Deactivated |
| Use partial comparison | Activated |
| Expected 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 |
|---|---|
| Check for absence | Activated |
| Use partial comparison | Activated |
| Expected 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 |
|---|---|
| Check for absence | Deactivated |
| Use partial comparison | Deactivated |
| Expected context |
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 |
|---|---|
| Check for absence | Deactivated |
| Use partial comparison | Activated |
| Expected context |
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 |
|---|---|
| Check for absence | Activated |
| Use partial comparison | Activated |
| Expected context |
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.