{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://calligence.ai/docs/webhooks/schemas/call.dispatched/v1.json",
  "title": "call.dispatched",
  "description": "Cuando el proveedor de voz acepta la llamada y el teléfono del cliente empieza a sonar. Una vez por llamada.",
  "$defs": {
    "AgentRef": {
      "properties": {
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Type"
        }
      },
      "required": [
        "type"
      ],
      "title": "AgentRef",
      "type": "object"
    },
    "CallRef": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "direction": {
          "examples": [
            "outbound",
            "inbound"
          ],
          "type": "string",
          "title": "Direction"
        },
        "status": {
          "examples": [
            "initiated",
            "completed",
            "failed"
          ],
          "type": "string",
          "title": "Status"
        },
        "attempt_index": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Attempt Index"
        },
        "started_at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Started At"
        },
        "ended_at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ended At"
        },
        "duration_s": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration S"
        },
        "from_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "From Number"
        },
        "to_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "To Number"
        }
      },
      "required": [
        "id",
        "direction",
        "status",
        "attempt_index",
        "started_at",
        "ended_at",
        "duration_s",
        "from_number",
        "to_number"
      ],
      "title": "CallRef",
      "type": "object"
    },
    "CampaignRef": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "title": "CampaignRef",
      "type": "object"
    },
    "CustomerRef": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "external_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "External Id"
        },
        "phone": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        }
      },
      "required": [
        "id",
        "external_id",
        "phone",
        "name"
      ],
      "title": "CustomerRef",
      "type": "object"
    },
    "LeadRef": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "status": {
          "examples": [
            "PENDIENTE",
            "EXITO",
            "INVALIDO",
            "NO_INTERESADO",
            "TRABAJADO_EXTERNO"
          ],
          "type": "string",
          "title": "Status"
        },
        "status_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Status Reason"
        },
        "product_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Product Name"
        },
        "product_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Product Code"
        }
      },
      "required": [
        "id",
        "status",
        "status_reason",
        "product_name",
        "product_code"
      ],
      "title": "LeadRef",
      "type": "object"
    }
  },
  "properties": {
    "call": {
      "$ref": "#/$defs/CallRef"
    },
    "lead": {
      "anyOf": [
        {
          "$ref": "#/$defs/LeadRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "customer": {
      "anyOf": [
        {
          "$ref": "#/$defs/CustomerRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "campaign": {
      "anyOf": [
        {
          "$ref": "#/$defs/CampaignRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "agent": {
      "$ref": "#/$defs/AgentRef"
    },
    "dispatched_at": {
      "format": "date-time",
      "title": "Dispatched At",
      "type": "string"
    }
  },
  "required": [
    "call",
    "lead",
    "customer",
    "campaign",
    "agent",
    "dispatched_at"
  ],
  "type": "object"
}
