Hi, I had been figuring out the Mapping Policy for a while, at first with rasa 0.14.4 but now I have updated to rasa 1.0 hoping it will work there.
Right now, I get an error:
...Anaconda3\envs\lewis\lib\site-packages\rasa_sdk\interfaces.py", line 175, in name
raise NotImplementedError("An action must implement a name")
NotImplementedError: An action must implement a name
The steps I followed for the Mapping Policy were:
Add MappingPolicy() to the training:
async def train_core():
"""Trains the core"""
agent = Agent(
DOMAIN,
policies=[
MemoizationPolicy(max_history=10),
MappingPolicy()],
)
training_data = await agent.load_data(STORIES)
agent.train(training_data)
# Attention: agent.persist stores the model and all meta data into a folder.
# The folder itself is not zipped.
agent.persist(os.path.join(MODEL_PATH, MODEL_NAME, "core"))
Add a trigger to the intent in the domain.yml
intents:
- faq_enrollment:
triggers: action_faq_enrollment
actions:
- utter_faq_enrollment
- action_faq_enrollment
Create a new file called actions.py and put this in there:
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()]
And then I ran python -m rasa_sdk --actions actions
, as stated in the docs. That’s when I got the error.
And when I just train and test the bot, it stops whenever the FAQ is asked.
Can anybody help me setting up the Mappig Policy? Or does anybody have another idea for handling FAQ’s randomly throughout the conversation without disturbing the story?