- Responses User-facing messages defined in your assistant. This is what you will use most frequently to send text, images, buttons, etc.
- Default Actions
Built-in actions that handle certain events or conversation situations out-of-the-box (e.g.,
action_restart,action_session_start). These can be overridden with your own custom logic if needed. - Custom Actions User-defined actions that can run any code you want (e.g., call external APIs, query databases, or retrieve specific data). Custom actions are the focus of this page.
What Are Custom Actions?
A custom action lets you execute arbitrary logic within your assistant—for example, retrieving data from an external API or performing a complex database query. Because you can run any code, custom actions offer maximum flexibility. Example of “flow-first” design:flows.yml
actions.py
Rasa Action Server
When your assistant predicts a custom action, it needs to run your custom code. You can do this in two ways:- Use a standalone Action Server
- The Rasa server calls the Action Server with information about the conversation.
- The Action Server executes your code and returns any responses or events to Rasa.
- This keeps your custom code isolated from the main assistant server (helpful for security or scaling).
- Run custom actions directly on the Rasa Assistant
- Write your custom actions in Python and configure them to run directly in the same process as the assistant.
- This may simplify deployment and reduce latency but requires that your Rasa environment be set up securely to handle sensitive credentials.
How to Write Custom Actions
- Create Your Action File
- If using Python, you typically write an
Actionclass. - If using another language, you need to implement the webhook API spec.
- If using Python, you typically write an
- Implement the Logic
- Perform the external API calls, database queries, or any other needed logic.
- Store retrieved data in slots (e.g.,
SlotSet("customer_id", customer_id)) so that your flow can condition on it.
- Return Events and Responses
- Return the events (e.g.
SlotSet,FollowupAction) needed to update the conversation state. - Optionally, return responses to immediately send messages back to the user.
- Return the events (e.g.
- Add Your Action to the Assistant Configuration
- List the custom action’s name in your assistant domain or configuration so that your flows can call it.
- Decide on Hosting
- Standalone Action Server: Configure your
endpoints.ymlto point to the Action Server’s URL. - Integrated Execution: In your
endpoints.yml, setactions_moduleto point to your Python module.
- Standalone Action Server: Configure your
- Train & Test
- Once your custom actions are properly listed in your flows and domain, re-train (compile) your assistant and test by running a conversation.
Next Steps
- For a deeper look at the parameters and payloads involved, see the Reference section on Custom Actions.