Order Status Agent

Build a simple order tracking voice agent that looks up and reports order status.

Order Status Agent

A focused agent for order tracking - simple, fast, and effective.

Configuration

{
  "agent": {
    "name": "Order Tracker",
    "language": "en-US",

    "llmProvider": "gemini-2.5",
    "llmModel": "gemini-2.5-flash-lite",
    "llmTemperature": 0.3,

    "sttProvider": "deepgram",
    "sttModel": "nova-3",

    "ttsProvider": "cartesia",
    "ttsVoice": "95856005-0332-41b0-935f-352e296aa0df",

    "greetingMessage": "Hi! I can help you check your order status. What's your order number?",

    "prompt": "..."
  }
}

System Prompt

You are an order status assistant. Your only job is to help customers check their order status.

## Behavior
1. Ask for order number if not provided
2. Look up the order using the get_order_status tool
3. Report the status clearly
4. Ask if they need anything else
5. End the call politely

## Response Style
- Be brief and direct
- Speak the order number digit by digit: "O R D 1 2 3 4 5"
- Give clear delivery estimates
- Use simple language

## If Order Not Found
Say: "I couldn't find that order number. Let me make sure I have it right. Could you say it again slowly?"

## Sample Flow

User: "I want to check my order"
You: "Sure! What's your order number?"

User: "It's 12345"
You: "Let me look that up. [pause] Your order O R D 1 2 3 4 5 shipped yesterday and should arrive by Friday. Is there anything else I can help with?"

User: "No that's all"
You: "Great! Thanks for calling. Have a good day!"

Tool

{
  "type": "function",
  "function": {
    "name": "get_order_status",
    "description": "Look up order status by order ID or phone number",
    "parameters": {
      "type": "object",
      "properties": {
        "order_id": {
          "type": "string",
          "description": "Order ID"
        },
        "phone": {
          "type": "string",
          "description": "Phone number to look up orders"
        }
      }
    }
  }
}

Tool Handler

func handleGetOrderStatus(params map[string]any) (string, error) {
    orderID := params["order_id"].(string)

    order, err := db.GetOrder(orderID)
    if err != nil {
        return "", err
    }

    if order == nil {
        return "Order not found. Please verify the order number.", nil
    }

    return formatOrderStatus(order), nil
}

func formatOrderStatus(order *Order) string {
    status := fmt.Sprintf("Order %s: ", spellOutOrderID(order.ID))

    switch order.Status {
    case "processing":
        status += fmt.Sprintf("Being prepared. Should ship by %s.",
            order.EstimatedShipDate.Format("Monday"))

    case "shipped":
        status += fmt.Sprintf("Shipped on %s. Expected delivery: %s. Tracking number: %s.",
            order.ShippedAt.Format("January 2"),
            order.EstimatedDelivery.Format("January 2"),
            spellOut(order.TrackingNumber))

    case "out_for_delivery":
        status += "Out for delivery today!"

    case "delivered":
        status += fmt.Sprintf("Delivered on %s.",
            order.DeliveredAt.Format("January 2"))

    case "cancelled":
        status += "This order was cancelled."
    }

    return status
}

func spellOutOrderID(id string) string {
    // "ORD12345" -> "O R D 1 2 3 4 5"
    return strings.Join(strings.Split(id, ""), " ")
}

Variables

Pass order info when initiating call:

curl -X POST https://voice-agent.edesy.in/api/v1/calls \
  -d '{
    "agent_id": "order_tracker",
    "to": "+1234567890",
    "variables": {
      "customerName": "John",
      "recentOrderId": "ORD12345"
    }
  }'

Updated greeting:

Hello {{customerName}}! I see you have a recent order {{recentOrderId}}. Would you like me to check on that?

DTMF for Order Number

Allow keypad entry:

{
  "dtmf": {
    "enabled": true,
    "prompt": "You can also enter your order number using your keypad, followed by pound."
  }
}
func (p *Pipeline) handleOrderDTMF(digits string) {
    orderID := "ORD" + digits
    status, _ := handleGetOrderStatus(map[string]any{"order_id": orderID})
    p.tts.Speak(status)
}

Multiple Orders

Handle customers with multiple orders:

func handleGetOrdersByPhone(phone string) (string, error) {
    orders, _ := db.GetOrdersByPhone(phone)

    if len(orders) == 0 {
        return "I don't see any orders for that phone number.", nil
    }

    if len(orders) == 1 {
        return formatOrderStatus(orders[0]), nil
    }

    // Multiple orders
    response := fmt.Sprintf("I found %d orders. ", len(orders))
    for i, order := range orders {
        response += fmt.Sprintf("Order %d: %s, status %s. ",
            i+1,
            spellOutOrderID(order.ID),
            order.Status)
    }
    response += "Which order would you like details on?"

    return response, nil
}

Analytics

type OrderStatusMetrics struct {
    TotalLookups      int
    SuccessfulLookups int
    NotFoundRate      float64
    AverageCallTime   time.Duration
}

func trackLookup(orderID string, found bool, duration time.Duration) {
    metrics.Increment("order_status.lookups.total")
    if found {
        metrics.Increment("order_status.lookups.success")
    } else {
        metrics.Increment("order_status.lookups.not_found")
    }
    metrics.Histogram("order_status.call_duration", duration.Seconds())
}

Next Steps