RasaHQ / rasa

💬 Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.96k stars 4.64k forks source link

how to make pre-filled (manually filled) slots to impact action prediction? #2094

Closed lisongshan closed 5 years ago

lisongshan commented 6 years ago
**Rasa Core version**:0.8.6 **Python version**: 3.6 **Operating system** (windows, osx, ...):osx **Issue**: how to make pre-filled slots to impact action prediction **Content of domain file** (if used & relevant): ```yaml intents: - findWalmart - inform entities: - location slots: location: type: text templates: action_findWalmart: - "here is the walmart store I found for location {location}!" action_prompt_for_location: - "what is your location?" actions: - action_findWalmart - action_prompt_for_location ``` ``` story.md ``` ***What I want to achieve:*** ``` ## when location slot is not pre-filled: * findWalmart - action_prompt_for_location * inform{"location":"mylocation"} - action_findWalmart ## when location slot is pre-filled (using slotset event with location value from other source): * findWalmart - action_findWalmart ``` I tried with this training stories, but it doesn't achieve my goal of not asking location when location slot is already filled. ``` attempted story files: ## st_1 * findWalmart{"location":"mylocation"} - action_findWalmart ## st_2 * findWalmart - action_prompt_for_location * inform{"location":"mylocation"} - action_findWalmart ```
disimone commented 6 years ago

you could trz adding the slot itself to the story

## st_2
* findWalmart
    - slot{"location": null}
    - action_prompt_for_location
* inform{"location":"mylocation"}
    - action_findWalmart

## st_2_2
* findWalmart
    - slot{"location": "any_value"}
    - action_findWalmart

combined with a memoizer in the policy, this works quite good for me.

note that according to the docs the value of the slot is not used in the dialogue prediction, just whether it is set or not. again according to the docs, null is how you say "not set"

HTH,

Andrea

disimone commented 6 years ago

another thing that works good for me is to use FormAction instead of a normal Action. It is available on master, and the documentation is rather clear. You basically specify in the action itself that it requires some slot to be set, and the action will ask for it to the user.

lisongshan commented 6 years ago

Hi, Andrea After seen your reply, I re-read the "common pattern" section of the rasa-core documentation. This seems to be the right approach according to the document. I will try it out.

Thanks a lot.

Songshan

ewagner70 commented 6 years ago

@disimone: did you find out how to use a filled in slot name, such as {location} in an utter_ask_xxxx action in a FormAction? It seems that it doesn't work as in a normal action template (such as the one you described above)

Rasa Team doesn't answer to my question/bug (?)

disimone commented 6 years ago

@ewagner70 I did not try this, sorry. Looking at the code in master, it should work, since they are simply calling dispatcher.utter_template

akelad commented 6 years ago

@lisongshan are you still having problems or can I close this?

lisongshan commented 6 years ago

@akelad please close it. @disimone thanks a lot.