Actions
These docs are for version 1.x of Rasa Open Source.
User Guide
- Installation
- Rasa Tutorial
- Command Line Interface
- Architecture
- Messaging and Voice Channels
- Evaluating Models
- Validate Data
- Running the Server
- Running Rasa with Docker
- Cloud Storage
NLU
- About
- Using NLU Only
- Training Data Format
- Choosing a Pipeline
- Language Support
- Entity Extraction
- Components
Core
- About
- Stories
- Domains
- Responses
- Actions
- Policies
- Slots
- Forms
- Retrieval Actions
- Interactive Learning
- Fallback Actions
- Knowledge Base Actions
Conversation Design
API Reference
- Action Server
- HTTP API
- Jupyter Notebooks
- Agent
- Custom NLU Components
- Events
- Tracker
- Tracker Stores
- Event Brokers
- Lock Stores
- Training Data Importers
- Featurization
- Migration Guide
- Rasa Change Log
Migrate from (beta)
Reference
Versions
viewing: 1.3.10
Actions
Actions are the things your bot runs in response to user input. There are four kinds of actions in Rasa:
- Utterance actions: start with
utter_and send a specific message to the user. - Retrieval actions: start with
respond_and send a message selected by a retrieval model. - Custom actions: run arbitrary code and send any number of messages (or none).
- Default actions: e.g.
action_listen,action_restart,action_default_fallback.
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!"
Retrieval Actions
Retrieval actions make it easier to work with a large number of similar intents like chitchat and FAQs.
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.
# Example for custom action
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 [])]
Default Actions
There are eight default actions:
| Action Name | Description |
|---|---|
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 |
action_default_fallback |
Undo the last user message and utter a message that the bot did not understand. |
action_deactivate_form |
Deactivate the active form and reset the requested slot. |
action_revert_fallback_events |
Revert events that occurred during TwoStageFallbackPolicy. |
action_default_ask_affirmation |
Ask the user to affirm their intent. |
action_default_ask_rephrase |
Ask the user to rephrase their intent. |
action_back |
Undo the last user message. |