Building custom actions using Rasa SDK
Custom actions provide a mechanism to run specific actions in remote servers. This is crucial for building a chatbot, as it is the gateway for implementing detailed business logic.
Installing the Rasa SDK package
Rasa integrates rasa-sdk
in its package. So, when you install Rasa, it will also automatically install rasa-sdk
. If we want to use rasa-sdk
alone (for example, in a production environment), we can run the following command:
pip install rasa-sdk
Writing custom actions
Custom actions must inherit the Action
class from the SDK, so that the server can automatically discover and register the custom actions. Here is an example:
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, ...