Flow Example: Customer Onboarding
This complete example demonstrates how different flow steps work together in a real-world scenario.
Scenario
When a new customer is created, we need to:
- Retrieve the customer details
- Set up their account based on their tier (Premium vs Standard)
- Calculate contract dates
- Create a contract record
- Send welcome emails to all contacts
- Publish an event for other systems
Flow Definition
Flow Name: OnboardNewCustomer
Description: When a new customer is created, set up their account with default settings, create related records, and send a welcome email.
Inputs:
| Name | Type | Required | Description |
|---|---|---|---|
| CustomerId | Entity Reference (Account) | Yes | The new customer record |
Outputs:
| Name | Type | Description |
|---|---|---|
| Success | Boolean | Whether onboarding completed successfully |
| ContractId | Entity Reference | The created contract record |
| ContactsNotified | Integer | Number of contacts who received welcome emails |
Flow Steps
┌─────────────────────────────────────────────────────────────────┐
│ STEP 1: GET ENTITY BY ID │
│ ─────────────────────────────────────────────────────────────── │
│ Entity: Account │
│ Entity ID: CustomerId │
│ → Store in variable: Customer │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 2: CONDITION - Is Premium Customer? │
│ ─────────────────────────────────────────────────────────────── │
│ Condition: Customer.CustomerTier == "Premium" │
└─────────────────────────────────────────────────────────────────┘
│ │
┌───────┘ └───────┐
│ TRUE │ FALSE
▼ ▼
┌───────────────────────────┐ ┌───────────────────────────┐
│ STEP 3a: NEW VARIABLE │ │ STEP 3b: NEW VARIABLE │
│ ───────────────────────── │ │ ───────────────────────── │
│ Name: WelcomeTemplate │ │ Name: WelcomeTemplate │
│ Value: "premium-welcome" │ │ Value: "standard-welcome" │
└───────────────────────────┘ └───────────────────────────┘
│ │
▼ │
┌───────────────────────────┐ │
│ STEP 4a: SAVE ENTITY │ │
│ ───────────────────────── │ │
│ Entity: Task │ │
│ Data: { │ │
│ Subject: "Schedule │ │
│ onboarding call", │ │
│ Regarding: Customer, │ │
│ Owner: Customer. │ │
│ AccountManager │ │
│ } │ │
└───────────────────────────┘ │
│ │
└─────────────┬─────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 5: RUN LOGIC BLOCK │
│ ─────────────────────────────────────────────────────────────── │
│ Block: CalculateContractDates │
│ Inputs: { │
│ StartDate: TODAY(), │
│ Tier: Customer.CustomerTier │
│ } │
│ → Store outputs in: ContractDates │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 6: SAVE ENTITY │
│ ─────────────────────────────────────────────────────────────── │
│ Entity: Contract │
│ Data: { │
│ Customer: Customer, │
│ StartDate: ContractDates.StartDate, │
│ EndDate: ContractDates.EndDate, │
│ Status: "Active" │
│ } │
│ → Store in variable: NewContract │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 7: EXECUTE QUERY │
│ ─────────────────────────────────────────────────────────────── │
│ Entity: Contact │
│ Multiplicity: Multiple │
│ Filter: ParentCustomerId == Customer.Id │
│ → Store in variable: CustomerContacts │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 8: NEW VARIABLE │
│ ─────────────────────────────────────────────────────────────── │
│ Name: EmailsSent │
│ Type: Integer │
│ Initial Value: 0 │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 9: ITERATOR - For each Contact │
│ ─────────────────────────────────────────────────────────────── │
│ Collection: CustomerContacts │
│ Item Variable: Contact │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ STEP 9a: SAVE ENTITY │ │
│ │ ─────────────────────────────────────────────────────── │ │
│ │ Entity: Email │ │
│ │ Data: { │ │
│ │ To: Contact, │ │
│ │ Subject: "Welcome to Our Service", │ │
│ │ Body: GetEmailTemplate(WelcomeTemplate), │ │
│ │ Regarding: Customer │ │
│ │ } │ │
│ │ → Store in: WelcomeEmail │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ STEP 9b: SEND EMAIL │ │
│ │ ─────────────────────────────────────────────────────── │ │
│ │ Email ID: WelcomeEmail.Id │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ STEP 9c: UPDATE VARIABLE │ │
│ │ ─────────────────────────────────────────────────────── │ │
│ │ Variable: EmailsSent │ │
│ │ Set Variable: EmailsSent + 1 │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 10: PUBLISH EVENT │
│ ─────────────────────────────────────────────────────────────── │
│ Event: CustomerOnboarded │
│ Payload: { │
│ CustomerId: Customer.Id, │
│ ContractId: NewContract.Id, │
│ Tier: Customer.CustomerTier, │
│ ContactsNotified: EmailsSent │
│ } │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ STEP 11: SET OUTPUT │
│ ─────────────────────────────────────────────────────────────── │
│ Output Bindings: │
│ Success: true │
│ ContractId: NewContract.Id │
│ ContactsNotified: EmailsSent │
└─────────────────────────────────────────────────────────────────┘
Step Categories Used
This flow demonstrates all major step categories:
| Category | Steps Used |
|---|---|
| Data Operations | Get Entity by ID (Step 1), Save Entity (Steps 4a, 6, 9a), Execute Query (Step 7) |
| Flow Control | Condition (Step 2), Iterator (Step 9) |
| Variables | New Variable (Steps 3a/3b, 8), Update Variable (Step 9c) |
| Integration | Send Email (Step 9b) |
| Invocation | Run Logic Block (Step 5) |
| Events | Publish Event (Step 10) |
| Output | Set Output (Step 11) |
Key Design Patterns
Conditional Setup
Steps 2-4 show how to handle different paths based on customer tier. Premium customers get a scheduled onboarding call; standard customers proceed directly.
Reusable Logic
Step 5 calls a Logic Block to calculate contract dates. This keeps date calculation logic separate and reusable.
Iterating Over Related Records
Steps 7-9 retrieve all contacts and send each one a personalized email. The iterator handles any number of contacts.
Event Publishing
Step 10 publishes an event so other systems can react to the onboarding completion without being directly coupled to this flow.
Clean Output
Step 11 sets clear outputs so callers know exactly what happened: success status, the contract created, and how many contacts were notified.