Start another story automatically based on last utterance

I have a story in which an utterance action is the last step. I want to know if there is a way to automatically start another story(without asking for an intent) after that utterance action is performed by the bot.

I know I can put the steps inside a single story but there is a complicated reason why I’m not doing that.

My Use Case Example

In the below stories, story 1 is completed when utter_something is performed. So after that utterance, I want to automatically start the story 2 which contains a feedback form.

stories:
  - story: story 1
    steps:
    - intent: ask_something
    - action: utter_something
  - story: story 2
    steps:
    - action: feedback_form
    - active_loop: feedback_form
    - active_loop: null

Thanks in advance

Hello and welcome to the forum!

You can have rule (or story) for that:

stories:
- story: links story 1 to story 2
  steps:
  - action: utter_end_of_first
  - action: action_start_of_second

For your particular case (forms), I don’t know if it would work. Because the following may predict action: action_listen after action: feedback_form, while you want to execute active_loop: feedback_form:

stories:
- story: links story 1 to story 2
  steps:
  - action: utter_something
  - action: feedback_form

Do try it out though and come back with the results :slight_smile:

I have 2 questions:

  1. Do I need to create a 3rd story that links the other 2 ?
  2. If Yes to the 1st question then is it necessary to name the third story like - “links story_a to story_b” ?

Yes. Stories are rules are made for linking stuff between each other.

No, you can give whatever name you want to stories and rules (as long as it obeys YAML syntax).

I tried your method with simple stories but it doesn’t seem to be working. Check stories below.

stories:

- story: happy path
  steps:
  - intent: greet
  - action: utter_greet
  - intent: mood_great
  - action: utter_happy

- story: story2
  steps:
  - action: utter_linking_works

- story: linker_story
  steps:
  - action: utter_happy
  - action: utter_linking_works

happy path is concluded with utter_happy, after which story2 doesn’t start i.e. utter_linking_works doesn’t occur. And yes utter_linking_works is present in domain file.

Am I doing something wrong here?

Story 2 is made up of one action, which is wrong.

A story is a sequence of steps.

The best (and intended) way to do what you want to do is do it all in one story. Isn’t it simpler?

- story: happy path
  steps:
  - intent: greet
  - action: utter_greet
  - intent: mood_great
  - action: utter_happy
  - action: utter_linking_works

Hi Peter @bofo and welcome to the forum :bouquet: I guess you can use Checkpoints : Stories for connecting the stories.

Checkpoints: They’re just intermediate points to connect two stories together. You don’t “define” them anywhere, you just put a checkpoint of any name you make at the end of one story, and then the same one at the start of the other story you want to connect.

I have a lot of story1s just with slightly different content, and every one of the story1s have the same utterance as the last step. I can’t add the same form for each story1. That’s why I want to do the form in a separate story which runs automatically when the utterance from any of the story1s is performed. I hope you understand this situation.

I used only one action as an example in the previous reply.

Can you direct me to an example rasa project to understand this story linking behaviour?

Checkpoints are nice but I have a lot of story1s with slightly different content, and every one of the story1s have the same utterance as the last step. I would have to add a checkpoint to each and every story1 to connect them to story2.

I would prefer a way to start story2 without changing anything in the story1s.

@bofo Then your use case is very complex, if your user want to divert your use case or ask the different question ? then any plan how to deal with that? you can’t fixed the stories like A->B->C->D and so on…any comment?

I understand that this use case is complex. But let’s assume that user won’t divert the use case. Is it possible to do then?

BTW, do you understand the solution that @ChrisRahme suggested in the beginning? It seems perfect for my use case, but I can’t seem to get it to work.

@bofo yes, anything can possible if we assume (but the reality is different), yes, you can follow the Chris suggestion and proceed (just try once) ; I personally not implemented this usecase; my use case is different.

I’ve tried @ChrisRahme method, but it doesn’t seem to work. I’ve provided the stories in the above post.

I can properly understand it if there was a working project which was using this method.

@bofo your story are interdependent or just like a story 1 then story 2 and so on?

They are not interdependent. story1 will run and end, and then story2 should start automatically.

If that’s the case, you should use Checkpoints and OR statements

Ok, I understand. But what about the method you suggested? Its not working anyway I try. So, can you please provide an example project that uses that method. The example doesn’t have to be like my use case. I just want to see your suggested method actually running.

@bofo Is your issue is solved whilst using checkpoints as suggested?

No. I wanted to automatically start a 2nd story whenever a certain utterance is performed at the end of the 1st story. But, If I have a lot of stories with that utterance as the last step, then I have to put the checkpoints in every 1st story.

I was looking for an automatic method without adding anything in the 1st stories. The method suggested by @ChrisRahme seemed perfect for my use case, but it’s not working, as I mentioned in my previous posts.