Data Models

Comprehensive guide to CallCall.ai's data models, their relationships, and how to work with them effectively in your applications.

Customer Model

{
  "id": "lead_123",
  "created_at": "2025-02-07T02:55:00Z",
  "updated_at": "2025-02-07T02:55:00Z",
  "status": "active",
  "score": 85,
  "contact": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john@example.com",
    "phone": "+1234567890"
  },
  "preferences": {
    "service_types": ["consulting", "support", "maintenance"],
    "price_range": {
      "min": 100,
      "max": 1000
    },
    "locations": ["downtown", "suburbs"],
    "service_level": { "min": "basic", "max": "premium" }
  },
  "engagement": {
    "last_contact": "2025-02-06T00:00:00Z",
    "total_interactions": 15,
    "preferred_contact_time": "evening"
  }
}

Service Model

{
  "id": "prop_456",
  "created_at": "2025-02-07T02:55:00Z",
  "updated_at": "2025-02-07T02:55:00Z",
  "status": "active",
  "type": "consulting",
  "details": {
    "price": 250,
    "duration": 60,
    "category": "business",
    "description": "Business consulting service"
  },
  "location": {
    "address": "123 Main St",
    "city": "Example City",
    "state": "EX",
    "zip": "12345",
    "coordinates": {
      "latitude": 37.7749,
      "longitude": -122.4194
    }
  },
  "features": [
    "free_consultation",
    "priority_support",
    "follow_up",
    "reporting"
  ],
  "media": {
    "photos": ["url1", "url2"],
    "video_demo": "demo_url",
    "brochure": "brochure_url"
  }
}

Relationship Models

Service Match

{
  "id": "match_789",
  "customer_id": "customer_123",
  "service_id": "service_456",
  "created_at": "2025-02-07T02:55:00Z",
  "score": 92,
  "match_factors": [
    "price_range",
    "location",
    "service_level"
  ],
  "status": "presented",
  "customer_feedback": "interested"
}

Interaction

{
  "id": "int_101",
  "lead_id": "lead_123",
  "type": "message",
  "created_at": "2025-02-07T02:55:00Z",
  "channel": "email",
  "content": "Inquiry about service",
  "sentiment": "positive",
  "ai_analysis": {
    "intent": "information_request",
    "urgency": "medium"
  }
}

Business Analysis

{
  "id": "analysis_202",
  "service_id": "service_456",
  "created_at": "2025-02-07T02:55:00Z",
  "business_data": {
    "median_price": 250,
    "price_trend": "+5%",
    "days_on_market": 30,
    "comparable_services": [
      "service_457",
      "service_458"
    ]
  },
  "predictions": {
    "estimated_value": 250,
    "booking_rate": "3.5%",
    "conversion_probability": 0.85
  }
}

Agent Assignment

{
  "id": "assignment_303",
  "customer_id": "customer_123",
  "agent_id": "agent_789",
  "created_at": "2025-02-07T02:55:00Z",
  "match_score": 88,
  "match_factors": [
    "expertise",
    "location",
    "language",
    "business_acumen"
  ],
  "status": "active",
  "performance": {
    "response_time": "2h",
    "satisfaction_score": 4.8
  }
}

Model Relationships

  • Customer → Services (many-to-many)
  • Customer → Interactions (one-to-many)
  • Service → Analysis (one-to-many)

Data Validation

  • Required fields validation
  • Data type checking
  • Format validation
  • Relationship integrity

Common Operations

GET/api/v1/customers/:id
POST/api/v1/services
PUT/api/v1/matches/:id

Working with Models

Create

Create new instances with proper validation

Query

Fetch and filter data efficiently

Update

Modify existing records safely

Delete

Handle deletions with care