Closed rkkumar16 closed 5 years ago
The logger links you to the documentation: http://rasa.com/docs/core/customactions/
The endpoint should be called action_endpoint
@akelad I changed the name as well but how I should include it in project? I have just created the file but how does I create endpoint and use for each custom action is my point here
I'm not sure I understand the question, the name of the action doesn't need to change, just what you put in your endpoint.yml. The link above describes exactly how to get the custom action server running
In earlier versions of rasa_core to run custom actions we just had to create classes like this
class ActionGetDate(Action):
def name(self):
return "ask_from_date"
def run(self, dispatcher, tracker, domain):
print("Events: \n"+tracker.events)
print("Past states: \n"+tracker.past_states())
print("Applied events"+tracker.applied_events())
#dispatcher.utter_message("Values have been saved")
return []
and then needed to add actions to domain file like this
actions.ActionGetDate
It was so simple there. Now, I'm trying to do the same here. By reading documents I found out that I need to run these on server. I don't understand how can we create and run a custom action and what file needs to be created for that.
Nothing has changed about how you write your actions, they're still kept in the same file as before. But rather than writing actions.ActionGetDate
in your domain file, you now write ask_from_date
. And to starting the action server is simple since your actions are written in python, take a look at that section in the link I sent you.
All you need to do is run this python -m rasa_core_sdk.endpoint --actions actions
to start the server
@akelad earlier we did not need to run server for this. I just want to override the function so that I can apply some validations on it. Why do I need to create an endpoint for this. By this way I would need endpoints for every validation I need to do. Is there no any other way for this?
You don't need to define an endpoint for every action, it's just the one endpoint, called "action_endpoint", which you start with python -m rasa_core_sdk.endpoint --actions actions
(if your python file is called actions.py
, if it's called myactions.py
then the command is python -m rasa_core_sdk.endpoint --actions myactions
)
@akelad Thanks for the support I got it working with this