Order Refund Flow
A complete example demonstrating how to build an intelligent customer support agent that can handle order refunds with sophisticated routing and business logic.
Overview
This example showcases:
Trigger handling with qualification logic
Prompt-based routing for intelligent conversation flow
Tool integration for business logic execution
Memory management for maintaining conversation state
Error handling and edge cases
Complete Implementation
Project Structure
order-refund-agent/
βββ minded.json # Agent configuration
βββ schema.ts # Memory type definition
βββ agent.ts # Main agent implementation
βββ flows/
β βββ refundFlow.yaml # Flow definition
βββ tools/
βββ lookupOrder.ts # Order lookup tool
βββ processRefund.ts # Refund processing tool
βββ index.ts # Tool exports1. Agent Configuration
Create your minded.json configuration file (see Project Configuration for detailed documentation):
minded.json:
2. Memory Schema
schema.ts:
3. Flow Definition
flows/refundFlow.yaml:
4. Tools Implementation
tools/lookupOrder.ts:
tools/processRefund.ts:
tools/index.ts:
5. Main Agent Implementation
agent.ts:
Running the Example
Install dependencies:
Set up environment:
Run the agent:
Expected Output
Key Features Demonstrated
Intelligent Qualification: The trigger only accepts customer service related queries
Conversation State Management: Memory tracks the conversation stage and relevant information
Business Logic Integration: Tools implement real business rules for refund eligibility
Error Handling: Graceful handling of failed API calls and invalid requests
Audit Trail: All refund transactions are logged for compliance
Type Safety: Full TypeScript type safety throughout the flow
This example provides a solid foundation for building production-ready customer service agents with MindedJS!
Last updated