Dialogflow CX Tutorial (1/14): What is a state machine?

Course outline


All right.

So in this set of slides I’m going to explain what a state machine is.

And as I start the first thing that I would like to point out is if you go to the Dialogflow CX documentation page you will notice that the first thing it starts with is it says Dialogflow CX provides a new way of designing agents taking a state machine approach to agent design.

So what is the state machine it’s a concept from computer science.

And if you go to.

Let’s say if you go to Wikipedia you can see that unfortunately this is a very complex explanation.

And I would not call it the most simple explanation for the state machine there’s no need for the definition to get this complex.

Although a good thing is that the state machine definition does talk about this vending machine and.

I think that that’s probably the simplest [m1] definition that you can have for a state machine.

So the vending machine is a good example of a state machine because it goes from state to state depending on how much money you have added into it so depending on the state that is the balance that you have in your the in the coins that you have added to the vending machine you can actually choose different products.

And depending on the state that is the balance you will get a different amount of money back from the machine if.

Let’s say the product that you pay the product that you selected is less than the amount that you paid.

So I’m going to take a simple example here.

Let’s say that you start with zero balance okay that is one state that is the state the vending machine is in the state of zero balance.

And you add 25 cents or a quarter right at that point the balance has now [m2] become 25 cents that is the new state the new state is where the balance in the vending machine is 25 cents you add one more quarter and.

Now, the state has become 50 cents that is the balance of the amount in the vending machine is now 50 cents.

And then you add another quarter it gets to 75 cents.

And so on now let’s make it a bit more useful.

And interesting.

Let’s say that you have exactly three products in your vending machine okay.

And those are Snickers bar which costs exactly 25 cents you can have a Twix which is exactly 50 cents or a Kitkat which costs exactly 75 cents so you start with the zero balance.

And then you insert a quarter into the vending machine now at that point because you only have a balance of [m3] 25 cents the only product that you can buy is the Snickers bar if you were to select any of the other products as you might know the vending machine will usually complain that you don’t have enough balance to buy any other product at least any other products in this list.

And then Let’s say you add one more 25 cents now you can select either Snickers or Twix.

And if you were to select sneakers.

And you asked for the refund you will get 25 cents back.

On the other hand, if you select twigs that means your balance has now come down to zero which means that you don’t get any money back if you are to ask for a refund it will just say that it’s empty balance or something like that.

And finally if you were to add one more quarter at that point you can select any of these three items so you can either go for the Snickers or the Twix or the Kitkat and.

In fact, you can even go for one Snickers.

And then one Twix.

And the [m4] vending machine should still be able to handle that because the sum of these two is only 75 cents which you do have in that balance so that’s the basic example of a vending machine and.

I think that understanding this is sufficient for you to understand how the agents are constructed in Dialogflow CX I don’t think from what I’ve seen till now I don’t think that you need to complicate this any further than just understanding a basic state machine like the vending machine example that I have shown here

<— End of article —>

This website contains affiliate links. See the disclosure page for more details. 
Check out the Learn Dialogflow ES and Learn Dialogflow CX courses if you would like to learn Dialogflow in depth.
"The magic key I needed as a non-programmer"

The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn.

- Kathleen R
Cofounder, gathrHealth