Flow Components
Flow components orchestrate complex multi-step workflows, providing a seamless user experience for multi-stage operations.
The SDK is still in it's early stages. A lot of breaking changes will potentially be introduced as development progresses
Table of Contents
- MultiStepFlow
- Type Definitions
- Available Steps
- Features
- Integration Patterns
- Styling & Customization
- Best Practices
MultiStepFlow
Configurable multi-step flow component for complex workflows like account creation, onboarding, and payment processes.
Web Component Usage
<alviere-multi-step-flow
config='{"steps":[{"type":"CREATE_CONSUMER_ACCOUNT","label":"Create Account"},{"type":"ADD_BANK_ACCOUNT","label":"Add Bank"}],"amount":100.50}'
jwt="your-jwt-token"
public-certificate="retrieved-public-certificate"
public-certificate-id="retrieved-public-certificate-id"
business-uuid="businessUuid"
amount="100.50"
debug="false">
</alviere-multi-step-flow>
Props
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
config |
FlowConfig |
Yes | - | FlowConfig object converted to JSON string |
jwt |
string |
Yes | - | JWT token for authentication |
public-certificate |
string |
Yes | - | Public Certificate used for encryption |
public-certificate-id |
string |
Yes | - | The version of the Public Certificate for version validation |
business-uuid |
string |
Yes | - | If a Business UUID matches the UUID inferred from JWT parse the component will trigger a "First Time Usage" flow |
debug |
boolean |
No | false |
Enable debug logging |
Note: showProgress, showNavigation, allowSkip, and allowBack are configured within the config object, not as separate props.
Events
| Event | Payload | Description |
|---|---|---|
stepcomplete |
{ stepIndex: number, stepType: string, result: any } |
Fired when a step is completed |
steperror |
{ stepIndex: number, stepType: string, error: Error } |
Fired when a step encounters an error |
complete |
{ stepResults: Record<number, any> } |
Fired when the entire flow is completed |
flowcomplete |
{ stepType: string, success: boolean, amount?: number } |
Fired when the flow is completed (alternative to complete) |
reset |
- | Fired when the flow is reset |
Event Handlers (Alternative to Event Listeners):
You can also use callback props instead of event listeners:
| Prop | Type | Description |
|---|---|---|
onflowcomplete |
(event: CustomEvent) => void |
Callback fired when flow is completed |
onstepcomplete |
(event: CustomEvent) => void |
Callback fired when a step is completed |
onsteperror |
(event: CustomEvent) => void |
Callback fired when a step encounters an error |
onreset |
(event: CustomEvent) => void |
Callback fired when the flow is reset |
Example Configurations
Complete Onboarding and Payment Flow
{
"steps": [
{
"type": "CREATE_ACCOUNT",
"label": "User Account"
},
{
"type": "ADD_BANK_ACCOUNT",
"label": "Add Bank Account"
},
{
"type": "CHECKOUT_CONFIRM",
"label": "Confirm Payment"
}
],
"amount": 100.50,
"showProgress": true,
"showNavigation": false,
"allowSkip": false,
"allowBack": false
}
Type Definitions
This section contains all TypeScript interfaces and type definitions used throughout the Flow Components.
FlowConfig
The main configuration object for the multi-step flow component.
interface FlowConfig {
steps: FlowStep[];
title?: string;
description?: string;
allowSkip?: boolean;
allowBack?: boolean;
showProgress?: boolean;
showNavigation?: boolean;
amount: number | string;
}
Properties:
steps- Array of flow steps to be executedtitle- Optional title for the flowdescription- Optional description textallowSkip- Whether users can skip optional stepsallowBack- Whether users can navigate back to previous stepsshowProgress- Whether to display the progress indicatorshowNavigation- Whether to show navigation controlsamount- The amount for payment transaction
FlowStep
Defines the structure of individual steps within a flow.
interface FlowStep {
type: StepType;
label: string;
status: StepStatus;
config?: Record<string, any>;
}
Properties:
type- The type of step (see Available Steps)label- Display label for the stepstatus- Current status of the stepconfig- Optional configuration object for the step
Step Types:
| Step Type | Component | Description |
|---|---|---|
CREATE_ACCOUNT |
CreateAccount | User account creation form (wrapper for consumer/business) |
CREATE_CONSUMER_ACCOUNT |
CreateConsumerAccount | Consumer account creation form |
CREATE_BUSINESS_ACCOUNT |
CreateBusinessAccount | Business account creation form |
ADD_BANK_ACCOUNT |
AddBankAccount | Bank account addition form |
CHECKOUT_CONFIRM |
CheckoutConfirm | Confirm payment step |
Step Status:
| Status | Description |
|---|---|
INCOMPLETE |
Step has not been started |
IN_PROGRESS |
Step is currently active |
COMPLETE |
Step has been completed successfully |
ERROR |
Step encountered an error |
CONSUMER_INFORMATION
Interface for consumer account information used in account creation steps.
The following required object is a configuration example. Specific project requirements need to be aligned with Alviere.
interface CONSUMER_INFORMATION {
consumer_information: {
first_name: string
middle_name?: string
last_name: string
date_of_birth?: string
ssn?: string
phone_number?: string
email_address: string
}
}
Properties:
first_name- Consumer's first name (required)middle_name- Consumer's middle name (optional)last_name- Consumer's last name (required)date_of_birth- Date of birth in YYYY-MM-DD format (optional)ssn- Full Social Security Number (optional)phone_number- International format (+1***) contact phone number (optional)email_address- Email address (required)
BUSINESS_INFORMATION
Interface for business account information used in business account creation steps.
The following required object is a configuration example. Specific project requirements need to be aligned with Alviere.
interface BUSINESS_INFORMATION {
business_information: {
business_type: string,
business_name: string,
doing_business_as?: string,
state_of_incorporation: string,
country_of_incorporation: string,
incorporation_date?: string,
ein?: string,
}
}
Properties:
business_type- Type of business entity (required)business_name- Legal business name (required)doing_business_as- DBA name if different from legal name (optional)state_of_incorporation- State where business is incorporated (required)country_of_incorporation- Country of incorporation (required)incorporation_date?- Date of incorporation in YYYY-MM-DD format (optional)ein?- Employer Identification Number (optional)
Available Steps
This section describes all available step types that can be used in a flow configuration.
CREATE_ACCOUNT
The create account step, is the first step on the onboarding flow. It consists of a wrapper around CREATE_CONSUMER_ACCOUNT and CREATE_BUSINESS_ACCOUNT forms, and it infers based on the config.formData it receives which of the two forms it will render. If no config is passed or is invalid, it will fallback to CREATE_CONSUMER_ACCOUNT.
Configuration:
{
formData: {
information: BUSINESS_INFORMATION | CONSUMER_INFORMATION,
primary_address?: ADDRESS
}
}
The step determines which form to display based on the structure of the information object. See CONSUMER_INFORMATION and BUSINESS_INFORMATION for details.
CREATE_CONSUMER_ACCOUNT
The create consumer account step will render the create consumer form and handle its state.
Configuration: Uses the CONSUMER_INFORMATION interface.
CREATE_BUSINESS_ACCOUNT
The create business account step will render the create business form and handle its state.
Configuration: Uses the BUSINESS_INFORMATION interface.
ADD_BANK_ACCOUNT
Bank account addition step for linking financial accounts to the user's profile.
CHECKOUT_CONFIRM
Confirmation step for payment and checkout processes. Requires an amount to be specified in the flow configuration.
Features
Progress Tracking
- Visual Progress Bar: Shows completion percentage
- Step Indicators: Clear indication of current step
- Status Display: Shows status of each step
- Completion Tracking: Tracks overall flow progress
Navigation Controls
- Next Button: Advances to next step when current step is complete
- Previous Button: Returns to previous step (if allowed)
- Skip Option: Skip optional steps (if configured)
- Flow Control: Automatic progression based on step completion
Step Management
- Dynamic Rendering: Renders appropriate component for each step
- State Persistence: Maintains step state across navigation
- Result Aggregation: Collects results from all completed steps
- Error Handling: Graceful error handling and recovery
User Experience
- Responsive Design: Works on all device sizes
- Accessibility: Full ARIA support and keyboard navigation
- Loading States: Visual feedback during step transitions
- Error Recovery: Clear error messages and recovery options
Integration Patterns
Event-Driven Architecture
The MultiStepFlow component emits events that can be used to integrate with external systems:
const flow = document.querySelector('alviere-multi-step-flow');
flow.addEventListener('stepcomplete', (event) => {
const { stepIndex, stepType, result } = event.detail;
// Update external systems
updateProgress(stepIndex, stepType);
saveStepResult(stepIndex, result);
// Trigger external workflows
if (stepType === 'CREATE_CONSUMER_ACCOUNT') {
triggerAccountVerification(result);
}
});
flow.addEventListener('complete', (event) => {
const { stepResults } = event.detail;
// Process complete flow results
processOnboardingComplete(stepResults);
// Navigate to next page
window.location.href = '/dashboard';
});
flow.addEventListener('flowcomplete', (event) => {
const { stepType, success, amount } = event.detail;
// Handle flow completion
if (success) {
console.log(`Flow completed successfully with amount: ${amount}`);
}
});
flow.addEventListener('reset', () => {
// Handle flow reset
console.log('Flow has been reset');
});
Custom Step Configuration
Steps can accept additional configuration for customization:
{
"steps": [
{
"type": "CREATE_ACCOUNT",
"label": "Create Account",
"status": "INCOMPLETE",
"config": {
"formData": {...AccountData}
}
}
]
}
Flow State Management
The component maintains internal state that can be accessed:
// Get current flow state
const currentStep = flow.getAttribute('data-current-step');
const completedSteps = flow.getAttribute('data-completed-steps');
// Check if flow is complete
const isComplete = flow.hasAttribute('data-complete');
Styling & Customization
CSS Custom Properties
The component uses CSS custom properties for theming:
.alviere-multi-step-flow {
--primary-color: #007bff;
--success-color: #28a745;
--error-color: #dc3545;
--warning-color: #ffc107;
--border-radius: 8px;
--step-spacing: 2rem;
}
Component-Specific Styling
Individual step components can be styled:
/* Style the create account step */
.alviere-multi-step-flow .alviere-create-consumer-account {
--form-background: #f8f9fa;
--border-color: #dee2e6;
}
/* Style the bank account step */
.alviere-multi-step-flow .alviere-add-bank-account {
--form-background: #ffffff;
--border-color: #ced4da;
}
Best Practices
Flow Design
- Keep steps focused: Each step should have a single, clear purpose
- Logical progression: Steps should follow a logical order
- Clear labels: Use descriptive labels for each step
- Progress indication: Always show progress to keep users informed
Error Handling
- Graceful degradation: Handle errors without breaking the flow
- Clear messaging: Provide clear error messages and recovery options
- Retry mechanisms: Allow users to retry failed steps
- Fallback options: Provide alternative paths when possible
Performance
- Lazy loading: Load step components only when needed
- State management: Efficiently manage step state and transitions
- Memory management: Clean up resources when steps are completed
- Optimization: Minimize re-renders and unnecessary updates