These docs are for version 1.x of Rasa Open Source.

## User Guide

- [Installation](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/installation/)
- [Tutorial: Rasa Basics](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/rasa-tutorial/)
- [Tutorial: Building Assistants](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/building-assistants/)
- [Command Line Interface](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/command-line-interface/)
- [Architecture](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/architecture/)
- [Messaging and Voice Channels](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/messaging-and-voice-channels/)
- [Testing Your Assistant](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/testing-your-assistant/)
- [Setting up CI/CD](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/setting-up-ci-cd/)
- [Validate Data](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/validate-files/)
- [Configuring the HTTP API](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/configuring-http-api/)
- [Deploying Your Rasa Assistant](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/how-to-deploy/)
- [Cloud Storage](https://legacy-docs-v1.rasa.com/1.9.6/user-guide/cloud-storage/)

## NLU

- [About](https://legacy-docs-v1.rasa.com/1.9.6/nlu/about/)
- [Using NLU Only](https://legacy-docs-v1.rasa.com/1.9.6/nlu/using-nlu-only/)
- [Training Data Format](https://legacy-docs-v1.rasa.com/1.9.6/nlu/training-data-format/)
- [Language Support](https://legacy-docs-v1.rasa.com/1.9.6/nlu/language-support/)
- [Choosing a Pipeline](https://legacy-docs-v1.rasa.com/1.9.6/nlu/choosing-a-pipeline/)
- [Components](https://legacy-docs-v1.rasa.com/1.9.6/nlu/components/)
- [Entity Extraction](https://legacy-docs-v1.rasa.com/1.9.6/nlu/entity-extraction/)

## Core

- [About](https://legacy-docs-v1.rasa.com/1.9.6/core/about/)
- [Stories](https://legacy-docs-v1.rasa.com/1.9.6/core/stories/)
- [Domains](https://legacy-docs-v1.rasa.com/1.9.6/core/domains/)
- [Responses](https://legacy-docs-v1.rasa.com/1.9.6/core/responses/)
- [Actions](https://legacy-docs-v1.rasa.com/1.9.6/core/actions/)
- [Reminders and External Events](https://legacy-docs-v1.rasa.com/1.9.6/core/reminders-and-external-events/)
- [Policies](https://legacy-docs-v1.rasa.com/1.9.6/core/policies/)
- [Slots](https://legacy-docs-v1.rasa.com/1.9.6/core/slots/)
- [Forms](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#)
- [Retrieval Actions](https://legacy-docs-v1.rasa.com/1.9.6/core/retrieval-actions/)
- [Interactive Learning](https://legacy-docs-v1.rasa.com/1.9.6/core/interactive-learning/)
- [Fallback Actions](https://legacy-docs-v1.rasa.com/1.9.6/core/fallback-actions/)
- [Knowledge Base Actions](https://legacy-docs-v1.rasa.com/1.9.6/core/knowledge-bases/)

## Conversation Design

- [Dialogue Elements](https://legacy-docs-v1.rasa.com/1.9.6/dialogue-elements/dialogue-elements/)
- [Small Talk](https://legacy-docs-v1.rasa.com/1.9.6/dialogue-elements/small-talk/)
- [Completing Tasks](https://legacy-docs-v1.rasa.com/1.9.6/dialogue-elements/completing-tasks/)
- [Guiding Users](https://legacy-docs-v1.rasa.com/1.9.6/dialogue-elements/guiding-users/)

## API Reference

- [Action Server](https://legacy-docs-v1.rasa.com/1.9.6/api/action-server/)
- [HTTP API](https://legacy-docs-v1.rasa.com/1.9.6/api/http-api/)
- [Jupyter Notebooks](https://legacy-docs-v1.rasa.com/1.9.6/api/jupyter-notebooks/)
- [Agent](https://legacy-docs-v1.rasa.com/1.9.6/api/agent/)
- [Custom NLU Components](https://legacy-docs-v1.rasa.com/1.9.6/api/custom-nlu-components/)
- [Rasa SDK](https://legacy-docs-v1.rasa.com/1.9.6/api/rasa-sdk/)
- [Events](https://legacy-docs-v1.rasa.com/1.9.6/api/events/)
- [Tracker](https://legacy-docs-v1.rasa.com/1.9.6/api/tracker/)
- [Tracker Stores](https://legacy-docs-v1.rasa.com/1.9.6/api/tracker-stores/)
- [Event Brokers](https://legacy-docs-v1.rasa.com/1.9.6/api/event-brokers/)
- [Lock Stores](https://legacy-docs-v1.rasa.com/1.9.6/api/lock-stores/)
- [Training Data Importers](https://legacy-docs-v1.rasa.com/1.9.6/api/training-data-importers/)
- [Featurization of Conversations](https://legacy-docs-v1.rasa.com/1.9.6/api/core-featurization/)
- [TensorFlow Configuration](https://legacy-docs-v1.rasa.com/1.9.6/api/tensorflow_usage/)
- [Migration Guide](https://legacy-docs-v1.rasa.com/1.9.6/migration-guide/)
- [Rasa Open Source Change Log](https://legacy-docs-v1.rasa.com/1.9.6/changelog/)

## Migrate from (beta)

- [Dialogflow](https://legacy-docs-v1.rasa.com/1.9.6/migrate-from/google-dialogflow-to-rasa/)
- [Wit.ai](https://legacy-docs-v1.rasa.com/1.9.6/migrate-from/facebook-wit-ai-to-rasa/)
- [LUIS](https://legacy-docs-v1.rasa.com/1.9.6/migrate-from/microsoft-luis-to-rasa/)
- [IBM Watson](https://legacy-docs-v1.rasa.com/1.9.6/migrate-from/ibm-watson-to-rasa/)

## Reference

- [Glossary](https://legacy-docs-v1.rasa.com/1.9.6/glossary/)

## Versions

viewing: 1.9.6

# Forms

## Note

There is an in-depth tutorial [here](https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction/) about how to use Rasa Forms for slot filling.

### Configuration File

- [Configuration File](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#configuration-file)

### Form Basics

- [Form Basics](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#form-basics)

### Custom slot mappings

- [Custom slot mappings](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#custom-slot-mappings)

### Validating user input

- [Validating user input](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#validating-user-input)

### Handling unhappy paths

- [Handling unhappy paths](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#handling-unhappy-paths)

### The requested_slot slot

- [The requested_slot slot](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#the-requested-slot-slot)

### Handling conditional slot logic

- [Handling conditional slot logic](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#handling-conditional-slot-logic)

### Debugging

- [Debugging](https://legacy-docs-v1.rasa.com/1.9.6/core/forms/#debugging)

One of the most common conversation patterns is to collect a few pieces of information from a user in order to do something (book a restaurant, call an API, search a database, etc.). This is also called **slot filling**. If you need to collect multiple pieces of information in a row, we recommended that you create a `FormAction`. This is a single action which contains the logic to loop over the required slots and ask the user for this information. There is a full example using forms in the `examples/formbot` directory of Rasa Core.

When you define a form, you need to add it to your domain file. If your form’s name is `restaurant_form`, your domain would look like this:

```
forms:
  - restaurant_form
actions:
  ...
```

To use forms, you also need to include the `FormPolicy` in your policy configuration file. For example:

```
policies:
  - name: "FormPolicy"
```

Using a `FormAction`, you can describe _all_ of the happy paths with a single story. By “happy path”, we mean that whenever you ask a user for some information, they respond with the information you asked for.

If we take the example of the restaurant bot, this single story describes all of the happy paths:

```
## happy path
* request_restaurant
    - restaurant_form
    - form{"name": "restaurant_form"}
    - form{"name": null}
```

In this story the user intent is `request_restaurant`, which is followed by the form action `restaurant_form`. With `form{"name": "restaurant_form"}` the form is activated and with `form{"name": null}` the form is deactivated again.

The `FormAction` will only request slots which haven’t already been set. If a user starts the conversation with I’d like a vegetarian Chinese restaurant for 8 people, then they won’t be asked about the `cuisine` and `num_people` slots.

Note that for this story to work, your slots should be [unfeaturized](https://legacy-docs-v1.rasa.com/1.9.6/core/slots/#unfeaturized-slot). If any of these slots are featurized, your story needs to include `slot{}` events to show these slots being set. In that case, the easiest way to create valid stories is to use [Interactive Learning](https://legacy-docs-v1.rasa.com/1.9.6/core/interactive-learning/#interactive-learning).

The `FormPolicy` is extremely simple and just always predicts the form action. Every time the form action gets called, it will ask the user for the next slot in `required_slots` which is not already set. It does this by looking for a response called `utter_ask_{slot_name}`, so you need to define these in your domain file for each required slot.

Once all the slots are filled, the `submit()` method is called, where you can use the information you’ve collected to do something for the user, for example querying a restaurant API. If you don’t want your form to do anything at the end, just use `return []` as your submit method.

## Example Code

```python
def name(self) -> Text:
    """Unique identifier of the form"""
    return "restaurant_form"
```

```python
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
    """A list of required slots that the form has to fill"""
    return ["cuisine", "num_people", "outdoor_seating", "preferences", "feedback"]
```

```python
def submit(
    self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> List[Dict]:
    """Define what the form has to do
        after all required slots are filled"""
    dispatcher.utter_message(template="utter_submit")
    return []
```

If you want to allow a combination of these, provide them as a list as in the example above.

After extracting a slot value from user input, the form will try to validate the value of the slot. This can be done by writing a helper validation function with the name `validate_{slot-name}`. Here’s an example , `validate_cuisine()` that checks if the extracted cuisine slot belongs to a list of supported cuisines.

```python
    @staticmethod
def cuisine_db() -> List[Text]:
        """Database of supported cuisines"""
        return ["caribbean","chinese","french","greek","indian","italian","mexican"]
```

```python
def validate_cuisine(
    self,
    value: Text,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any],
) -> Dict[Text, Any]:
    """Validate cuisine value."""
    if value.lower() in self.cuisine_db():
        return {"cuisine": value}
    else:
        dispatcher.utter_message(template="utter_wrong_cuisine")
        return {"cuisine": None}
```

If you are writing stories by hand, you will likely miss important things. Please read [Interactive Learning with Forms](https://legacy-docs-v1.rasa.com/1.9.6/core/interactive-learning/#section-interactive-learning-forms).
