Skip to content

Commit

Permalink
update docs with slot validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ancalita committed Sep 21, 2023
1 parent 141480e commit 5c6b1c5
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion docs/docs/concepts/flows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ response will be used to fill the "account_type" slot.
:::note

The slot needs to be defined in the domain file. See the
[domain documentation](./domain.mdx) for more information. Additionaly, the slot
[domain documentation](./domain.mdx) for more information. Additionally, the slot
should have fitting slot mappings.

:::
Expand Down Expand Up @@ -483,6 +483,44 @@ flow is completed.
scope: "flow"
```

#### Slot value validation

You can now write slot value validation directly in your flow yaml file without the need to use custom actions.
Add a `rejections` property to your `collect_information` step to define the validation rules.
The `rejections` section is a list of mappings, where each mapping has an `if` and an `utter` property:
- the `if` property is a condition written in natural language that is evaluated using the
[pypred](https://github.com/armon/pypred) library.

Check warning on line 492 in docs/docs/concepts/flows.mdx

View workflow job for this annotation

GitHub Actions / Typo CI

pypred

"pypred" is a typo. Did you mean "preyed"?
- the `utter` property is the name of the response the assistant will send if the condition evaluates to `True`.

Here is an example:

```yaml
flows:
verify_eligibility:
description: This flow verifies if the user is eligible for creating an account.
name: verify eligibility
steps:
- id: "ask_age"
collect: "age"
rejections:
- if: age < 1
utter: utter_invalid_age
- if: age < 13
utter: utter_age_at_least_13
next: "ask_email"
```

Upon every validation failure, the assistant will again make another attempt to collect the information.
This will be repeated until none of the rejection conditions pass. Once all rejections have evaluated to `False`, the
assistant moves on to the `next` step with the collected value.

If the predicate defined in the `if` property is invalid or missing, the assistant will log an error and respond with the
`utter_internal_error_rasa` response which by default is
`Sorry, I'm having trouble understanding you right now. Please try again later.`. However, you can customize this in
your domain file. We recommend using end-to-end testing to ensure that your flows work as expected.

If no rejections are defined, the assistant will fill the slot with the collected value and proceed to the next step.

### Link

A `link` step is used to link to another flow. Here is an example:
Expand Down

0 comments on commit 5c6b1c5

Please sign in to comment.