Contextual intent

Hi,

I am new to Rasa and trying to create a bot to help with product registration and registration checking. I have come up with the following story so far.

## greet
* greet
  - utter_greet
  - utter_howCanIHelp

## check warranty
* greet
  - utter_greet
  - utter_howCanIHelp
* check_warranty
  - utter_enterSerialNumber
* inform_serialnumber{"serial_number":""}
  - action_validate_serial
  - utter_moreHelp
* affirm
  - utter_howCanIHelp
* deny
  - utter_goodbye
  - action_restart

## say goodbye
* goodbye
  - utter_goodbye


## bot challenge
* bot_challenge
  - utter_iamabot

The bot works as expected, but it is picking up intent randomly. for example, if I don’t follow the greet part and just type in my serial number, it is validating the serial number, which is correct, but this validation action will be different in different context. When user wants to check the registration details, it would run a custom action and when user wants to register the product, it would run a custom action. Now for both the intents (check and register), I’ll ask user to enter the serial number and run the action accordingly. Bot must ignore serial numbers if it is not in a particular context. How can I achieve this? I know that in the validate registration number action, I can detect the previous intent and if user just entered the a serial number without saying “I want to check” or “I want to register”, then I may ask the user what to do with the provided serial number. But I believe there must be a better way.

I’d say, you need more training data. Write stories with what is supposed to happen, when the user types in the serial number without any context, e.g.:

## no context serial number story
* inform_serialnumber{"serial_number":""}
  - utter_what_to_do_with_it

As far as I understood how the NLU works, it will actually take the differences in context into account.

Thanks for the guidance… It helps, but I was trying to find out if I can do something with custom actions and some conditional logic to have better control and to avoid writing more stories…

I guess you could use a categorical slot, in which you save the task/use case the user wants to be done. And when they state the serial number, a custom action can check if the slot is empty and react accordingly. But this will need more training data on the NLU side of things as well as actually writing the custom action, so I would definitely prefer the more straightforward solution.

Btw, I really love using the rasa interactive tool in the shell, when my bot misbehaves - it’s really helpful!