Common story fragments?

I started using the < checkpoint feature and it’s nice and works well in some cases where my story ends with that checkpoint, and from what I can tell, this is the way it has to work, you can’t insert a checkpoint into the middle of a story or else you get story conflicts.

I’m curious if there is any good way to create something similar to a checkpoint but more like a common reusable fragment. The resulting functionality would be that it allows you to insert a story into a story.

Here’s one type of example, but there are other good reasons to break out a set of common story steps.

I have many support scenarios and some of them require a user’s ID number so the bot can go look up information related to their ID. There are other things you can do with the bot that don’t require the ID, so I don’t want to prompt the user for their ID, if I don’t need it.

I would like to have a fragment story like this:

## Prompt user for their ID number
> fragment_prompt_for_idnumber
  - form_database_query_customer
  - form{"name": "form_database_query_customer"}
  - form{"name": null}
  - utter_greet_first_name

I would like to be able to insert it into a larger story with >prompt_for_idnumber like this -

## 003 Buyer issue happy path with done
* buyer
  - utter_response_can_help
  > fragment_prompt_for_idnumber
  - utter_buyer_start
  - buyer_form
  - form{"name": "buyer_form"}
  - form{"name": null}
  - utter_anythingelse
* deny
  - utter_in_that_case
  - utter_goodbye
  - utter_goodbye_signoff
  - action_restart
* affirm
  - utter_whatelse

Is there currently any way to do this?

My thoughts / hacky idea:

I could create my own custom syntax, write stories in another directory, and build a python script that munges over all of my stories and inserts the fragment code where it should go and produce a final robust file to train on.

I’m hoping there’s a better way and open to ideas

Hi @jonathanpwheat!

Just wanted to add to your idea, you can build a custom training data importer, so as you said, you can write your stories however you want then import them in rasa format with your custom importer.

Hmm, never thought about using that, maybe I’ll try something like that.

Truth be told, I’d prefer out-of-the-box support for common story fragments though :slight_smile:

Yeah you are right. I also felt need for such a feature sometimes ago. Maybe other folks here could help you. You could also open a feature request for that, it’ll certainly be a good addition I think.