How to configure stories and actions to get shared requested slots?

Hello everyone,

I am developing a chatbot using Rasa NLU and Rasa Core. My bot mainly queries a database for some results. I am kinda stuck in a situation regarding the filling of the slots in my domain.yml file. Here is my bot setup and what I want it to do:

Some intents require slots, and I use the values of these slots to query the database. An example would be: LookForShop intent, which requires a location entity (slot). I train this intent with examples like: “show me the nearest shop in Ontario”. If a user asks “show me some shops”, I want the bot to ask the user for the location, but if the user enters the location with the question from the first time, I want to just return the DB results directly. Basically something like:

## Story 1
    * LookForShop{"location": "London"}
        - action_LookForShop

## Story 2
    * LookForShop
        - utter_AskForLocation
    * LookForShop{"location": "London"}
        - action_LookForShop

And a chat flow like:

u: show me some shops
b: please specify a location.
u: LA
b: here are some shops in LA.


u: show me some shops in Montreal
b: here are some shops in Montreal.

But for this to work, my file should be something like:

## intent:LookForShop
    show me some shops
    show me some shops in [Barcelona](location)

In the case where there is one intent -other than chitchat and small talk intents-, this works fine, but the problem is that I have multiple intents that share the same entity (slot). An entity (location) is shared amongst intents like LookForShop and LookForCafe and I simply can’t use the previous story setup as I will have to train the Rasa NLU on examples like:

## intent:LookForShop
show me some shops in [Paris](location)


## intent:LookForCafe
show me some cafe in [Ontario](location)

I would like to hear your suggestions on what my stories and actions should be.

Hi @Juste, I watched your weather bot tutorial: From zero to hero: Creating a chatbot with Rasa NLU and Rasa Core – Justina Petraitytė . The bot needs a location to return the weather condition, but the user might not enter it from the first time, so you’ll have a stories files as (I changed from json to md format to make it easier to read):

## intent:Inform
 - Tell me the weather
 - Is the weather nice in [Barcelona](location) today?
 - [Lithuania](location) 

and a stories file with (also with a slight modification to focus on my point):

 ## Generated Story -3351152636827275381
* inform{"location": "London"}
    - slot{"location": "London"}
    - action_weather

## Generated Story 8921121480760034253
* inform
    - utter_ask_location
* inform{"location":"London"}
    - slot{"location": "London"}
    - action_weather

The problem is that I have multiple intents that have and require the same entity, and although I have tried formactions, I still can’t reach the first (basic) chat flow that is shown above, not mentioning implementing it with multiple intents and entities :confused:. I would truly appreciate any help on the manner.

Hey @Leo_Sal!

Regarding your first inquiry:

This looks like you could make good use of Forms.

You will have to build a form action. The form will be activated upon intent LookForShop and then validate the location slot and if it isn’t filled yet, it will run utter_ask_{missing_slot} (which in your case you have to rename utter_AskForLocation to utter_ask_location for it to work) before the from triggers to run action_LookForShop.

Your stories for this would be something like:

* LookForShop
    - shop_form
    - form{"name": "shop_form"}
    - form{"name": null}

The form handles both requesting slots, and when all required slots are filled, running the specified action.

You could have two forms, one for shops and one for cafes, but I think the better option in this case would be to make a slot for place that can be filled with cafe or shop and then is one of the required slots in the form. This very much depends on your use case and other intents and actions of the bot though.

1 Like

Regarding your second question:

The weather bot tutorial is using very old rasa versions, maybe try updating to newer versions. I see you tried forms, and this should work to reach a story-line as you described.

Can you post what the exact issue you are having with the forms? How do your stories look using forms?

1 Like

Hi @pwessel, thanks a lot for your reply. I actually have somewhat of a private context that I can’t share, so I have created an equivalent implementation (stories, nlu_data, domain and forms), and that is the one I am sharing. Right now I have modified the ‘equivalent’ model slightly. Here are all the files I am using:

In those files, I am trying to use forms, but It is simply not working. It just always goes directly to the fallback intent :slightly_frowning_face:.

To use forms, you have add the FormPolicy in your configuration file

  - name: "FormPolicy"

Maybe try to use Interactive Learning to write some more stories and see where your predictions go wrong.

Which rasa versions are you using? (find out running pip list | grep rasa in the command line)

Hey, the rasa version I’m using is here:

rasa 0.1.1
rasa-core 0.13.7
rasa-core-sdk 0.12.2
rasa-nlu 0.14.6

And I am using the form policy in my policies file. Unfortunately, I am still getting fallback actions :slightly_frowning_face: