Smart Flows Methods
Overview¶
Smart Flows enables merchants to create dynamic, rule-based customer engagement experiences. Build automated flows that trigger popups, website banners, discounts, and product recommendations based on user behavior, cart state, and other conditions.
Key Features¶
- Rule-based triggers - Show content based on cart value, user type, date ranges, and more
- Multiple component types - Popups, website banners, redirects, Buy X Get Y offers
- Session persistence - Track user interactions across page loads using IndexedDB
- Link-based flows - Trigger flows via URL parameters for marketing campaigns
- Preview mode - Test flows in the admin before going live
Quick Start¶
Smart Flows initializes automatically when configured in your Rebuy dashboard. For programmatic access:
// Check if Smart Flows is ready
if (Rebuy.SmartFlows.status === 'ready') {
// Get all available flows
const flows = Rebuy.SmartFlows.getFlows();
console.log('Available flows:', flows);
}
// Listen for Smart Flows to be ready
document.addEventListener('rebuy:smartflows.ready', (event) => {
console.log('Smart Flows initialized');
});
Load a Flow by Short Code¶
Flows can be loaded dynamically using their short code:
// Add a flow by its short code (useful for marketing links)
const flow = await Rebuy.SmartFlows.addFlowByCode('SUMMER2026');
if (flow) {
console.log('Flow loaded:', flow.name);
// Process the flow
Rebuy.SmartFlows.processFlows();
}
Check Session Activity¶
Access user session data to understand engagement:
// Get session activity metrics
const activity = await Rebuy.SmartFlows.session.getSessionActivity();
console.log('Active time:', activity.activeTime, 'ms');
console.log('Is returning user:', activity.isReturningUser);
Methods Reference¶
Access the Smart Flows module via window.Rebuy.SmartFlows.
SmartFlows.initialized : boolean¶
Smart Flows module initialization flag
SmartFlows.session : SmartFlowSession¶
Smart Flow Session module for session persistence and state management
SmartFlows.status : SmartFlowsStatus¶
Smart Flows module status. Helps determine when flows are ready to be processed.
'initializing' | 'redirecting' | 'ready'
SmartFlows.addFlow(flow) ⇒ void¶
Add a new Smart Flow
| Param | Type | Description |
|---|---|---|
| flow | SmartFlow |
Smart Flow to add |
SmartFlows.addFlowByCode(shortCode) ⇒ Promise<(SmartFlow|void)>¶
Add a new Smart Flow via shortCode
| Param | Type | Description |
|---|---|---|
| shortCode | string |
Smart Flow shortCode |
SmartFlows.getActiveGlobalFlow() ⇒ SmartFlow | undefined¶
Get the currently active global flow
SmartFlows.getFlowById(flowId) ⇒ SmartFlow | undefined¶
Find a Smart Flow by ID
| Param | Type | Description |
|---|---|---|
| flowId | number |
Smart Flow ID |
SmartFlows.getFlowByShortCode(shortCode) ⇒ SmartFlow | undefined¶
Find a Smart Flow by short code
| Param | Type | Description |
|---|---|---|
| shortCode | string |
Smart Flow shortCode |
SmartFlows.getFlows() ⇒ Array<SmartFlow>¶
Get a list of available flows
NOTE: Useful for filtering or lookups by ID / shortCode
SmartFlows.getPreviewFlow() ⇒ SmartFlow | undefined¶
Get the flow currently being previewed
SmartFlows.goToModalPage(componentId, pageNumber) ⇒ boolean¶
Navigate to a specific page in a modal for a given component ID
Returns: boolean - True if successful, false otherwise
| Param | Type | Description |
|---|---|---|
| componentId | string |
The ID of the component containing the modal |
| pageNumber | number |
The page number to navigate to (1-based) |
SmartFlows.goToModalProduct(componentId, productId) ⇒ boolean¶
Navigate to a specific product page in a modal for a given component ID
Returns: boolean - True if successful, false otherwise
| Param | Type | Description |
|---|---|---|
| componentId | string |
The ID of the component containing the modal |
| productId | string |
The product ID to navigate to |
SmartFlows.handleLinkBasedFlow() ⇒ Promise<void>¶
Handle link-based Smart Flow initialization
SmartFlows.init(flows) ⇒ SmartFlowsModule¶
Smart Flow module initialization
| Param | Type | Description |
|---|---|---|
| flows | Array<SmartFlow> |
Array of Smart Flows to initialize |
SmartFlows.processFlows() ⇒ void¶
Process all available Smart Flows
SmartFlows.removeFlow(flowId) ⇒ void¶
Removes a flow + cleans up associated component observers
| Param | Type | Description |
|---|---|---|
| flowId | number |
The ID of the flow to remove |
SmartFlows.runComponent(component, flow) ⇒ void¶
Executes a specific Smart Flow component
| Param | Type | Description |
|---|---|---|
| component | SmartFlowComponent |
Execute a component in the Smart Flow tree |
| flow | SmartFlow |
Smart Flow being ran |
SmartFlows.runFlow(flow) ⇒ void¶
Run a given Smart Flow, traversing its tree and rendering the first components
| Param | Type | Description |
|---|---|---|
| flow | SmartFlow |
Smart Flow to run |
SmartFlows.setFlows(flows) ⇒ void¶
Apply the Smart Flows to make available
| Param | Type | Description |
|---|---|---|
| flows | Array<SmartFlow> |
Array of Smart Flows |
SmartFlows.sync() ⇒ void¶
Sync the active UI component state
Related¶
- Smart Flows Session - Session persistence and state management