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

- [Docs for the new version 2.0 can be found here.](/content/docs/rasa/index.html)

## User Guide

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

## NLU

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

## Core

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

## Conversation Design

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

## API Reference

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

## Migrate from (beta)

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

## Reference

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

## Rasa SDK

Rasa SDK provides the tools you need to write custom actions in python.

### Installation

Use `pip` to install `rasa-sdk` on your action server.

```bash
pip install rasa-sdk
```

Note

You do not need to install `rasa` for your action server.  
E.g. if you are running Rasa in a docker container, it is recommended to create a separate container for your action server. In this separate container, you only need to install `rasa-sdk`.

### Running the Action Server

If you have `rasa` installed, run this command to start your action server:

```bash
rasa run actions
```

Otherwise, if you do not have `rasa` installed, run this command:

```bash
python -m rasa_sdk --actions actions
```

You can verify that the action server is up and running with the command:

```bash
curl http://localhost:5055/health
```

You can get the list of registered custom actions with the command:

```bash
curl http://localhost:5055/actions
```

The file that contains your custom actions should be called `actions.py`. Alternatively, you can use a package directory called `actions` or else manually specify an actions module or package with the `--actions` flag.

### Actions

The `Action` class is the base class for any custom action. It has two methods that both need to be overwritten, `name()` and `run()`.

In a restaurant bot, if the user says “show me a Mexican restaurant”, your bot could execute the action `ActionCheckRestaurants`, which might look like this:

```python
from rasa_sdk import Action
from rasa_sdk.events import SlotSet

class ActionCheckRestaurants(Action):
   def name(self) -> Text:
      return "action_check_restaurants"

def run(self,
           dispatcher: CollectingDispatcher,
           tracker: Tracker,
           domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

cuisine = tracker.get_slot('cuisine')
      q = "select * from restaurants where cuisine='{0}' limit 1".format(cuisine)
      result = db.query(q)

return [SlotSet("matches", result if result is not None else [])]
```

You should add the action name `action_check_restaurants` to the actions in your domain file. The action’s `run()` method receives three arguments. You can access the values of slots and the latest message sent by the user using the `tracker` object, and you can send messages back to the user with the `dispatcher` object, by calling `dispatcher.utter_message`.

### Details of the run() method:

#### _async_ Action.run(dispatcher, tracker, domain)

Execute the side effects of this action.

**Parameters**

- **dispatcher** – the dispatcher which is used to send messages back to the user. Use `dispatcher.utter_message()` or any other `rasa_sdk.executor.CollectingDispatcher` method.

- **tracker** – the state tracker for the current user. You can access slot values using `tracker.get_slot(slot_name)`, the most recent user message is `tracker.latest_message.text` and any other `rasa_sdk.Tracker` property.

- **domain** – the bot’s domain

**Returns**

A dictionary of `rasa_sdk.events.Event` instances that is returned through the endpoint.

**Return type**

`List[Dict[str, Any]]`

### Details of the dispatcher.utter_message() method:

`CollectingDispatcher.utter_message(text=None, image=None, json_message=None, template=None, attachment=None, buttons=None, elements=None, **kwargs)`

“Send a text to the output channel.

**Return type**

`None`

### Customizing the session start action

The default behavior of the session start action is to take all existing slots and to carry them over into the next session. Let’s say you do not want to carry over all slots, but only a user’s name and their phone number. To do that, you’d override the `action_session_start` with a custom action that might look like this:

```python
from typing import Text, List, Dict, Any

from rasa_sdk import Action, Tracker
from rasa_sdk.events import SlotSet, SessionStarted, ActionExecuted, EventType
from rasa_sdk.executor import CollectingDispatcher

class ActionSessionStart(Action):
    def name(self) -> Text:
        return "action_session_start"

@staticmethod
    def fetch_slots(tracker: Tracker) -> List[EventType]:
        slots = []

for key in ("name", "phone_number"):
            value = tracker.get_slot(key)
            if value is not None:
                slots.append(SlotSet(key=key, value=value))

return slots

async def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[EventType]:

events = [SessionStarted()]  
        events.extend(self.fetch_slots(tracker))
        events.append(ActionExecuted("action_listen"))

return events
```

Note

You need to explicitly add `action_session_start` to your domain to override this custom action.

### Events

An action’s `run()` method returns a list of events. For more information on the different types of events, see [Events](https://legacy-docs-v1.rasa.com/1.10.13/api/events/#events). There is an example of a `SlotSet` event above. The action itself will automatically be added to the tracker as an `ActionExecuted` event. If the action should not trigger any other events, it should return an empty list.

### Tracker

The `rasa_sdk.Tracker` lets you access the bot’s memory in your custom actions. You can get information about past events and the current state of the conversation through `Tracker` attributes and methods.

**Available attributes of a Tracker object:**

- `sender_id` - The unique ID of person talking to the bot.
- `slots` - The list of slots that can be filled as defined in the domains.
- `latest_message` - A dictionary containing the attributes of the latest message: `intent`, `entities` and `text`.
- `events` - A list of all previous events.
- `active_form` - The name of the currently active form.
- `latest_action_name` - The name of the last action the bot executed.

**Available methods from the Tracker:**

- `Tracker.current_state()` - Return the current tracker state as an object.  
- `Tracker.is_paused()` - State whether the tracker is currently paused.  
- `Tracker.get_latest_entity_values(entity_type, entity_role=None, entity_group=None)` - Get entity values found for the passed entity type and optional role and group in the latest message.

- `Tracker.get_latest_input_channel()` - Get the name of the input_channel of the latest UserUttered event.
- `Tracker.events_after_latest_restart()` - Return a list of events after the most recent restart.
- `Tracker.get_slot(key)` - Retrieves the value of a slot.
