How to set the categorical slot value with the intent?

I have the following categorical slot defined.

entities:
- login_id_type
slots:
  login_id_type:
    type: categorical
    influence_conversation: true
    values:
    - phone_verify
    - login_code
    - email

And set stories for each category as:

- story: how_to_login - phone_verify
  steps:
  - intent: how_to_login
  - action: utter_ask_login_id_type
  - intent: inform
  - slot_was_set:
    - login_id_type: phone_verify
  - action: utter_ans_login_id_type_phone_verify
- story: how_to_login - login_code
  steps:
  - intent: how_to_login
  - action: utter_ask_login_id_type
  - intent: inform
  - slot_was_set:
    - login_id_type: login_code
  - action: utter_ans_login_id_type_login_code
- story: how_to_login - email
  steps:
  - intent: how_to_login
  - action: utter_ask_login_id_type
  - intent: inform
  - slot_was_set:
    - login_id_type: email
  - action: utter_ans_login_id_type_email

But I’m not sure it’s the right way to set slot value as below:

- intent: inform
  examples: |
    - [AA]("entity": "login_id_type", "value": "login_code")
    - [AAA]("entity": "login_id_type", "value": "login_code")
    - [BB]("entity": "login_id_type", "value": "phone_verify")
    - [BBB]("entity": "login_id_type", "value": "phone_verify")
    - [CC]("entity": "login_id_type", "value": "email")
    - [CCC]("entity": "login_id_type", "value": "email")

I can train the model without errors. But it’s wrong to run the model

2020-11-26 19:48:39 DEBUG    rasa.core.processor  - Received user message 'BB' with intent '{'id': 2632104468417020721, 'name': 'inform', 'confidence': 0.9999431371688843}' and entities '[{'entity': '"entity"', 'start': 0, 'end': 2, 'confidence_entity': 0.7480142574109602, 'value': ' "login_id_type", "value": "phone_verify"', 'extractor': 'CRFEntityExtractor', 'processors': ['EntitySynonymMapper']}, {'entity': '"entity"', 'start': 0, 'end': 2, 'confidence_entity': 0.9065237045288086, 'value': 'BB', 'extractor': 'DIETClassifier'}]'
/home/sz/py36-bert110-grakn181-rasa203/lib/python3.7/site-packages/rasa/shared/utils/io.py:93: UserWarning: Interpreter parsed an entity '"entity"' which is not defined in the domain. Please make sure all entities are listed in the domain.
  More info at https://rasa.com/docs/rasa/domain
2020-11-26 19:48:39 DEBUG    rasa.core.processor  - Current slot values:
        feedback_message: None
        feedback_value: None
        login_id_type: None
        requested_slot: None
2020-11-26 19:48:39 DEBUG    rasa.core.processor  - Logged UserUtterance - tracker now has 8 events.
2020-11-26 19:48:39 DEBUG    rasa.core.policies.memoization  - Current tracker state [{}, {'user': {'intent': 'how_to_login'}, 'prev_action': {'action_name': 'action_listen'}}, {'user': {'intent': 'how_to_login'}, 'prev_action': {'action_name': 'utter_ask_login_id_type'}}, {'user': {'intent': 'inform'}, 'prev_action': {'action_name': 'action_listen'}}]
2020-11-26 19:48:39 DEBUG    rasa.core.policies.memoization  - Launch DeLorean...
2020-11-26 19:48:39 DEBUG    rasa.core.policies.memoization  - Current tracker state [{}, {'user': {'intent': 'inform'}, 'prev_action': {'action_name': 'action_listen'}}]
2020-11-26 19:48:39 DEBUG    rasa.core.policies.memoization  - There is no memorised next action
2020-11-26 19:48:39 DEBUG    rasa.core.policies.rule_policy  - Current tracker state: [{}, {'user': {'intent': 'how_to_login'}, 'prev_action': {'action_name': 'action_listen'}}, {'user': {'intent': 'how_to_login'}, 'prev_action': {'action_name': 'utter_ask_login_id_type'}}, {'user': {'intent': 'inform'}, 'prev_action': {'action_name': 'action_listen'}}]
2020-11-26 19:48:39 DEBUG    rasa.core.policies.rule_policy  - There is no applicable rule.
2020-11-26 19:48:39 DEBUG    rasa.core.policies.ensemble  - Predicted next action using policy_0_TEDPolicy
2020-11-26 19:48:39 DEBUG    rasa.core.processor  - Predicted next action 'utter_ans_login_id_type_email' with confidence 0.47.
2

I’d suggest using buttons and including the entities in the payload. For this you’ll set the payload equal to /inform{“login_id_type”: ”phone_verify”} for example. This will bypass the NLU pipeline and deliver the intent and entities directly to the dialog manager.

@kearnsw Due to the limitation of some channel, I can’t use buttons here. Without buttions, what should I do? Use non-categorial slot + synonym + action to get the job done?

Based on many many tries, synonym doesn’t work here. If anyone can give an example how to use categorial slot to do Contextual Conversations, that would be great.

Is this via SMS? It looks like you are offering options A,B, and C. You should implement this as a form which will provide validation and in the case of an incorrect value it’ll reprompt the user. Additionally, it’ll allow you to collapse your stories into a single story. For this you’ll need to use the from_entity() function.


forms:
  login_form:
    login_id_type:
      - type: from_entity
        entity: selection

I’d suggest using a regular expression match for these instead of going for an ML solution.


nlu:
- regex: selection
  examples: |
    - \bA\b
    - \bB\b
    - \bC\b

Thanks for your suggestion. A/B/C are not the only options. Acutally, there’re three categories indeed. There are just many synonyms for each category.

Form is good for collecting user information, I guess it’s a little heavy here. I prefer a Contextual Conversation. There should be a easy way to do it. Since the Rasa doc shows an exmple of Contextual Conversation with bool slots.

I guess, what I need is just an example of Contextual Conversation with categorial slots. Do you have any experience about it?

Thanks, again

It seems that no easy way to set categorical slot value with intent directly. But we can by pass the issue with synonym + categorical slot + contextual story.

Can you provide an example of your solution?

If you’re trying to set a categorical slot using an intent and have a single slot you are trying to fill, then the from_trigger_intent mapping should do the trick.


forms:
  login_form:
    login_id_type:
    - type: from_trigger_intent
      value: phone_verify
      intent: inform_login_id_phone_verify

However, I would still recommend a form with the from_intent method as you are starting with the same intent utter_ask_login_id_type for each context and incorporating this prompt into the form will provide better opportunity for error handling. Not to mention this is the exact syntax used for forms.

1 Like