session#
- class besser.bot.core.session.Session(session_id, bot, platform)[source]#
Bases:
object
A user session in a bot execution.
When a user starts interacting with a bot, a session is assigned to him/her to store user related information, such as the current state of the bot, the conversation history, the detected intent with its parameters or any user’s private data. A session can be accessed from the body of the states to read/write user information.
- Parameters:
- _file#
File or None: The last file sent to the bot.
- flags#
A dictionary of boolean flags. A predicted_intent flag is set to true when an intent is received. When the evaluation of the current state’s transitions is done, the flag is set to false. It may happen that a transition different from the one associated with this intent is triggered (e.g. one evaluating some condition). In the following state, if there is a transition associated with the same intent, it should not be triggered as the time for this intent passed (unless the same intent is detected, in such case the flag will be set to true again). Another flag file_flag is used for the same purpose but for files sent by the user
- delete(key)[source]#
Delete an entry of the session private data storage.
- Parameters:
key (str) – the entry key
- get(key)[source]#
Get an entry of the session private data storage.
- Parameters:
key (str) – the entry key
- Returns:
the entry value, or None if the key does not exist
- Return type:
Any
- move(transition)[source]#
Move to another bot state.
- Parameters:
transition (Transition) – the transition that points to the bot state to move