Flows

Basic flow syntax and logic.

Flows are written using YAML syntax, which looks like this:

323

A basic flow.

Let's go through the code line by line.

states is another required keyword. It tells Meya that what follows is the sequence of states (i.e. actions) the bot should perform.

You can name your states any combination of alphanumeric characters, but they must be unique within the flow. In the above example, the initial state has been called first, and the second has been called get_name.

🚧

Indentation matters!

Note the indentation in this flow example. Your flow won't work if improperly indented.

component: tells your bot which type of action to perform. In this case, the bot will use the built-in meya.text component to display text to the user.

Some components have properties that can be set. Properties may be required or optional (refer to the component's documentation).

The meya.text component only has one property to set: text.

📘

The action property

There is a hidden property here, too: action. action tells your bot which state (i.e. action) to perform after this one. By default, action is set to next, meaning your bot will simply move on to the next state in the flow in a linear fashion. Just be aware you can explicitly set action to jump to different states. Some components require you to set action to some value, but in this example it is optional.

get_name is the name of the second state. The next line indicates it uses the meya.input_string component to get input from the user. This component has three properties that can be set: text, output, and scope.

Summary

This example has provided a basic overview of flows, their general structure, states, components, and component properties. For a more detailed look at the types of components available, and their properties, refer to the Components documentation.


What’s Next

Now that you know how flows work, let's take a look at how they are triggered.