OK, in case anyone is still struggling with the Mapping Policy of Rasa 1.0, this is what I did to make it work:
Put this in endpoints.yml
action_endpoint:
url: "http://localhost:5055/webhook"
Create an actions.py
in your working folder with your custom action. For me, this was:
from rasa_sdk import Action
from rasa_sdk.events import UserUtteranceReverted
class FaqEnrollment(Action):
"""Revertible mapped action for utter_faq_enrollment"""
def name(self):
return "action_faq_enrollment"
def run(self, dispatcher, tracker, domain):
dispatcher.utter_template("utter_faq_enrollment", tracker)
return [UserUtteranceReverted()]
Wherever you load your bot, put an argument action_endpoint
along with it. You should do import the endpoint config (from rasa.utils.endpoints import EndpointConfig
) and set action_endpoint = EndpointConfig(url="http://localhost:5055/webhook")
. I had to do this in my training file and my file to run the chat. Just in case:
ENDPOINT = EndpointConfig(url="http://localhost:5055/webhook")
async def train_core():
"""Trains the core"""
agent = Agent(
DOMAIN,
policies=[
MemoizationPolicy(max_history=10),
MappingPolicy()],
action_endpoint=ENDPOINT
)
Now put the trigger in your domain.yml
. Example:
intents:
- faq_enrollment:
triggers: action_faq_enrollment
And don’t include any of these in your stories.md
Now, to run it you need to open your command prompt.
Type: rasa run actions --actions actions
(assuming your file is called actions.py
, otherwise change the last “actions” in the command).
In another command prompt, train your bot and run the chat.
It should work now!