| 1 |
Flows Concepts |
| 2 |
============== |
| 3 |
|
| 4 |
Static structure |
| 5 |
---------------- |
| 6 |
|
| 7 |
Flows are represented as graphs. Those graphs have a root (FlowRoot), which is basically their entry point, and |
| 8 |
are composed of nodes (FlowNodes). Every node represents an Errbot command. |
| 9 |
|
| 10 |
.. figure:: concept.svg |
| 11 |
:align: center |
| 12 |
|
| 13 |
Example of a flow construction. |
| 14 |
|
| 15 |
|
| 16 |
This defines a simple flow where for example this sequence of commands is possible:: |
| 17 |
|
| 18 |
!command1 !command2 !command3 !command1 !command2 !command3 !last_command |
| 19 |
|
| 20 |
On the connections of those nodes (⟶), you can attach **predicates**, predicates are simple conditions to allow |
| 21 |
the flow to continue without any user intervention. |
| 22 |
|
| 23 |
Execution |
| 24 |
--------- |
| 25 |
|
| 26 |
At execution time, Errbot will keep track of who started the flow, and at what step (node) it is currently. |
| 27 |
On top of that, Errbot will initialize a context for the entire conversation. The context is a simple Python dictionary |
| 28 |
and it is attached to only one conversation. Think of this like the persistence for plugins, but linked to |
| 29 |
a conversation only. |
| 30 |
|
| 31 |
If you don't specify any predicate when you build your flow, every single step is "manual". It means that Errbot will |
| 32 |
wait for the user to execute one of the possible commands at every step to advance along the graph. |
| 33 |
|
| 34 |
Predicates can be used to trigger a command automatically. Predicates are simple functions saying to Errbot, |
| 35 |
"this command has enough in the context to be able to execute without any user intervention". |
| 36 |
At any time if a predicate is verified after a step is executed, Errbot will proceed and execute the next step. |