# 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.10.18/core/actions/#utterance-actions)

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

```
responses:
  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 response in your custom
actions, but the response can not be directly predicted as its own action.
See [Responses](https://legacy-docs-v1.rasa.com/1.10.18/core/responses/#responses) for more details.

If you use an external NLG service, you don’t need to specify the
responses in the domain, but you still need to add the utterance names
to the actions list of the domain.

## [Retrieval Actions](https://legacy-docs-v1.rasa.com/1.10.18/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.10.18/core/retrieval-actions/#retrieval-actions) to learn more.

## [Custom Actions](https://legacy-docs-v1.rasa.com/1.10.18/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.

Note

Rasa uses a ticket lock mechanism to ensure incoming messages from the same
conversation ID do not interfere with each other and are processed in the right
order. If you expect your custom action to take more than 60 seconds to run, please
set the `TICKET_LOCK_LIFETIME` environment variable to your expected value.

### [Custom Actions Written in Python](https://legacy-docs-v1.rasa.com/1.10.18/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.10.18/api/rasa-sdk/#rasa-sdk) which starts
this action server for you.

## [Execute Actions in Other Code](https://legacy-docs-v1.rasa.com/1.10.18/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.10.18/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.10.18/api/events/#events).

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

The available default actions are:

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