# Actions

Actions are the things your bot runs in response to user input. There are four kinds of actions in Rasa:

> 1. **Utterance actions**: start with `utter_` and send a specific message to the user  
> 2. **Retrieval actions**: start with `respond_` and send a message selected by a retrieval model  
> 3. **Custom actions**: run arbitrary code and send any number of messages (or none).  
> 4. **Default actions**: e.g. `action_listen`, `action_restart`, `action_default_fallback`

## [Utterance Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#utterance-actions)

To define an utterance action (`ActionUtterTemplate`), add an utterance template to the domain file that starts with `utter_`:

```
templates:
  utter_my_message:
    - "this is what I want my action to say!"
```

It is conventional to start the name of an utterance action with `utter_`. If this prefix is missing, you can still use the template in your custom actions, but the template can not be directly predicted as its own action. See [Responses](https://legacy-docs-v1.rasa.com/1.6.2/core/responses/#responses) for more details.

## [Retrieval Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#retrieval-actions)

Retrieval actions make it easier to work with a large number of similar intents like chitchat and FAQs. See [Retrieval Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/retrieval-actions/#retrieval-actions) to learn moree.

## [Custom Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#custom-actions)

An action can run any code you want. Custom actions can turn on the lights, add an event to a calendar, check a user’s bank balance, or anything else you can imagine.

Rasa will call an endpoint you can specify, when a custom action is predicted. This endpoint should be a webserver that reacts to this call, runs the code and optionally returns information to modify the dialogue state.

To specify your action server use the `endpoints.yml`:

```
action_endpoint:
  url: "http://localhost:5055/webhook"
```

And pass it to the scripts using `--endpoints endpoints.yml`.

You can create an action server in node.js, .NET, java, or any other language and define your actions there - but we provide a small python SDK to make development there even easier.

### [Custom Actions Written in Python](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#custom-actions-written-in-python)

For actions written in python, we have a convenient [Rasa SDK](https://legacy-docs-v1.rasa.com/1.6.2/api/rasa-sdk/#rasa-sdk) which starts this action server for you.

## [Execute Actions in Other Code](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#execute-actions-in-other-code)

Rasa will send an HTTP `POST` request to your server containing information on which action to run. Furthermore, this request will contain all information about the conversation. [Action Server](https://legacy-docs-v1.rasa.com/1.6.2/api/action-server/#action-server) shows the detailed API spec.

As a response to the action call from Rasa, you can modify the tracker, e.g. by setting slots and send responses back to the user. All of the modifications are done using events. There is a list of all possible event types in [Events](https://legacy-docs-v1.rasa.com/1.6.2/api/events/#events).

## [Proactively Reaching Out to the User Using Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#proactively-reaching-out-to-the-user-using-actions)

You may want to proactively reach out to the user, for example to display the output of a long running background operation or notify the user of an external event.

To do so, you can `POST` to this [endpoint](https://legacy-docs-v1.rasa.com/1.6.2/api/http-api/#operation/executeConversationAction) , specifying the action which should be run for a specific user in the request body. Use the `output_channel` query parameter to specify which output channel should be used to communicate the assistant’s responses back to the user. If your message is static, you can define an `utter_` action in your domain file with a corresponding template. If you need more control, add a custom action in your domain and implement the required steps in your action server. Any messages which are dispatched in the custom action will be forwarded to the specified output channel.

Proactively reaching out to the user is dependent on the abilities of a channel and hence not supported by every channel. If your channel does not support it, consider using the [CallbackInput](https://legacy-docs-v1.rasa.com/1.6.2/user-guide/connectors/your-own-website/#callbackinput) channel to send messages to a webhook.

## [Default Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/actions/#default-actions)

The available default actions are:

|     |     |
| --- | --- |
| `action_listen` | Stop predicting more actions and wait for user input. |
| `action_restart` | Reset the whole conversation. Can be triggered during a conversation by entering `/restart` if the [Mapping Policy](https://legacy-docs-v1.rasa.com/1.6.2/core/policies/#mapping-policy) is included in the policy configuration. |
| `action_session_start` | Start a new conversation session. Take all set slots, mark the beginning of a new conversation session and re-apply the existing `SlotSet` events. This action is triggered automatically after an inactivity period defined by the `session_expiration_time` parameter in the domain’s [Session configuration](https://legacy-docs-v1.rasa.com/1.6.2/core/domains/#session-config). Can be triggered manually during a conversation by entering `/session_start`. All conversations begin with an `action_session_start`. |
| `action_default_fallback` | Undo the last user message (as if the user did not send it and the bot did not react) and utter a message that the bot did not understand. See [Fallback Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/fallback-actions/#fallback-actions). |
| `action_deactivate_form` | Deactivate the active form and reset the requested slot. See also [Handling unhappy paths](https://legacy-docs-v1.rasa.com/1.6.2/core/forms/#section-unhappy). |
| `action_revert_fallback_events` | Revert events that occurred during the TwoStageFallbackPolicy. See [Fallback Actions](https://legacy-docs-v1.rasa.com/1.6.2/core/fallback-actions/#fallback-actions). |
| `action_default_ask_affirmation` | Ask the user to affirm their intent. It is suggested to overwrite this default action with a custom action to have more meaningful prompts. |
| `action_default_ask_rephrase` | Ask the user to rephrase their intent. |
| `action_back` | Undo the last user message (as if the user did not send it and the bot did not react). Can be triggered during a conversation by entering `/back` if the MappingPolicy is included in the policy configuration. |

All the default actions can be overridden. To do so, add the action name to the list of actions in your domain:

```
audios:
- action_default_ask_affirmation
```

Rasa will then call your action endpoint and treat it as every other custom action.
