transition#
- class besser.bot.core.transition.Transition(name, source, dest, event, event_params)[source]#
Bases:
object
A bot transition from one state (source) to another (destination).
A transition is triggered when an event occurs.
- Parameters:
name (str) – the transition name
source (State) – the source state of the transition (from where it is triggered)
dest (State) – the destination state of the transition (where the bot moves to)
event (Callable[[Session, dict], bool]) – the event that triggers the transition
event_params (dict) – the parameters associated to the event
- is_auto()[source]#
Check if the transition event is auto (i.e. a transition that does not need any event to be triggered).
- Returns:
true if the transition’s intent matches with the target one, false
- Return type:
- is_event_true(session)[source]#
Given a session, returns true if the event associated to the transition returns true, and false otherwise. (Applicable to any event)
- is_intent_matched(session)[source]#
For intent-matching transitions, check if the predicted intent (stored in the given session) matches with the transition’s expected intent (stored in the transition event parameters).
If the transition event is not intent_matched, return false.
- is_variable_matching_operation(session)[source]#
For session-value-comparison transitions, check if the given operation on a stored session value and a given target value (stored in the transition event parameters) returns true.
If the transition event is not variable_matches_operation, return false.