Rasa: How to work with FormAction?

Created on 3 May 2018  路  35Comments  路  Source: RasaHQ/rasa

Rasa Core version: 0.9.0a3
Rasa NLU version: 0.12.2

Python version: 3.6

Operating system (windows, osx, ...): Ubuntu 17.10

Issue: I'm obviously too stupid to work with newly introduced FormAction for easier filling in slots and not generating numerous stories (details see files below).
The bot got stuck after trigger sentence "I want to report a conflict of interest". Then no reply (no matter what I enter)
when I enter fallback sentence, then 10 times the fallback reply comes back.

Can you provide a simple comprehensive example on how to use FormAction (your partial examples seem to lack some key information or I'm simply too stupid to understand it), ideally complemented with an example on how to fill the slot with the "coi_gi_receivername" (!)
Thx in advance!

Content of domain file (if used & relevant):
```georgebot_domain.yml
intents:

  • greet
  • default
  • goodbye
  • thankyou
  • reportcoi
  • affirm
  • inform

entities:

  • username

slots:
username:
type: text
initial_value: "human"
slot_result:
type: text
requested_slot:
type: unfeaturized

templates:
utter_greet:
- "hey there {username}!" # variable will be filled by slot with the same name or by custom code
utter_goodbye:
- "goodbye {username}" # multiple templates will allow the bot to randomly pick from them
utter_default:
- "I don't understand what you mean!"
utter_affirm:
- "affirmative"
utter_thankyou:
- "you're welcome"
utter_entername:
- "Good to know you, {username}"
utter_reportcoi:
- "Sure, let me guide you through the reporting process."
utter_coi_gi_receivername:
- "Who is the receiver of the gift/invitation?"
utter_coi_gi_give_or_take:
- text: "Do you give or receive the gift/invitation to {coi_gi_receivername}?"
buttons:
- title: "give"
payload: "give"
- title: "receive"
payload: "receive"
utter_coi_amount:
- "How much is the gift/invitation worth (in EUR)?"
utter_coi_gi_is_publicofficial:
- "Is the receiver/giver a public official?"
utter_coi_remarks:
- "Please amend any further information necessary"

actions:

  • utter_greet
  • utter_default
  • utter_goodbye
  • utter_thankyou
  • utter_reportcoi
  • utter_affirm
  • utter_entername
  • utter_coi_gi_receivername
  • utter_coi_gi_give_or_take
  • utter_coi_gi_is_publicofficial
  • utter_coi_amount
  • utter_coi_remarks
  • test_rasa.ActionReportCoI
```test_rasa.py
class ActionReportCoI(FormAction):

    RANDOMIZE = False

    @staticmethod
    def required_fields():
        return [
            EntityFormField("coi_gi_receivername", "coi_gi_receivername"),
            EntityFormField("coi_gi_give_or_take", "coi_gi_give_or_take"),
            EntityFormField("coi_gi_is_publicofficial", "coi_gi_is_publicofficial"),
            EntityFormField("coi_amount", "coi_amount")
        ]

    def name(self):
        return 'action_report_coi'

    def submit(self, dispatcher, tracker, domain):
        results = RestaurantAPI().search(
            tracker.get_slot("coi_gi_receivername"),
            tracker.get_slot("coi_gi_give_or_take"),
            tracker.get_slot("coi_gi_is_publicofficial"),
            tracker.get_slot("coi_amount"))
        return [SlotSet("search_results", results)]

```georgebot_nlu.md

intent:greet

  • good morning
  • good evening
  • hey
  • howdy
  • hey there
  • hello
  • hi
  • dear sir

intent:default

  • bla bla
  • do you want to marry me
  • i hate you
  • i want something else
  • can you help me?
  • do you love me?
  • fuck you

intent:goodbye

  • goodbye
  • good bye
  • stop
  • end
  • farewell
  • Bye bye
  • have a good one

intent:affirm

  • great
  • right, thank you
  • correct
  • great choice
  • sounds really good
  • yes
  • yep
  • yeah
  • indeed
  • that's right
  • ok

intent:reportcoi

  • report conflict of interest
  • i would like to report a conflict of interest
  • i want to report a conflict
  • how can i report a conflict of interest
  • where can i report a conflict of interest
  • can you support me in reporting a conflict of interest

intent:intent_coi_gi_receivername

intent:thankyou

  • thanks
  • thank you
  • thank you very much
  • nice
  • thx alot
  • thx
  • appreciated

synonym:chinese

  • Chines
  • Chinese

synonym:vegetarian

  • vegg
  • veggie

regex:zipcode

  • [0-9]{5}

regex:greet

  • hey[^\s]*
```georgebot_stories.md
## greet path
* greet
  - utter_greet

## goodbye path
* goodbye
  - utter_goodbye

## default path
* default
  - utter_default

## affirm path
* affirm
  - utter_affirm

## thankyou path
* thankyou
  - utter_thankyou

## report_coi path 1
* reportcoi
  - action_report_coi
  - slot{"requested_slot": "coi_gi_give_or_take"}
* inform("coi_gi_give_or_take": "give")
  - action_report_coi
  - slot{"requested_slot": "coi_gi_is_publicofficial"}
* inform{"coi_gi_is_publicofficial": "affirm"}
  - action_report_coi
  - slot{"requested_slot": "coi_amount"}
* inform{"coi_amount": "1000"}
  - action_report_coi
  - utter_goodbye

Most helpful comment

+1 we should raise an error if a domain contains a FormAction but there is no requested_slot in the domain

All 35 comments

Guys ... any chance for feedback? Does this FormAction really work? Did anybody succeed in bringing that to life?

Does the report_coi path 1 not work either if you try to follow it with the trained bot?

I'm not sure, as I don't get any feedback from bot - prompt remains and I can enter further input(s) with same effect. This stops when I only hit the enter (i.e. no input) and then 10 times the utter_default appears. Then I can start over with "hi" again (which works, by the way). Only if I enter the report_coi_path 1, I have the above mentioned effects.

Can you run the bot with --debug flag set to increase the output? If you don't mind, please also add the comandline log from this session.

ok ... got a bit further, DEBUG mode really shows a lot on where documentation is really lacking (!).
I'm now stuck with the following 3 issues:

  1. how to handle Buttons in FormAction?
  2. (a) I can show them properly, but don't know how to handle the answer (it is interpreted with usual intents and not with the button payloads !?)
  3. (b) if I enter a slot name in the text, f.ex. {coi_gi_receivername}, it is shown as {coi_gi_receivername], but not with the previously entered and correctly slot stored value "eric wagner"

  4. how to handle Fallback within FormAction (here again, 10 times utter_default comes up, when a [not in a story existent] fallback situation applies; when entered outside any Formaction, Fallback works)

  5. how to handle Boolean in FormAction?
  6. (a) I can enter the affirm intent, which is also recognized, but NOT handled as answer to the bool form and NOT stored in the slot accordingly (!?)
  7. (b) same as 1b, if I enter a slot name in the text, f.ex. {coi_gi_receivername}, it is shown as {coi_gi_receivername], but not with the previously entered and correctly slot stored value "eric wagner"

see attached files for the code and configurations
test_rasa.zip
as well as the respective console dialogue (DEBUG mode) below:

Bot loaded. Type a message and press enter: 
hi
2018-05-06 01:20:30 DEBUG    rasa_core.tracker_store  - Creating a new tracker for id 'default'.
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Received user message 'hi' with intent '{'name': 'greet', 'confidence': 0.49393202362036}' and entities '[]'
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 2 events
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Current slot values: 
    coi_amount: None
    coi_gi_give_or_take: None
    coi_gi_is_publicofficial: None
    coi_gi_receivername: None
    coi_remarks: None
    requested_slot: None
    slot_result: None
    username: human
2018-05-06 01:20:30 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('slot_username_0', 1)]
    [('intent_greet', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]]
2018-05-06 01:20:30 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'utter_greet' with prob 1.00.
hey there human!
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: hey there human!, data: null)'
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Action 'utter_greet' ended with events '[]'
2018-05-06 01:20:30 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_greet', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]
    [('intent_greet', 1), ('slot_username_0', 1), ('prev_utter_greet', 1)]]
2018-05-06 01:20:30 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_listen' with prob 1.00.
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
2018-05-06 01:20:30 DEBUG    rasa_core.processor  - Current topic: None
i want to report a conflict of interest
2018-05-06 01:20:40 DEBUG    rasa_core.tracker_store  - Recreating tracker for id 'default'
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Received user message 'i want to report a conflict of interest' with intent '{'name': 'reportcoi', 'confidence': 0.4578477483215921}' and entities '[]'
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 6 events
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Current slot values: 
    coi_amount: None
    coi_gi_give_or_take: None
    coi_gi_is_publicofficial: None
    coi_gi_receivername: None
    coi_remarks: None
    requested_slot: None
    slot_result: None
    username: human
2018-05-06 01:20:40 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_greet', 1), ('slot_username_0', 1), ('prev_utter_greet', 1)]
    [('intent_reportcoi', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]]
2018-05-06 01:20:40 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_report_coi' with prob 1.00.
Who is the receiver of the gift/invitation?
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: Who is the receiver of the gift/invitation?, data: null)'
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Action 'action_report_coi' ended with events '['SlotSet(key: requested_slot, value: coi_gi_receivername)']'
2018-05-06 01:20:40 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_reportcoi', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]
    [('intent_reportcoi', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]]
2018-05-06 01:20:40 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_listen' with prob 1.00.
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
2018-05-06 01:20:40 DEBUG    rasa_core.processor  - Current topic: None
the receiver's name is Eric Wagner
2018-05-06 01:20:47 DEBUG    rasa_core.tracker_store  - Recreating tracker for id 'default'
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Received user message 'the receiver's name is Eric Wagner' with intent '{'name': 'coi_gi_receivername', 'confidence': 0.5459034188528149}' and entities '[{'entity': 'PERSON', 'value': 'Eric Wagner', 'start': 23, 'confidence': None, 'end': 34, 'extractor': 'ner_spacy'}, {'start': 23, 'end': 34, 'value': 'eric wagner', 'entity': 'coi_gi_receivername', 'confidence': 0.7606913926018922, 'extractor': 'ner_crf'}]'
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 12 events
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Current slot values: 
    coi_amount: None
    coi_gi_give_or_take: None
    coi_gi_is_publicofficial: None
    coi_gi_receivername: eric wagner
    coi_remarks: None
    requested_slot: coi_gi_receivername
    slot_result: None
    username: human
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_reportcoi', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]
    [('intent_coi_gi_receivername', 1), ('entity_coi_gi_receivername', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]]
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_report_coi' with prob 1.00.
Is the {coi_gi_receivername} a public official?
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: Is the {coi_gi_receivername} a public official?, data: null)'
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Action 'action_report_coi' ended with events '['SlotSet(key: coi_gi_receivername, value: eric wagner)', 'SlotSet(key: requested_slot, value: coi_gi_is_publicofficial)']'
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_coi_gi_receivername', 1), ('entity_coi_gi_receivername', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]
    [('intent_coi_gi_receivername', 1), ('entity_coi_gi_receivername', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]]
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:47 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_listen' with prob 1.00.
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
2018-05-06 01:20:47 DEBUG    rasa_core.processor  - Current topic: None
yes
2018-05-06 01:20:59 DEBUG    rasa_core.tracker_store  - Recreating tracker for id 'default'
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Received user message 'yes' with intent '{'name': 'affirm', 'confidence': 0.5472063446898725}' and entities '[]'
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 18 events
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Current slot values: 
    coi_amount: None
    coi_gi_give_or_take: None
    coi_gi_is_publicofficial: None
    coi_gi_receivername: eric wagner
    coi_remarks: None
    requested_slot: coi_gi_is_publicofficial
    slot_result: None
    username: human
2018-05-06 01:20:59 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:59 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_coi_gi_receivername', 1), ('entity_coi_gi_receivername', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]
    [('intent_affirm', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]]
2018-05-06 01:20:59 DEBUG    rasa_core.featurizers  - Feature 'entity_PERSON' (value: '1.0') could not be found in feature map. Make sure you added all intents and entities to the domain
2018-05-06 01:20:59 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_report_coi' with prob 1.00.
Do you give or receive the gift/invitation to {coi_gi_receivername}?
1: give (give)
2: receive (receive)
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: Do you give or receive the gift/invitation to {coi_gi_receivername}?, data: {
  "buttons": [
    {
      "payload": "give",
      "title": "give"
    },
    {
      "payload": "receive",
      "title": "receive"
    }
  ]
})'
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Action 'action_report_coi' ended with events '['SlotSet(key: coi_gi_is_publicofficial, value: True)', 'SlotSet(key: requested_slot, value: coi_gi_give_or_take)']'
2018-05-06 01:20:59 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_affirm', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]
    [('intent_affirm', 1), ('slot_coi_gi_is_publicofficial_0', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]]
2018-05-06 01:20:59 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_listen' with prob 1.00.
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
2018-05-06 01:20:59 DEBUG    rasa_core.processor  - Current topic: None
give
2018-05-06 01:23:47 DEBUG    rasa_core.tracker_store  - Recreating tracker for id 'default'
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Received user message 'give' with intent '{'name': 'goodbye', 'confidence': 0.42840596401523173}' and entities '[]'
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Logged UserUtterance - tracker now has 24 events
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Current slot values: 
    coi_amount: None
    coi_gi_give_or_take: None
    coi_gi_is_publicofficial: True
    coi_gi_receivername: eric wagner
    coi_remarks: None
    requested_slot: coi_gi_give_or_take
    slot_result: None
    username: human
2018-05-06 01:23:47 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_affirm', 1), ('slot_coi_gi_is_publicofficial_0', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_report_coi', 1)]
    [('intent_goodbye', 1), ('slot_coi_gi_is_publicofficial_0', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]]
2018-05-06 01:23:47 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'utter_goodbye' with prob 0.60.
goodbye human
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Bot utterance 'BotUttered(text: goodbye human, data: null)'
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Action 'utter_goodbye' ended with events '[]'
2018-05-06 01:23:47 DEBUG    rasa_core.policies.memoization  - Current tracker state [
    [('intent_goodbye', 1), ('slot_coi_gi_is_publicofficial_0', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_action_listen', 1)]
    [('intent_goodbye', 1), ('slot_coi_gi_is_publicofficial_0', 1), ('slot_coi_gi_receivername_0', 1), ('slot_username_0', 1), ('prev_utter_goodbye', 1)]]
2018-05-06 01:23:47 DEBUG    rasa_core.policies.ensemble  - Predicted next action 'action_listen' with prob 1.00.
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Action 'action_listen' ended with events '[]'
2018-05-06 01:23:47 DEBUG    rasa_core.processor  - Current topic: None

Guys ... any help would be appreciated.

So as for 1:
You have to set the payload to "/give" - this directly passes on the intent.
How are you sending this utterance? Is it with dispatcher.utter_button_template? If it's with dispatcher.utter_button_message, you have to .format the string with the slot value. With the template it should be set automatically though.

  1. I'd say you have to add stories for the fallback action then.

I have to be honest - you've lost me ...

ad 1a) there's no "give" intent. I simply want to fill the slot "coi_gi_give_or_take" with either "give" or "receive". Ideally, I would like to do that with a button, but I don't know how that works within FormAction?
ad 1b) can you help me on that as well?

ad 2)

  • do you really mean separate STORIES for fallback action? If yes, HOW do I do that ??
  • I thought separate intent examples in nlu.yml are sufficient for that?

ad 3a+b) can you help me on that as well?

In general, see attached .zip file above with complete py and yml and md file-set (!)

can you please at least help me on 1b/3b? the slot is populated, but not shown in utterance utter_ask_xxx, when using FormAction! Is that a bug or am I'm doing something wrong?

https://github.com/RasaHQ/rasa_core/pull/458 should fix the slot issue - looks like that was a bug so not anything you did wrong.

for 1a) if you want a button to pass entities you can also do that, with e.g. /coi_gi_give_or_take{"give_take":"give"} as a payload (assuming you have an entityformfield which sets entity give_take to the slot you want to set.

ad 1b/3b) cool ... how do I install the new version 0.9.0a5?
pip install rasa_core==0.9.0a5 --user
Collecting rasa_core==0.9.0a5
Could not find a version that satisfies the requirement rasa_core==0.9.0a5 (from versions: 0.7.0a5, 0.7.0a8, 0.7.0a9, 0.7.0a10, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.7.4, 0.7.5, 0.7.6, 0.7.7, 0.7.9, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.9.0a1, 0.9.0a2, 0.9.0a3)
No matching distribution found for rasa_core==0.9.0a5
Once this version can be installed, you can close that issue.

ad 1a) yes, I've already found that out (NOT from the documentation, but from github issue)

easiest is just to grab master from github

I'm too stupid ...
sudo -H python3 setup.py install --user
installs everything in (correct) ~/.local/lib/python3.6/site-packages/
EXCEPT rasa_core, which is installed under /root/.local/lib/python3.6/site-packages/ (!?)
see:

root@fractal:/root/.local/lib/python3.6/site-packages# ls -l
total 300
-rw-r--r-- 1 root root    220 Mai 14 22:20 easy-install.pth
-rw-r--r-- 1 root root 295766 Mai 14 22:20 rasa_core-0.9.0a5-py3.6.egg
-rw-r--r-- 1 root root     46 Mai 14 22:20 setuptools.pth
root@fractal:/root/.local/lib/python3.6/site-packages# cat easy-install.pth 
./rasa_core-0.9.0a5-py3.6.egg
/usr/local/lib/python3.6/dist-packages/colorhash-1.0.2-py3.6.egg
/home/eric/.local/lib/python3.6/site-packages
/usr/local/lib/python3.6/dist-packages/tensorflow-1.8.0-py3.6-linux-x86_64.egg
root@fractal:/root/.local/lib/python3.6/site-packages# cat setuptools.pth 
/home/eric/.local/lib/python3.6/site-packages

Rasa Core version: 0.9.3
Rasa NLU version: 0.12.

Python version: 32.7

Operating system (windows, osx, ...): OSx

Issue:
I am getting a strange error.
While running, I get the following:

INFO rasa_core.trackers - Tried to access non existent slot 'requested_slot'

ERROR rasa_core.trackers - Tried to set non existent slot 'requested_slot'. Make sure you added all your slots to your domain file.

In both the cases, the slot it is trying to check or fill is not the slot name (like "addr", but a slot called requested_slot !

Anyone come across such issue?

Domain:
slots:
fName:
type: text
lName:
type: text
mob:
type: text
dbirth:
type: text
eMail:
type: text
.... (there are 10 such fields)

Actions.py

class RestaurantAPI(object):
def search(self, info):
return "papi's pizza place"

class ActionFillForm(FormAction):

RANDOMIZE = False

@staticmethod
def required_fields():
    return [
        FreeTextFormField("fName"),
        FreeTextFormField("lName"),
        FreeTextFormField("sex"),
        FreeTextFormField("dbirth"),
        FreeTextFormField("mob"),
        FreeTextFormField("eMail"),
        FreeTextFormField("idType"),
        FreeTextFormField("idNo"),
        FreeTextFormField("addr"),
        FreeTextFormField("idProof")
    ]

def name(self):
    return ACTION_FILLFORM

def submit(self, dispatcher, tracker, domain):
    results = RestaurantAPI().search("test")

    return [SlotSet("search_results", results)]

Stories:

fillform

  • accountApplicationProcessStart

    • utter_help

    • action_fillForm

    • slot { "fName":"xxxxx"}

  • nameNo {"fName":"Surya"}
    .....
    repeated the story for all required fields (9 more fields)

You need to add the name requested_slot to your slots in the domain file

Thank you! The error disappeared. Wish the documentation was little clear. Did not realize the slot name it self was, "requested_slot'

+1 we should raise an error if a domain contains a FormAction but there is no requested_slot in the domain

another suggestion / request :
Is it possible to pull the VALIDATE function from forms.py and be referenced / called from custom actions?
Though this validations implementation is nice, don't like some custom code creeping in core packages.

I made some progress. I am able to get the validations properly. It does go to the submit function after the last action_fillForm. But, story does not go to "utter_goodbye". Is this a training issue or something else?
I am yet to locate a proper example to see, if I am at least on the right track.

My story ends like this...

....
....
....

  • action_fillForm
  • slot { "requested_slot": "addr"}

    • nameNo {"addr":"103, 1xxxxx"}

  • action_check
  • action_write
  • action_fillForm
  • slot { "requested_slot": "idProof"}

    • nameNo {"idProof":"xxxxx"}

  • action_fillForm
  • utter_goodbye
  • action_restart

@ewagner70 , did you manage to get this working. Been doing several attempts and also finding very similar to your observations.

@Egalite123 yes, I've downloaded the most recent version from github (via pip install -U git+https://github.com/rasahq/rasa_core.git --user ) what I found out is that the training set is sometimes quite tricky to compose (if you are referring to your last comment "... but story does not go to 'utter_goodbye' ...") especially if you have lengthy similar paths in various stories and it can sometimes lead to a shitty model, which does not really work (then simply re-train again and re-use that model accordingly)
Don't know if my answer really helps - maybe you can be more specific which of the aboves issues you're referring to.

@Egalite123 could you please share your project here.. I am facing the same issue :(

@Egalite123 I am having the same issue as well. It goes into submit form but does not go into the next action.

could one of you share your stories file/form action so we can try and reproduce this? In general it might help to try interactive learning for this. It might be that you've forgotten a slot set event somewhere in your stories

Hi @akelad , here is my stories file.
When I run the bot, I do get "success". But, does not goto "utter_otp".
Please let me know, if you need anything more.

FundsTransferConfirm

  • transferFunds

    • action_fillForm

    • slot{"requested_slot": "fromAccount"}

  • dataInput

    • action_fillForm

    • slot{"fromAccount": "A0001"}

    • slot{"requested_slot": "toAccont"}

  • dataInput

    • action_fillForm

    • slot{"toAccount": "B0002"}

    • slot{"requested_slot": "currency"}

  • dataInput

    • action_fillForm

    • slot{"currency": "USD"}

    • slot{"requested_slot": "amt"}

  • dataInput

    • action_fillForm

    • slot{"amt": "1000"}

    • slot{"searchResults": "success"}

    • utter_otp

  • otp

    • utter_confirmTransfer

    • action_restart

actions.py -->

class trustCheck(object):
def search(self, *args):

    print ("= = = = inside api  = = = = =")
    return

class ActionFillForm(FormAction):

RANDOMIZE = False
print ("Surya...")
@staticmethod
def required_fields():
    return [
        FreeTextFormField("fromAccount"),
        FreeTextFormField("toAccount"),
        FreeTextFormField("currency"),
        FreeTextFormField("amt")
    ]

def name(self):
    return ACTION_FILLFORM

def submit(self, dispatcher, tracker, domain):


    results = trustCheck().search(
        tracker.get_slot("fromAccount"),
        tracker.get_slot("toAccount"),
        tracker.get_slot("currency"),
        tracker.get_slot("amt"))

    template = "utter_thanks"
    dispatcher.utter_template(template)

    results = "success"
    print ("==== in submit =====")
    print ("Results...... ", results)
    return [SlotSet("searchResults",results)]

In continuation of the above, while testing last night noticed this -
a. While I just start with intent (in this example - just saying "transfer funds" with out entities) and if I let FormAction control the dialogue with the user (filling all slots sequentially), it is behaving normally and goes onto "utter_otp"
b. If I start with something like - "transfer 100 from my account AC1234", bot identifies that , two slots amt and fromAccount are filled and asks only currency and toAccount. In this case, though the FormAction has all the entities, it does out come of the loop and goes to "utter_otp".

May be this is a clue. But, was still elusive to me.

Ah ok, so the issue here is you need to have a story for that case too, when the user provides some information at the start already. Otherwise Core may not have the correct prediction

Not sure, I follow you. But, when the user supplies other info (e.g., amount ), I see that the required slot is already is filled and FormAction skips the question. That is an expected behaviour, right?

Yes it is, but you also need to add the stories for those cases to your training data otherwise future predictions of core might be wrong.

I must be missing something.. but If i have fields in the FormAction that are more or less identical in its range and type of values, how do I train my NLU to recognise the correct intent for it. Eg inform{"latitude": "10"} vs inform{"longitude": "10"}. Is there any way for me to automatically force whatever input the user has to a particular intent?

could one of you share your stories file/form action so we can try and reproduce this? In general it might help to try interactive learning for this. It might be that you've forgotten a slot set event somewhere in your stories

Strangely, in interactive learning, it seems to be executing it correctly.

what do you mean? Those examples have the same intent, are you talking about entities?

I have hit up on a problem. I have two different story snippets (or, use cases). One FormAction to make a FundsTransfer and another one to collect user information for call back. I have named them two different action names and also two different intents to collect user inputs (one like illustrated above - "dataInput" and other formAction has "inform" intents - just to avoid confusion.
Both the flows collect numerical data (like amount in the example above and other form action also collects customer account number).
Some times, while running, bot picks up the other intent (instead of "dataInput" picks the intent as "inform" and jumps into the middle of other story.
How can I avoid this situation?

@Egalite123 Can you post this kind of question in our forum please? We'll answer it there.
Also this issue thread has been going on for a while and they're all mostly questions rather than issues/bugs, so I'll close this for now.

Was this page helpful?
0 / 5 - 0 ratings