Is it possible for an assistant to switch between stories?

A real assistant can book a hotel room or an airplane ticket, order pizza, reserve a table in a restaurant, look up local events, save important meetings in a calendar, etc. All these would require me to set up a different story. Can the bot switch between all these stories if the conversation shifts from one to another? If so, is there something special that needs to be done to make it happen? Thanks.

1 Like

hi @ggabor - welcome to the forum! Yes this is perfectly possible - you just need to provide some training stories where this happens. The easiest way is to use interactive learning and export those stories.

Let’s make an example by creating two stories.

## order pizza path
* greet
 - utter_greet
* want_pizza{"pizzeria": "Italia", "number": 14, "size": "large"}
  - order_pizza
* goodbye
  - utter_goodbye

## book movie ticket path
* greet
  - utter_greet
* want_ticket{"location": "Cinemax", "movie": "John Wick 3", "count": 2}
  - confirm_ticket
* thanks+goodbye
  - utter_goodbye

What I mean by switching between paths is that instead of saying goodbye after ordering a pizza I can order a movie ticket and Rasa will automatically switch from the first to the second, skipping the “goodbye” part of the first and the “greet” part of the second path - without me having to manually create a joined path.

What you say is that it essentially can’t do this, instead I should create joined paths.

Consider how many possible things an assistant could do. Creating every joined combination for 2 paths would require only 2 more “joined paths” but if the assistant can do 10 things separately then it’d require hundreds more paths to join them in every possible way.

hi Gabor

couple of things you can do:

  • use augmentation to generate some of these combinations at training time

  • use the new embedding policy, which is better able to handle topic switches

An important guiding principle behind Rasa is to learn from real conversations rather than design hypothetical ones. So even though there might be combinatorially many possibilities, a far smaller number will actually occur in reality.

“learn from real conversations” - this gives me an idea. We don’t really say hi to software.

If you think about the program as a personal assistant and not as something on a business’ website where you can ask for certain things and nothing else, then you communicate with it all day long without saying hello and goodbye all the time.

What if we remove all the greetings and goodbyes from every path, and instead create a path that is solely a greeting or a goodbye? This way we can say “hi” if we want to, but ordering a pizza in itself, without all the human interaction courtesy is a complete path, and then going on to order a movie ticket is another path. Once a path is exhausted, the program has no problem picking up a new path, is that correct?

The only hindrance here would be that slots are limited to a path, if I’m not mistaken, so information from one path’s slots would need to be saved somehow to make the software capable of referencing it once again at a later time.

What do you think, would this work?

you can certainly include some stories where you leave out the greetings and have separate stories for the hello and goodbye. Then the augmentation will combine these with the other stories you have into longer conversations that will be used to train the model.

Slots are not limited to particular stories, no. Slots are always carried forward until they are unset or there is a ConversationRestarted event.

One thing I want to clarify is that stories are examples used to train your model. The same way that NLU generalizes to new messages you haven’t seen before, Core learns from the examples you provide it. So there is no concept of ‘picking up a path’ and then ‘exhausting’ that path.

1 Like

Hi @ggabor, I was also facing similar problem. I solved this by creating a separate story file in my stories’ folder. image

where i defined all possible small conversations a user can have with my bot.

Using augmentation will automatically glue various stories together to create more realistic stories. Also you can skip using *greet and *goodbye in your regular stories as these will be glued automatically to all story lines. @amn41 kindly add if i skip something as I’m also new to rasa.

for these use cases I would strongly recommend you try the new retrievaal models Integrate response retrieval models in assistants built with Rasa