Session is data model for storing a conversation state between user and bot. Session is uniquely defined by:
- userId / partnerId
Session has unlimited lifetime, which means, whenever you are accessing the same bot with the same messenger account, the conversation state will be saved. However there are possibility to expire information, such as expiring flow etc.
A Session consists of following fields:
id- session id
deploymentId- deployment id of the session
dataKey- key to connect multiple session data
states- states of open flows
contexes- contexes of the open flows
history- stack of open flows ordered by last opened
meta- additional information such as lastState and lastFlow
timestamp- time of last update
createdAt- time of session creation
data- persistent data
Context is a flow specific information that lives only during the lifetime of a flow. It will be cleared whenever the flow is closed. A session stores the context of every open flow. Data is a flow-agnostic persistent storage. It is accessible from every flow and doesn’t have a lifetime.
There are cases when data from multiple session need to be shared. E.g. user using multiple messaging apps. To link data, you can specify the dataKey. This way multiple session will shares the same data.
Contributing to the Documentation
Is something missing/incorrect? Please let us know by contacting firstname.lastname@example.org. If you know how to fix it straight away, don’t hesitate to create a pull request on this documentation’s GitHub repository.