What is a state machine?

(Autogenerated transcript)

 Alright, so in this set of slides I am 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 a 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 you to get for the definition to get this complex. So a good thing is that the state machine definition does talk about this vending machine and I think that that's probably the simplest 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 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 pay. 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 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 a 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 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 Snickers and you ask for the refund you will get 25 cents back. On the other hand if you select Twix that means your balance has now come down to zero which means that you don't get any money back if you were 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 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.

About this website

BotFlo1 was created by Aravind Mohanoor as a website which provided training and tools for non-programmers who were2 building Dialogflow chatbots.

This website has now expanded into other topics in Natural Language Processing, including the recent Large Language Models (GPT etc.) with a special focus on helping non-programmers identify and use the right tool for their specific NLP task. 

For example, when not to use GPT

1 BotFlo was previously called MiningBusinessData. That is why you see that name in many videos

2 And still are building Dialogflow chatbots. Dialogflow ES first evolved into Dialogflow CX, and Dialogflow CX itself evolved to add Generative AI features in mid-2023