Examples
Comprehensive examples demonstrating MDWR workflows for various use cases.
Available Examples
Master Application Flow
Best for: Complete system workflows with all subsystems
- 20+ interconnected steps
- Complete error handling with 5 fallback strategies
- Memory integration throughout
- Security (authentication, authorization, rate limiting)
- Multi-channel notifications
- Real-time monitoring and metrics
- Complete audit trail
View on GitHub: implementation/workflow-memory-layer/src/workflows/master-application/
Basic Workflow
Best for: Learning MDWR fundamentals
- Simple 3-step workflow
- No memory integration
- Demonstrates basic step chaining
- Shows decision structure
View on GitHub: examples/basic-workflow.ts
Refund Workflow
Best for: Understanding memory integration
- Risk evaluation with memory queries
- Conditional step execution
- Memory-informed decision making
- Real-world e-commerce use case
View on GitHub: examples/refund-workflow.ts
Approval Workflow
Best for: Multi-level approvals and branching
- Multi-step approval chain
- Conditional branching based on decisions
- Memory-based approval thresholds
- Demonstrates workflow state management
View on GitHub: examples/approval-workflow.ts
Order Processing
Best for: E-commerce and fulfillment workflows
- Inventory check
- Payment processing
- Shipping calculation
- Order fulfillment with memory
View on GitHub: examples/order-processing.ts
Content Moderation
Best for: AI/ML decision workflows
- Content analysis
- Risk scoring
- Automated moderation decisions
- Memory-based pattern learning
View on GitHub: examples/content-moderation.ts
Replay Examples
Best for: Understanding workflow replay
- Exact replay
- Policy-aware replay
- Memory-informed replay
- Comparing replay modes
View on GitHub: examples/replay-examples.ts
Running Examples
Deploy All Workflows
npx ts-node scripts/deploy.ts
Execute Specific Workflow
npx ts-node scripts/execute.ts <workflow_name>
View in Motia Workbench
- Start Motia:
cd motia-atlas && npm run dev - Open:
http://localhost:3000 - See workflow diagrams and test endpoints
Integration Patterns
See the examples directory on GitHub for complete code.
Quick Code Snippets
Simple Decision:
const workflow = Workflow.create("simple")
.step("decide", async (ctx) => {
return {
decision: "proceed",
reason: "Simple decision",
confidence: 1.0
};
}, true);
Memory-Informed:
.step("decide", async (ctx) => {
const insights = await ctx.memory.similar({
situation: "my_decision",
context: ctx.input
});
return { decision, reason, confidence };
}, true)
Conditional Execution:
.step("next", async (ctx) => {
if (ctx.state.previous?.decision !== "approve") {
return { decision: "skip", reason: "...", confidence: 1.0 };
}
// Continue execution
}, true)
Next Steps
- Getting Started - Build your first workflow
- Guides - Learn advanced features
- API Reference - Complete API docs