Building contextual assistants with Rasa Forms


(Juste) #1

Building contextual assistants with Rasa Forms

Check out our new tutorial on Rasa Forms! Learn how to use them to handle all the happy paths with just one training story! Have you tried Rasa Forms already? Share you experience with us in a thread below! :slight_smile: :rocket:


(JG) #2

I had created a video tutorial based on the @Juste Article which shows how to set up the bot and make it running:

Thanks :slight_smile:


(Srikar) #3

Hi @Juste,

In the below code snippet

* request_restaurant
    - restaurant_form
    - form{"name": "restaurant_form"}
    - form{"name": null}
    - utter_slots_values

Could you please explain the use of form{"name": "restaurant_form"} and also form{"name": null}

Thanks


(akshay) #4

Hi JiteshGaikwad can i integrate rasa with whatsapp? if yes then please provide solution


(JG) #5

I haven’t integrated the rasa bot with Whatsapp yet, but what i know you can do so using twillio.

for example you can relate with this : https://www.twilio.com/blog/build-whatsapp-chatbot-twilio-dialogflow-php


(akshay) #6

Thanks for your reply I will go through the steps.


(krati) #7

Hi @JiteshGaikwad and @Juste @juste_petr

I am getting this error when i train for rasa_core:

Can not access action ‘restaurant_form’, as that name is not a registered action for this domain

do i need to add “restaurant_form” under -actions as well?


(Juste) #8

Hello @rasa5. I couldn’t reproduce the error. Any chance you made some changes to the domain? Also, are you getting the following error when running make train-core ?


(krati) #9

Hi @Juste @juste_petr
“make” command doesn’t run on my cmd, so i ran 2 commands:

1.for train-nlu (which worked perfectly and the NLU model was trained) python -m rasa_nlu.train -c nlu_tensorflow.yml --fixed_model_name current --data data/nlu_data.md -o models --project nlu --verbose

2.train-core(which displayed this error): python -m rasa_core.train -s data/stories.md -d domain.yml -o models/dialogue --debug

Also, i am using rasa-core 0.10.4 rasa-core-sdk 0.12.1 rasa-nlu 0.14.3


(Juste) #10

Ok, so you are using an old version of Rasa Core. This new Form Action is a new addition to the stack so I would suggest you upgrading your Rasa Core to at least 0.12.0


(krati) #12

Hi @Juste

I installed the latest version and implemented form action in my own code . I have one required slot and the bot asks for it, but after receiving the response my bot doesn’t execute submit(). Instead it tries to find a suitable intent for the response.


(Juste) #13

Hi @rasa5. Can you share how your submit function looks like? Also, if your submit function triggers and utterance, are you sure you have it included in your domain?


(manoj ns) #14
docker run -p 8000:8000 rasa/duckling

How do I get this up in windows ?

Manoj


(manoj ns) #15

I have this running from command line. Wish to integrate this to a web chat. can you please guide how to post user messages and respond back using the same bot server ?


(somlaychong) #16

Could you please explain the use of form{"name": "restaurant_form"} and also form{"name": null}mantigames.

Thanks


(Juste) #17

@somlaychong @srikarplus Apologies for a late reply :slight_smile:

form{"name":"restaurant_form" means that the form has been activated and that now it’s time for the FormPolicy to jump in. Once the form is activated, the code of the ActionForm will be used to check which required slots are populated and, which ones to ask for next. form{"name":"null"} means the deactivation of the form and allows other policies in the configuration to take over the prediction of what happens in the dialogue next. The form can be deactivated in a happy path (when all slots are populated) or druing the deviations from it (chitchat, etc).


(krati) #19

Hi @Juste @juste_petr

You have created a separate intent as chitchat and in stories, you have defined different paths- happy, unhappy, stop and continue path etc.

However, in the paths that involve chitchat intent, I wish to give users the flexibility that they can talk about any other intent but I have about 10 different intents!

So, how do i produce stories that replace chitchat intent with the other 10 intents?


(Tobias ) #20

Hi @Juste

When I train the model using the keras policy I get a bunch of the following warnings:

“Feature ‘active_form_restaurant_form’ could not be found in feature map.”

Why is that and is it hurting performance?


(Serge B) #21

Hi @Juste. Thank you for your post. We went through your post as well

We have a FormAction that has a postal code as an only slot in the domain file: forms:

- store_search_form

we have the slots under corresponding utterances for our single slot also in the domain file (the 2nd stores slot is where our submit action puts the response back for UI stories): slots:

  postal_code:
    type: unfeaturized

  stores:
    type: unfeaturized

And we have the convention-based utterance that FormAction needs to prompt the user for the only value it needs as per the required_slots method:

templates:
  utter_ask_postal_code:
  - text: "Please enter the Postal Code you wish to use to search for a Bell Store"

  utter_postal_code_slot_value:
  - text: "I am going to run a Google API search for The Source near:{postal_code}"

The second utterance we use to echo back to make sure form slot was populated correctly.

Our form action in actions.py that dictate the required slots.

class FormActionSearchStores(FormAction):

    def name(self):
        return 'store_search_form'

    @staticmethod
    def required_slots(tracker):
       # type: () -> List[Text]
       return ["postal_code"]

And our story:

* locate_store
  - store_search_form
  - form{"name": "store_search_form"}
  - utter_postal_code_slot_value
  - action_suggest
  - form{"name": null}
  - utter_goodbye
  - action_restart

Note: I tried this configuration with same effect:

* locate_store
  - store_search_form
  - form{"name": "store_search_form"}
  - form{"name": null}
  - utter_postal_code_slot_value
  - action_suggest
  - utter_goodbye
  - action_restart

action_suggest simply sets the “stores” slot with the results.

And here is the problem: while the slots gets filled and my action cod runs and my API logic executes (in the action server log), it seems my conversation is falling back to the default policy due to stating it does not recognize the intent. It seems the 2 policies are fighting or we are doing something wrong.

Hers is the debug rasa core log. I’ve added notes where I provide inputs and then what happens after i hit enter:

Enter to bot: store locator

Bot log in debug mode

Recreating tracker for id 'UF97SURFC'
Received user message 'store locator' with intent '{'name': 'locate_store', 'confidence': 0.778114378452301}' and entities '[]'
Logged UserUtterance - tracker now has 139 events
Current slot values:
        requested_slot: None
        name: None
        stores: None
        b1_number: None
        postal_code: None
Current tracker state [None, None, None, {}, {'prev_action_listen': 1.0, 'intent_locate_store': 1.0}]
There is a memorised next action '69'
There is no active form
Predicted next action using policy_2_MemoizationPolicy
Predicted next action 'store_search_form' with prob 1.00.
Calling action endpoint to run action 'store_search_form'.
Action 'store_search_form' ended with events '['Form(store_search_form)', 'SlotSet(key: requested_slot, value: postal_code)']'
Bot utterance 'BotUttered(text: Please enter the Postal Code you wish to use to search for a Bell Store, data: {
  "attachment": null,
  "elements": null,
  "buttons": null
})'
Current tracker state [None, None, None, {}, {'prev_action_listen': 1.0, 'intent_locate_store': 1.0}]
There is a memorised next action '69'
There is an active form 'store_search_form'
Predicted next action using policy_3_FormPolicy
Predicted next action 'action_listen' with prob 1.00.
Action 'action_listen' ended with events '[]'

Enter to bot: M2N1A1

Bog log in debug mode

Recreating tracker for id 'UF97SURFC'
Received user message 'M2N1A1' with intent '{'name': None, 'confidence': 0.0}' and entities '[{'entity': 'postal_code', 'extractor': 'ner_crf', 'end': 6, 'start': 0, 'value': 'M2N1A1', 'confidence': 0.968162055366042}]'
Logged UserUtterance - tracker now has 146 events
Current slot values:
        requested_slot: postal_code
        name: None
        stores: None
        b1_number: None
        postal_code: M2N1A1
NLU confidence 0.0 is lower than NLU threshold 0.3. Predicting fallback action: action_default_fallback
Current tracker state [None, None, None, {}, {'prev_action_listen': 1.0, 'intent_locate_store': 1.0}]
There is a memorised next action '69'
There is an active form 'store_search_form'
Predicted next action using policy_3_FormPolicy
Predicted next action 'store_search_form' with prob 1.00.
Calling action endpoint to run action 'store_search_form'.
Action 'store_search_form' ended with events '['SlotSet(key: postal_code, value: M2N1A1)', 'SlotSet(key: stores, value: work time:   Monday: 10:00 AM – 6:00 PM', 'Form(None)', 'SlotSet(key: requested_slot, value: None)']'
Bot utterance 'BotUttered(text: Form Action Submit complete, postal code is M2N1A1., data: {
  "attachment": null,
  "elements": null,
  "buttons": null
})'
NLU confidence 0.0 is lower than NLU threshold 0.3. Predicting fallback action: action_default_fallback
Current tracker state [None, None, {}, {'prev_action_listen': 1.0, 'intent_locate_store': 1.0}, {'prev_store_search_form': 1.0, 'intent_locate_store': 1.0}]
There is a memorised next action '68'
There is no active form
Predicted next action using policy_1_FallbackPolicy
Predicted next action 'action_default_fallback' with prob 1.00.
Action 'action_default_fallback' ended with events '['UserUtteranceReverted()']'
Bot utterance 'BotUttered(text: I am sorry, I didn't understand that. Please try again., data: {
  "attachment": null,
  "elements": null,
  "buttons": null
})'
Current tracker state [None, None, None, {}, {'prev_action_listen': 1.0, 'intent_locate_store': 1.0}]
There is a memorised next action '69'
There is an active form 'store_search_form'
Predicted next action using policy_3_FormPolicy
Predicted next action 'action_listen' with prob 1.00.
Action 'action_listen' ended with events '[]'

Note this part in the above:

Logged UserUtterance - tracker now has 146 events Current slot values: requested_slot: postal_code name: None stores: None b1_number: None postal_code: M2N1A1 NLU confidence 0.0 is lower than NLU threshold 0.3. Predicting fallback action: action_default_fallback

So while the form action executed I think successfully - in the UI - instead of the output from the Action (store hours above).   It falls back to the default utterance of "I do not understand"


  utter_default:
  - text: "I am sorry, I didn't understand that. Please try again."

Can you help? How can we train/signal the bot that if the FormAction processed ok, that all is good? Are we missing something?

Or is this have nothing to do with Forms, but rather we have to keep working on the NLU training set? (keep in mind we have a good set of postal code - in phrases, out of phrases, lower/upper cases) - maybe 50 of each? Remember my post about the NLU training API crashing :slight_smile:

Your help is much appreciated

Thanks Serge


(shubham Mainali) #22

I’m using the Form Action to fill the Slots. I’ve about 7 slots such as:

“NAME”, “CAB_TYPE”, “P_COUNT”, “SOURCE”, “DESTINATION”, “RIDEPREFERENCE”, “DURATION”

but as soon as I fill the DESTINATION Slot the Form starts again. I’ve my all the entities & slots listed in Domain file.

entities:

  • NAME
  • CAB_TYPE
  • P_COUNT
  • SOURCE
  • DESTINATION
  • RIDEPREFERENCE
  • DURATION

slots: NAME: type: unfeaturized auto_fill: false CAB_TYPE: type: unfeaturized auto_fill: false P_COUNT: type: unfeaturized auto_fill: false SOURCE: type: unfeaturized auto_fill: false RIDEPREFERENCE: type: unfeaturized auto_fill: false DURATION: type: unfeaturized auto_fill: false DESTINATION: type: unfeaturized auto_fill: false requested_slot: type: unfeaturized

Stories:

  • greeting
    • utter_greeting
  • request_booking
    • booking_form
    • form{“name”: “booking_form”}
    • utter_slots_values
  • mood_affirm
    • utter_booking_details
    • utter_bye Need help on this.