Formbot Tutorial - New Cuisines Added to actions.py Not Entered in Database

I’m running the formbot tutorial https://blog.rasa.com/building-contextual-assistants-with-rasa-formaction and am getting the proper output for the code provided in the tutorial. I’m running with debug turned on.

However, when I make a simple update - adding 6 new cuisine names to actions.py - I get an error “rasa_sdk.endpoint - Failed to extract slot cuisine with action restaurant_form” or “sorry, I didn’t understand you, please try input something else” The first 2 names I added work fine but the last 4 generate errors.

I was careful to ensure that the proper spacing was used on the lines I added. Any ideas why these errors would result?

New Code I added in actions.py def cuisine_db() -> List[Text]: “”“Database of supported cuisines”""

    return [
        "caribbean",
        "chinese",
        "french",
        "greek",
        "indian",
        "italian",
        "mexican",
        "american",
        "thai",
        "bbq",
        "fast food",
        "pizza",
        "burgers",
    ]

Debug output: NOTE: the output below shows the error I get when I enter bbq. The second input below when thai is entered for cuisine shows that I was able to successfully add thai to the list of cuisines.

What type of food would you like?
Your input ->  bbq                                                                                                                                                               
2019-10-30 15:45:53 DEBUG    rasa.core.tracker_store  - Recreating tracker for id 'default'
2019-10-30 15:45:53 WARNING  root  - Could not parse timestamp 0263b4c84e164caca9b49947313111e8. Instead current UTC time will be passed to duckling. Error: invalid literal for int() with base 10: '0263b4c84e164caca9b49947313111e8'
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Received user message 'bbq' with intent '{'name': 'request_restaurant', 'confidence': 0.7831459045410156}' and entities '[]'
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 12 events
2019-10-30 15:45:53 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_greet': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0}]
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - There is a memorised next action '14'
2019-10-30 15:45:53 DEBUG    rasa.core.policies.form_policy  - There is an active form 'restaurant_form'
2019-10-30 15:45:53 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Predicted next action 'restaurant_form' with confidence 1.00.
2019-10-30 15:45:53 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'restaurant_form'.
2019-10-30 15:45:53 ERROR    rasa.core.actions.action  - Failed to extract slot cuisine with action restaurant_form
2019-10-30 15:45:53 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - Current tracker state [{'intent_greet': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0}, {'intent_request_restaurant': 1.0, 'prev_restaurant_form': 1.0, 'active_form_restaurant_form': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0, 'active_form_restaurant_form': 1.0}]
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2019-10-30 15:45:53 DEBUG    rasa.core.policies.form_policy  - There is an active form 'restaurant_form'
2019-10-30 15:45:53 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_0_FallbackPolicy
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Predicted next action 'action_default_fallback' with confidence 0.30.
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Action 'action_default_fallback' ended with events '['BotUttered(text: sorry, I didn\'t understand you, please try input something else, data: {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, metadata: {})', 'UserUtteranceReverted()']'
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Current slot values: 
	cuisine: None
	feedback: None
	num_people: None
	outdoor_seating: None
	preferences: None
	requested_slot: cuisine
2019-10-30 15:45:53 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_greet': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0}]
2019-10-30 15:45:53 DEBUG    rasa.core.policies.memoization  - There is a memorised next action '14'
2019-10-30 15:45:53 DEBUG    rasa.core.policies.form_policy  - There is an active form 'restaurant_form'
2019-10-30 15:45:53 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'request_restaurant'.
2019-10-30 15:45:53 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2019-10-30 15:45:53 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'
2019-10-30 15:45:53 DEBUG    rasa.core.lock_store  - Deleted lock for conversation 'default'.
sorry, I didn't understand you, please try input something else
Your input ->  thai                                                                                                                                                              
2019-10-30 15:48:42 DEBUG    rasa.core.tracker_store  - Recreating tracker for id 'default'
2019-10-30 15:48:42 WARNING  root  - Could not parse timestamp d371caa548f84da599d40a8bb5779019. Instead current UTC time will be passed to duckling. Error: invalid literal for int() with base 10: 'd371caa548f84da599d40a8bb5779019'
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Received user message 'thai' with intent '{'name': 'inform', 'confidence': 0.7832643985748291}' and entities '[{'start': 0, 'end': 4, 'value': 'thai', 'entity': 'cuisine', 'confidence': 0.5489843690954916, 'extractor': 'CRFEntityExtractor'}]'
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Current slot values: 
	cuisine: None
	feedback: None
	num_people: None
	outdoor_seating: None
	preferences: None
	requested_slot: cuisine
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 30 events
2019-10-30 15:48:42 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2019-10-30 15:48:42 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_greet': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0}]
2019-10-30 15:48:42 DEBUG    rasa.core.policies.memoization  - There is a memorised next action '14'
2019-10-30 15:48:42 DEBUG    rasa.core.policies.form_policy  - There is an active form 'restaurant_form'
2019-10-30 15:48:42 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Predicted next action 'restaurant_form' with confidence 1.00.
2019-10-30 15:48:42 DEBUG    rasa.core.actions.action  - Calling action endpoint to run action 'restaurant_form'.
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Action 'restaurant_form' ended with events '['BotUttered(text: How many people are in your group?, data: {"elements": null, "quick_replies": null, "buttons": null, "attachment": null, "image": null, "custom": null}, metadata: {"cuisine": "thai", "feedback": null, "num_people": null, "outdoor_seating": null, "preferences": null, "requested_slot": "cuisine"})', 'SlotSet(key: cuisine, value: thai)', 'SlotSet(key: requested_slot, value: num_people)']'
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Current slot values: 
	cuisine: thai
	feedback: None
	num_people: None
	outdoor_seating: None
	preferences: None
	requested_slot: num_people
2019-10-30 15:48:42 DEBUG    rasa.core.policies.fallback  - NLU confidence threshold met, confidence of fallback action set to core threshold (0.3).
2019-10-30 15:48:42 DEBUG    rasa.core.policies.memoization  - Current tracker state [None, {}, {'intent_greet': 1.0, 'prev_action_listen': 1.0}, {'prev_utter_greet': 1.0, 'intent_greet': 1.0}, {'prev_action_listen': 1.0, 'intent_request_restaurant': 1.0}]
2019-10-30 15:48:42 DEBUG    rasa.core.policies.memoization  - There is a memorised next action '14'
2019-10-30 15:48:42 DEBUG    rasa.core.policies.form_policy  - There is an active form 'restaurant_form'
2019-10-30 15:48:42 DEBUG    rasa.core.policies.mapping_policy  - There is no mapped action for the predicted intent, 'inform'.
2019-10-30 15:48:42 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_2_FormPolicy
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Predicted next action 'action_listen' with confidence 1.00.
2019-10-30 15:48:42 DEBUG    rasa.core.processor  - Action 'action_listen' ended with events '[]'
2019-10-30 15:48:42 DEBUG    rasa.core.lock_store  - Deleted lock for conversation 'default'.
How many people are in your group?

Hi @d7x Paul, what is going on is that the bot is not recognizing your answer ‘bbq’ as a possible message for the intent inform with an entity of cuisine. You must first teach the bot to understand that, and only then will it actually call the custom action to check if that type of cuisine is supported.

I recommend that you use Rasa X, because you will detect these type of issues much easier.

For example, when you answer ‘italian’, Rasa X will show you that the bot correctly understands this as inform{"cuisine":"italian"}

italian

This means that the bot correctly understand that your intent is inform, and the entity cuisine is italian.

Now, when you answer ‘bbq’, the bot does not understand that this is a sentence with intent inform and entity of type cuisine. It just shows nul0

bbq-wrong

In Rasa X , you can then also fix it easily by correcting the prediction for the sentence bbq. You just put your mouse next to it and select correct this:

bbq-correct-this

Which opens up the Interactive Learning area where you can define that this sentence belongs to the intent inform:

Then you go to the NLU Training data section, where you can annotate bbq as entity of type cuisine:

Then retrain the model, make sure to make the new trained model the active model and try again. It will now work OK.

Let me know if this is all clear.

If you prefer to work without Rasa X, then you must manually edit the file data/nlu.md, by adding this:

## intent:inform
- [bbq](cuisine)
2 Likes