Logo
Search
API Docs

E-commerce Order Processing: Structured Output Template

Structured Data & Outputs

E-commerce Order Processing: Structured Output Template

Overview

This is a production-ready structured-output schema for capturing order details from a sales call — customer info, line items, shipping, and payment. Attach it to an assistant the same way described in Structured Outputs (Post-Call Data Extraction). It's the full schema behind the one-line mention on Prebuilt Templates & Example Use Cases.


Full JSON Schema

{
  "name": "E-commerce Order",
  "type": "ai",
  "description": "Extract complete order information from sales calls",
  "schema": {
    "type": "object",
    "properties": {
      "customer": {
        "type": "object",
        "properties": {
          "name":          { "type": "string", "description": "Customer full name" },
          "email":         { "type": "string", "format": "email", "description": "Customer email for order confirmation" },
          "phone":         { "type": "string", "description": "Contact number" },
          "loyaltyNumber": { "type": "string", "description": "Loyalty program member number if mentioned" }
        },
        "required": ["name", "email"]
      },
      "items": {
        "type": "array",
        "minItems": 1,
        "items": {
          "type": "object",
          "properties": {
            "productName":    { "type": "string", "description": "Name or description of the product" },
            "sku":            { "type": "string", "description": "Product SKU if mentioned" },
            "quantity":       { "type": "integer", "minimum": 1, "description": "Quantity ordered" },
            "size":           { "type": "string", "enum": ["XS", "S", "M", "L", "XL", "XXL", "custom"], "description": "Size if applicable" },
            "color":          { "type": "string", "description": "Color preference" },
            "customization":  { "type": "string", "description": "Any customization requests" }
          },
          "required": ["productName", "quantity"]
        }
      },
      "shipping": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "enum": ["standard", "express", "overnight", "pickup"],
            "description": "Shipping method"
          },
          "address": {
            "type": "object",
            "properties": {
              "street":    { "type": "string" },
              "apartment": { "type": "string", "description": "Apartment or suite number" },
              "city":      { "type": "string" },
              "state":     { "type": "string", "pattern": "^[A-Z]{2}$" },
              "zipCode":   { "type": "string", "pattern": "^\\d{5}(-\\d{4})?$" },
              "country":   { "type": "string", "default": "USA" }
            },
            "required": ["street", "city", "state", "zipCode"]
          },
          "instructions": { "type": "string", "description": "Special delivery instructions" },
          "giftWrap":     { "type": "boolean", "description": "Whether gift wrapping was requested" },
          "giftMessage":  { "type": "string", "description": "Gift message if applicable" }
        },
        "required": ["method", "address"]
      },
      "payment": {
        "type": "object",
        "properties": {
          "method": {
            "type": "string",
            "enum": ["credit_card", "debit_card", "paypal", "apple_pay", "google_pay", "invoice"],
            "description": "Payment method"
          },
          "cardLastFour": {
            "type": "string",
            "pattern": "^\\d{4}$",
            "description": "Last 4 digits of card if provided"
          },
          "billingAddressSameAsShipping": {
            "type": "boolean",
            "description": "Whether billing address is same as shipping"
          }
        },
        "required": ["method"]
      },
      "promotions": {
        "type": "object",
        "properties": {
          "promoCode":      { "type": "string", "description": "Promotional code mentioned" },
          "referralSource": { "type": "string", "description": "How customer heard about us" }
        }
      },
      "specialRequests": { "type": "string", "description": "Any special requests or notes" }
    },
    "required": ["customer", "items", "shipping"]
  }
}

Example Output

A realistic extraction result from a completed order call:

{
  "customer": {
    "name": "Michael Chen",
    "email": "[email protected]",
    "phone": "+14155552468",
    "loyaltyNumber": "LOYAL123456"
  },
  "items": [
    {
      "productName": "Wireless Headphones XL",
      "quantity": 1,
      "color": "Black"
    },
    {
      "productName": "USB-C Cable 6ft",
      "quantity": 2
    }
  ],
  "shipping": {
    "address": {
      "street": "123 Market Street",
      "city": "San Francisco",
      "state": "CA",
      "zipCode": "94102",
      "country": "USA"
    },
    "method": "express",
    "giftWrap": false
  },
  "payment": {
    "method": "credit_card",
    "cardLastFour": "4242"
  },
  "promotions": {
    "promoCode": "SAVE20"
  },
  "specialRequests": "Please leave package with doorman"
}

Key Fields

SectionRequired FieldsOptional Fields
Top levelcustomer, items, shippingpayment, promotions, specialRequests
customername, emailphone, loyaltyNumber
items[]productName, quantitysku, size, color, customization
shippingmethod, address (street, city, state, zipCode)apartment, country, instructions, giftWrap, giftMessage
paymentmethodcardLastFour, billingAddressSameAsShipping
promotions(none)promoCode, referralSource

The items array enforces at least one item (minItems: 1), and shipping.address.state expects a two-letter uppercase US state code.