Rasa 1.0.6 fallback action failing [SOLVED]

Hey all,

I’m working on a sample conversational chatbot with Rasa 1.0.6 (i.e., training and everything is done on the command line, with only a single custom action as a custom .py script). Everything is working as intended, except for the fallback action. It’s defined in the config file, which is as follows:

config.yml


language: "en"

pipeline:

  • name: “SpacyNLP” # loads the spacy language model
  • name: “SpacyTokenizer” # splits the sentence into tokens
  • name: “CRFEntityExtractor” # uses the pretrained spacy NER model
  • name: “SpacyFeaturizer” # transform the sentence into a vector representation
  • name: “SklearnIntentClassifier” # uses the vector representation to classify using SVM
  • name: “EntitySynonymMapper” # trains the synonyms

policies:

  • name: “KerasPolicy” featurizer:
    • name: MaxHistoryTrackerFeaturizer max_history: 5 state_featurizer:
      • name: BinarySingleStateFeaturizer
  • name: “MemoizationPolicy” max_history: 5
  • name: “FallbackPolicy” nlu_threshold: 0.4 core_threshold: 0.3 fallback_action_name: “my_fallback_action”

And the domain:

intents:

  • greet
  • goodbye
  • mood_affirm
  • mood_deny
  • mood_great
  • mood_unhappy
  • inform

slots: group: type: text

entities:

  • group

actions:

  • utter_greet
  • utter_did_that_help
  • utter_happy
  • utter_goodbye
  • my_fallback_action
  • utter_ask_picture
  • action_retrieve_image
  • default

templates: utter_greet:

  • text: “Hey! How are you?”

utter_did_that_help:

  • text: “Did that help you?”

my_fallback_action:

  • text: “I am not sure what you are aiming for.”

utter_happy:

  • text: “Great carry on!”

utter_goodbye:

  • text: “Bye”

utter_ask_picture:

  • text: “To cheer you up, I can show you a cute picture of a dog, cat or a bird. Which one do you choose?”

default:

  • text: “Default test”

and sample stories:

strange user

  • mood_affirm
    • utter_happy
  • mood_affirm
    • default
    • my_fallback_action

say goodbye

  • goodbye
    • utter_goodbye

fallback

  • default
  • my_fallback_action

The error i’m getting is:

rasa.core.processor - Encountered an exception while running action ‘my_fallback_action’. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.

The ‘default’ action is also not being executed, so I suspect it’s got something to do with the policy itself.

I couldn’t find anything related on the forum, and I believe i’ve followed the instructions in the 1.0.6 documentation properly.

…and apologies if the body of this post isn’t formatted properly :confused:

Thank you!

I think you have to create a custom code for taring the core. You can try this below code.

def train_dialog(dialog_training_data_file, domain_file, path_to_model = 'models/dialogue'):
    logging.basicConfig(level='INFO')
    fallback = FallbackPolicy(fallback_action_name="action_default_fallback",core_threshold=0.25,nlu_threshold=0.25)
    agent = Agent(domain_file,policies = [MemoizationPolicy(), KerasPolicy(),fallback])
    training_data = agent.load_data(dialog_training_data_file)
    agent.train(training_data)
    agent.persist(path_to_model)    


train_dialog('data/stories.md', 'domain.yml')

I’m trying to run with the full 1.0.6 capabilities, meaning that I train the models via the commandline, without custom training code. I think it should be possible, but perhaps I’m getting something wrong with the policies key in the config.yml file

Using rasa interactive -m models/model.tar.gz --debug i found that the model expects an endpoint for the fallback action, considering it a custom action. I’ll update this reply when I find out more.

EDIT/SOLUTION: The problem was that my fallback action was a simple utterance, but I did not name the action with an ‘utter_’ prefix, and Rasa was hence expecting a custom action.

Thank you for the input, good luck and have fun all!