X
X
Xip
Search…
FlowMap
The FlowMap is the file that contains your flow and state declarations. It's stored in config/flow_map.rb and will be generated by Xip when you instantiate your bot.
Here is a FlowMap similar to the one that is generated for a new bot:
1
class FlowMap
2
3
include Xip::Flow
4
5
flow :hello do
6
state :say_hello
7
state :get_hello_response, fails_to: :say_hello
8
end
9
10
flow :goodbye do
11
state :say_goodbye
12
end
13
14
flow :interrupt do
15
state :say_interrupted
16
end
17
18
flow :unrecognized_message do
19
state :handle_unrecognized_message
20
end
21
22
flow :catch_all do
23
state :level1
24
end
25
26
end
Copied!
In this example, we've declared five flows: hello, goodbye, interrupt, unrecognized_message, and catch_all. These are the default flows that are generated for you when you create a new bot.
Each flow consists of an arbitrary number of states. All of the above flows only have a single state, but the hello flow has two. As you build out your bot and add functionality, you'll need to keep the FlowMap updated. If you attempt to transition to a flow or state that hasn't yet been declared in the FlowMap, you'll encounter a Xip::Errors::InvalidStateTransition exception.
States also support additional options like the fails_to option for the get_hello_response state. We'll cover these state options in the State Option docs section.
Last modified 9mo ago
Copy link