Action server for the Rasa custom actions
You can use this implementation of the action server as a starting point for your own chatbot based on Rasa.
Using the action server, you can focus on the business logic (defined within custom actions). Everything else is already done for you.
Rasa Core sends a request to the action server to execute a certain custom action. As a response to the action call from Core, you can modify the tracker, e.g. by setting slots and send responses back to the user.
Action server exposes an API that is used by Rasa to execute custom actions. The following endpoints are supported:
Endpoint | Description |
---|---|
GET /health | Ping endpoint to check if the server is running and well. |
GET /actions | List all registered actions. |
POST /webhook | It allows you to run the custom action. This endpoint should be set in the endpoints.yml file in Rasa. |
Before starting the action server ensure that contains your custom action.
You can create two types of custom actions:
- general - which corresponds to Rasa Custom Action. To use this kind of actions, you can create a Java class which implement the
io.github.rbajek.rasa.sdk.action.Action
interface. - forms - which corresponds to Rasa Forms. Ths kind of actions should extends the
io.github.rbajek.rasa.sdk.action.form.AbstractFormAction
To add your custom action, you can create a Java class which implement/extend an appropriate interface/class. Recommended package for your custom actions is io.github.rbajek.rasa.action.server.action.custom
. Afterwards, you have to register your custom action in io.github.rbajek.rasa.sdk.ActionExecutor
.
Tip: If you want your custom action to be automatically registered, your action has to be as Spring component.
Attention: action server contains two examples of custom actions:
- ActionJoke.java - as the general action (based on original example)
- RestaurantFormAction.java - as the form action, which implement functionality of Restaurant Form
In order to start the action server using implemented custom actions, fisrt of all, you have to build the application:
mvnw clean package
next, you ca run server as follows:
java -jar target\rasa-java-action-server.jar
If you are using docker you can build the docker image:
docker build -t rasa-action-server:1.0.0
and tun it:
docker run -p 5055:8080 --name rasa-action-server rasa-action-server:1.0.0
Rasa core has to know what is the URL of your custom server. To set this, you have to set the /webhook
endpoint in the endpoints.yml
within the Rasa server (see custom action):
For example:
action_endpoint:
url: "http://localhost:5055/webhook"