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 exports

1. 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

  1. Install dependencies:

  1. Set up environment:

  1. Run the agent:

Expected Output

Key Features Demonstrated

  1. Intelligent Qualification: The trigger only accepts customer service related queries

  2. Conversation State Management: Memory tracks the conversation stage and relevant information

  3. Business Logic Integration: Tools implement real business rules for refund eligibility

  4. Error Handling: Graceful handling of failed API calls and invalid requests

  5. Audit Trail: All refund transactions are logged for compliance

  6. 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