How to handle stories out of order


Suppose I have a story: Edit: forgot to mention that all slots are featurized

## example
* A
  - action_A
  - slot{"slot_A": "something"}
* B
  - B_form
  - form{"name": "B_form"}
  - slot{"B_form_slot": "other"}
  - form{"name": null}
* C
  - action_C

For action_C to work, all previous slots should be filled.

How to handle situations where user starts straight with intent C. In this scenario, action_C will fail because it does not have any slots set. Do I need to create a story for every possible scenario for every out of order intent?


Hi @eugeniumegherea. I hope I can help you out with this.

Yes, to model the behaviour where the users starts the conversations with intent C you should include at least one example story with it in your training stories file and make sure that the form is activated for your assistant to collect the information.

Could you provide an example of an actual conversation where users might go fo the intent C without going through intent B?

Hello, thanks for reply

This reply is quite lengthy, sorry in advance :sweat_smile:

Imagine a customer support bot:

Case 1: correct order

[user] - hi
[bot ] - hello, welcome to our customer support ... what do you want to do?
[user] - contact an agent (this triggers B form)
[bot ] - okay. do you have a sale id?
[user] - yes
[bot ] - okay. please enter it
[user] - XXXXXXX
[bot ] - thank you (B form finishes, submit does nothing)
[bot ] - what would you like to contact us about?
    - cancel sale
    - change sale
[user] - cancel sale (this action will trigger action C)
    {slot_set branching "cancel"}
[bot ] - we are sorry to hear... why would you do that?
    - changed my mind
    - other plans
[user] - changed my mind
  {slot_set cancelation reason "changed my mind"}
[bot ] - thank you. we will contact you about that very soon

Case 2: start from the middle

[user] - hi
[bot ] - hello, welcome to our customer support ... what do you want to do?
[user] - I would like to cancel my sale
    bot should ask for sale id and set branching slot as "cancel" and continue flow

Now, the slots that the sale form is setting are featurized. For example if the sale is already canceled, bot will say to the user something like “it seems that this sale is already canceled, do you think it is a mistake?” followed by yes/no and finally human handoff to handle the case.

If the user starts from intent C, the bot should ask for it’s sale id, check its status and if it’s an active sale, proceed further by setting the branching slot to “cancel” because user requested a cancelation.

If for example user wants to cancel and provides everything from first intent (ex: “I would like to cancel because we changed our plans”), bot should do everything from above + setting slot cancelation reason and go straight to human handoff.

Obviously in customer support there can be a lot of possible scenarios a user can do with a sale and I cannot wrap my head around how to handle every possible scenario nicely. I would appreciate some ideas in that regard. Currently we have at least 27 possible branchings from featurized slots and others like yes/no answers.

My current workaround

I’ve written a sort of story compiler that takes all possible branching that are predefined in a checkpoint like system and creates all possible stories. This seems like the way to go in my case.

Here is the big problem. For the intents that start from the middle, all intents that should trigger some slot modifications will firstly trigger an action that follows-up with sale id form if necessary. But the problem is that after the form completes, bot continues following the stories defined, not following user initial intent of cancel because some reason. What is mean is this:

[user] - I would like to cancel my sale because some reason
    trigger action to check whether sale id form slots are set or not
    follow up sale id form
[bot ] - thank you
[bot ] - what would you like to contact us about? (bot should have not asked this but rather proceed with setting slot branching and cancelation reason and go to handoff, but it does)

I cannot set the cancelation reason before following up sale form because I need to know the sale status. If it is canceled, I need to go on another branching path. So for now user has to go other again and say what he wants to do and why (bot looses context).

The solution I think would solve my use case

My ideal solution to this problem would be a some mechanism to tell the bot to go and do a predefined task and then come back with the results and proceed following original story (not the story from the task). I imagine it as an extension of Followup action that has a kind of callback to the caller. So in this case, an action could return not only slots and events but also a completely new branch of history and append it to tracker.

Or another mechanism that would tell the bot to fill some slots and then forget that and then proceed as if nothing happened but remember the slots.

Thank you