Skip to content

Smart Flows Session

Session

Smart Flow Session Module

Manages session persistence and state management, handling CRUD operations for sessions, flows, and component states

Session.create() ⇒ Promise\<SessionCreateResult>

Creates or updates a Smart Flow session

Returns: Promise\<SessionCreateResult> - Object containing the session and metadata

Session.get() ⇒ Promise\<FlowSessionTable>

Retrieves the current session or creates a new one

Returns: Promise\<FlowSessionTable> - The current session
Throws:

  • Error If session retrieval fails

Session.getComponent(flowId, component) ⇒ Promise\<FlowComponentTable>

Retrieves a component's state from the database

Returns: Promise\<FlowComponentTable> - The component's session data

Param Type Description
flowId number The ID of the flow
component SmartFlowComponent The component to retrieve

Session.getFlow(flowId) ⇒ Promise\<FlowTable>

Retrieves or initializes a flow

Returns: Promise\<FlowTable> - The flow data

Param Type Description
flowId number The ID of the flow

Session.getSessionActivity() ⇒ Promise\<{activeTime: number, lastActive: number, isReturningUser: boolean}>

Retrieves the current session activity metrics with recalculation

Returns: Promise\<{activeTime: number, lastActive: number, isReturningUser: boolean}> - Session activity data

Session.init() ⇒ Promise\<SmartFlowSessionModule>

Initializes the Smart Flow session and calculates user activity metrics

Returns: Promise\<SmartFlowSessionModule> - The initialized Session module

Session.remove([excludeId]) ⇒ Promise\<void>

Removes session(s) from the database

Param Type Description
[excludeId] string Optional ID of session to exclude from deletion

Session.removeComponent(flowId, component) ⇒ Promise\<void>

Removes a component from the database

Param Type Description
flowId number The ID of the flow
component SmartFlowComponent The component to remove

Session.removeFlow(flowId) ⇒ Promise\<void>

Removes a flow and its components from the database

Param Type Description
flowId number The ID of the flow to remove

Session.save(session) ⇒ Promise\<FlowSessionTable>

Saves session changes to the database

Returns: Promise\<FlowSessionTable> - The updated session

Param Type Description
session FlowSessionTable The session to save

Session.saveComponent(flowId, component, state) ⇒ Promise\<FlowComponentTable>

Saves component state changes to the database

Returns: Promise\<FlowComponentTable> - The updated component session
Throws:

  • Error If flowId or component.id is invalid
Param Type Description
flowId number The ID of the flow
component SmartFlowComponent The component to update
state object The state changes to save

Session.saveFlow(flowId, state) ⇒ Promise\<FlowTable>

Saves flow state changes to the database

Returns: Promise\<FlowTable> - The updated flow

Param Type Description
flowId number The ID of the flow
state Partial\<FlowTable> The state changes to save

Session.update([session]) ⇒ Promise\<FlowSessionTable>

Updates an existing session or creates a new one

Returns: Promise\<FlowSessionTable> - The updated or new session

Param Type Description
[session] FlowSessionTable Optional session to update

SessionCreateResult : Array

Tuple containing the session and associated metadata

Properties

Name Type Description
session FlowSessionTable The session object
meta FlowSessionMeta The session metadata