Newbie seeks pointers on quick state machine setup

Hi,

I am a 2 day old newbie needing pointers on setting up a mere state machine, aka a fixed “multiple choice” system as soon as possible. (in Rasa, of course). I need to convince the software engineers on my team that continuing to roll-their-own chat system is a waste of time.

One good model for what I am after seems to be this Rasa implementation: your profiled Canadian Dialog Virtual Clinic (e.g. Dialogue Virtual Clinic Chatbot | Rasa Showcase | Rasa). It seems to be built almost entirely on a happy path model because virtually all of the turns shown in the video do not offer free text type. User statements are almost entirely driven by clicking on what seem to be pre-engineered multiple choice chits. Right?

My best tack at convincing the engineers is to stand up a working replica of that happy path system they have already built. Just a plain ascii text bot would be fine. I want to show them how fast the set up is and simple and how elegant the stories, etc are.

Then later show them how extensible into real world context dependent dialogs can be supported.

We already have a working intent / mention NLU system with maybe 10 intents. Maybe 20 to 30 different dialog nodes.

So, I would appreciate any of the following:

- (a) key system terms/aspects to study first

- (b) what parts of the manual to read first

- (c) what videos to watch first

- (d) any shareable pointers you have about a system like the Canadian Dialog Virtual Clinic

- (e) any useful incantations to know when you have a chit based system

Believe me, I know full well that coding with state machines for supporting happy paths is the road to ruin.

But what I need to do is be convincing to the extremely pragmatic, fast moving, non NLP sophisticate engineers that the Rasa way will win in the short term over their own hackery.

For this reason, I am keen on reproducing the happy path system. Once I have won them over and we use Rasa then I can get us on the Right Track RE true contextually sensitive dialog stories etc.

I have little time to make my case to them. Hence I balk at reading the 170ish page manual in full before starting implementing. Hopefully I can be done in like, um, 3 days?

Thanks for any pointers for a quick start!

Thanks,

T

@Tester01 Hello, Testie the tester! Welcome to the forum. If I get you right you are looking for some pointers, how to start your journey with rasa (If I not get you right apologies in advance)

Valuable links and resources for your reference

  1. RasaMasterclass
  2. Conversational AI with Rasa - Video Series [Latest]
  3. Rasa for Beginners
  4. Rasa Certification Workshop
  5. Rasa Advanced Custom Actions, Forms, & Responses Workshop
  6. Rasa Advanced Deployment Workshop
  7. Rasa Youtube Channel Please subscribe and hit the bell icon for notification.
  8. Rasa Github Mini Project
  9. Rasa Masterclass Handbook
  10. Hardcopy Book: Conversational AI with Rasa

I hope these links will help you to learn Rasa!

1 Like

Thanks, those are all great links I will explore them.

However, if you or anyone knows a specific pointer to a particular chapter or to a piece of example code to really hone in my reading, that would be great.

To recap: my urgent need is to quickly stand up a dialog state machine. There’s not free-text type in, it’s all multiple choice answers. A kind of hello world example.

Regardless, I am excited about the road ahead.

@Tester01 when you say “dialog state machine” what you actually mean by that? can you share some example like bot/user conversation?

1 Like

Sure, thanks @nik202 for asking for an example.

Here’s an example of what I mean by a “state machine” or a dialog based on a dialog tree.

Turn1

Sys: What kind of pizza do you want: (a) cheese (b) non-cheese

User: a

Turn2

Sys: Okay, cheese. Do you want it delivered? (c) yes (d) no (x) start over

User: d

Turn3

Sys: What time would you like to be ready by? (e) 7pm, (f) 8pm (g) 9pm (x) start over

User: f

Turn4

Sys: OK cheese pizza, ready by 8pm, to be picked up at our store. C U soon!

As you can see this is ridiculously basic. There is no real NL. The user can only reply to the multiple choice options given, i.e.

  • a or b in turn, 1.
  • c or d in turn 2.
  • e, f of g in turn 3.

In addition the user could in Turn 2 or 3 chose x which would cause the system to erase all the user’s answer and start at Turn1 and say “What kind of pizza do you…”

Further, there are only a few places the dialog tree can branch.

If the user chose ‘x’, then they would branch and go back to the beginning.

There is another branch not shown above. It occurs at Turn 2, i.e. when the system asks “Do you want it delivered?”…The above shows the branch of choosing d. However, if the user choose (c) (meaning “yes”) then we’d want one addition question to be asked, i.e. what is your address. That question, unlike the others would take free text as input. And lets assume for now it does not do any processing on that free text. So the user could put in “humpty dumpty” as their address and the system would blithely accept it. (-:

So, any pointers?

Should I use rules? Or stories? Or both? If stories, maybe the memoization policy is the one to use because it is so deterministic? Perhaps my solution is best cast as a case of Form Filling?

(Still casting about, only ankle deep in the documentation)

Is one of the examples at https://github.com/RasaHQ/rasa/tree/main/examples the best to start with?

I think I need to stop reading docs / watching videos now and download it and find some hello world example, run it, and then start tweaking it. Maybe that is the fastest path to victory.

But any hints pointers, things to focus on, things to avoid (for now), much appreciated.

Thanks! T

p.s. hopefully you can see how this is very much like this featured app Dialogue Virtual Clinic Chatbot | Rasa Showcase | Rasa

@nik202 I just got the bright idea to search the forum on “multiple choice”. I instantly found this answer of yours:

I think that is precisely what I need. Do you agree?

@Tester01 Yeps! You got my solution :wink: But, yes please go ahead and try some example or states, and for starting stories will be fine and later, when you use forms you can switch to rules.

@Tester01 Menu with numbers - #12 by nik202 or Hi everyone.....i have to design a conversation like nested one intent within another intent - #2 by nik202 check this also, It have 3 files, just you need to run :stuck_out_tongue: Good Luck!

Note: If you are using button based then it will be easy pesy task, do check and study the code first, how I used both button based and text based approach while using intents.

1 Like

Thanks, great stuff!

Welcome to the Forum, Testie!

I would just like to add something a little more advanced, but cleaner in my opinion.


You can have a form with buttons on each question.

Every button will have the same payload intent, but different entities.

'/inform{{"pizza":"cheese"}}'
'/inform{{"delivered":"no"}}'
'/inform{{"time":"8pm"}}'

The entity values specified in the payload will be saved in a slot of the same name for long-term memory (entities are for short-term memory, they get reset on every message).

Then, in the form, to branch off, you can have a dynamic form behavior to ask for a slot depending on a previous one.

To stop the form when the user presses x, its button payload would have to be a different intent. e.g., /cancel. In a rule and/or story, you can specify to deactivate the form by handling an unhappy path and execute a certain action if that intent was detected.

stories:
- story: User doesn't want to continue
  steps:
  - intent: request_restaurant
  - action: restaurant_form
  - active_loop: restaurant_form
  - intent: cancel
  - action: action_deactivate_loop
  - active_loop: null
  - action: utter_canceled

That certain action is a custom action that will reset all the slots.

- story: User doesn't want to continue
  steps:
  # etc...
  - active_loop: null
  - action: action_reset_slots

You can reset the slots by returning a list of SlotSet events which will each set its given slot to the value None. Alternatively, if you want to reset absolutely all slots, you can use the AllSlotsReset event.

return [SlotSet('pizza', None), SlotSet('delivered', None), SlotSet('time', None)]
return [AllSlotsReset()]

If you want the form to automatically restart after canceling, you can also return the FollowupAction event in the list of the custom action mentioned just above.

If you have your own frontend interface, you can even disable the text input when buttons are present to make sure the users will press the buttons and thus control their behavior.


I have done these in my project if you want something to look at (even though building your own project may be easier than understanding someone else’s :slight_smile:)

Nik’s approach is perfectly fine and easier though :slight_smile: I just feel this solution is cleaner and more scalable, even though harder to understand and set up. It all comes down to preferences!

1 Like

Thanks so much @ChrisRahme!!! I will bear it in mind. I think I’m gonna run with nik202’s first and then level up to yours.

1 Like