Examples
Real-world business rules written in Flow. Each example is a complete, runnable .flow file — the rule and the executable are the same artifact.
Available examples
Transaction Fraud
Real-time fraud decisioning that combines AI risk scoring, rule-based screening, velocity checks, and human escalation into a single workflow.
step DecisionEngine:
set ai-score to ai-confidence times 100 rounded to 0
set combined-score to rule-score plus ai-score divided by 2 rounded to 0
if combined-score is above 75:
set decision to "block"
otherwise if combined-score is above 40:
set decision to "review"
otherwise:
set decision to "approve"Payment Reconciliation
Compares ledger records against payment processor settlements. Loops through settlements to calculate running totals, detects mismatches, and uses AI to analyze discrepancies.
step CalculateTotals:
set settlement-total to 0
set settlement-count to 0
for each settlement in settlements:
set settlement-total to settlement-total plus settlement.amount
set settlement-count to settlement-count plus 1
step CompareResults:
set total-difference to ledger-total minus settlement-total
if total-difference is not 0:
set has-mismatch to trueChargeback Dispute
Gathers evidence from multiple sources, asks AI for a dispute recommendation, then uses string matching to decide whether to contest or accept.
step BuildResponse:
ask CaseBuilder to "analyze this chargeback dispute..."
save the result as recommendation
save the confidence as recommendation-confidence
if recommendation-confidence is below 0.5:
set action to "escalate"
otherwise if recommendation contains "contest":
set action to "contest"
otherwise:
set action to "accept"Email Verification
Validates an email address submitted through a form. Demonstrates service calls, conditionals, and completion/rejection.
verify email using EmailVerifier with address email
if email is not empty:
complete with status "verified"
otherwise:
reject with "The email address could not be verified"Order Processing
Processes a new order: checks inventory, calculates totals with tax, charges payment with retry logic, and generates an AI confirmation message.
step CalculateTotal:
set subtotal to order.subtotal
set tax to subtotal times 0.08
set total to subtotal plus taxGitHub Scout
Fetches a GitHub user profile from the public API and evaluates their popularity and activity level. Works with real data — no API key needed.
get profile using GitHub at "/users/{request.username}"
save the result as profile
set followers to profile.followers
if followers is above 1000:
set popularity to "star"Stripe Checkout
Processes a payment through Stripe's API with authenticated headers, status checking, retry logic, and Slack notification.
services:
Stripe is an API at "https://api.stripe.com/v1"
with headers:
Authorization: "Bearer {env.STRIPE_SECRET_KEY}"
step CreateCharge:
create charge using Stripe with amount amount and currency currency
save the result as charge
save the status as status-code
on failure:
retry 3 times waiting 5 secondsSlack Notification
Sends a formatted deployment notification to Slack with conditional message building based on deploy status.
step BuildMessage:
if deploy-status is "success":
set message to "Deployed {service-name} v{version} successfully"
otherwise if deploy-status is "rollback":
set message to "Rolled back {service-name} to v{version}"
otherwise:
set message to "Deployment of {service-name} v{version} failed"SendGrid Email
Sends a transactional email through SendGrid with authentication, input validation, and delivery status verification.
services:
SendGrid is an API at "https://api.sendgrid.com/v3"
with headers:
Authorization: "Bearer {env.SENDGRID_API_KEY}"
Content-Type: "application/json"
step SendEmail:
send email using SendGrid at "/mail/send" with to recipient and subject subject
save the status as status-codeInventory Lookup
Queries a SQLite database to check product stock levels using the database connector. Demonstrates table-mode queries, empty checks, and conditional logic.
services:
DB is a database at "./inventory.sqlite"
step CheckProduct:
get product using DB at "products" with id request.product-id
save the result as product
if product is empty:
reject with "Product not found"Customer Database
Queries a PostgreSQL database to look up a customer, aggregates their order history, and classifies them into a loyalty tier based on total spending.
services:
DB is a database at "postgresql://localhost:5432/customers"
step GetOrderHistory:
list orders using DB at "orders" with customer_id customer-id
save the result as orders
set total-spent to 0
for each order in orders:
set total-spent to total-spent plus order.amountDaily Sales Report
Aggregates daily sales from a database, calculates revenue metrics, evaluates performance against targets, and sends a summary to Slack. Designed to run on a schedule.
step CalculateMetrics:
if order-count is above 0:
set average-order to total-revenue divided by order-count
step EvaluatePerformance:
if total-revenue is above 50000:
set performance to "exceptional"
otherwise if total-revenue is above 25000:
set performance to "strong"flow schedule examples/daily-sales-report.flow --every "day at 18:00" --mockSLA Monitor
Checks the health of critical services and alerts via PagerDuty when any are down. Designed to run every few minutes on a schedule.
step CheckPaymentAPI:
get health using PaymentAPI at "/health"
save the status as payment-status
on failure:
retry 2 times waiting 3 seconds
if still failing:
set payment-status to 0
if payment-status is not 200:
set failed-services to failed-services plus 1
log "ALERT: PaymentAPI is not responding"flow schedule examples/sla-monitor.flow --every "5 minutes" --mock --verboseRunning examples
With mock services
flow test examples/email-verification.flow --dry-run --verboseWith real APIs
The GitHub Scout example works with real data:
flow run examples/github-scout.flow --input '{"username": "torvalds"}'As webhooks
Serve all examples as HTTP endpoints:
flow serve examples/ --mock --port 3000Then trigger any workflow:
curl -X POST http://localhost:3000/github-scout \
-H "Content-Type: application/json" \
-d '{"username": "octocat"}'Creating your own
Every Flow file follows the same structure:
config:
name: "My Workflow"
version: 1
services:
# Declare your services here
workflow:
trigger: when something happens
# Your logic here
complete with result dataSee the Getting Started guide to create your first workflow, or the Language Reference for the complete syntax.