{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://calligence.ai/docs/webhooks/schemas/lead.status_changed/v1.json",
  "title": "lead.status_changed",
  "description": "Cada vez que cambia el estado de un lead: por el análisis de una llamada, cuando tu equipo registra o corrige un resultado, cuando el chat de WhatsApp decide un veredicto, al volver a entrar en una campaña o al marcarlo como trabajado fuera. Si el estado no cambia, no hay evento. Una vez por cambio.",
  "$defs": {
    "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": {
    "lead": {
      "$ref": "#/$defs/LeadRef"
    },
    "customer": {
      "anyOf": [
        {
          "$ref": "#/$defs/CustomerRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "campaign": {
      "anyOf": [
        {
          "$ref": "#/$defs/CampaignRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "from": {
      "examples": [
        "PENDIENTE",
        "EXITO",
        "INVALIDO",
        "NO_INTERESADO",
        "TRABAJADO_EXTERNO"
      ],
      "type": "string",
      "title": "From"
    },
    "to": {
      "examples": [
        "PENDIENTE",
        "EXITO",
        "INVALIDO",
        "NO_INTERESADO",
        "TRABAJADO_EXTERNO"
      ],
      "type": "string",
      "title": "To"
    },
    "reason": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reason"
    },
    "call_id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Call Id"
    },
    "changed_at": {
      "format": "date-time",
      "title": "Changed At",
      "type": "string"
    }
  },
  "required": [
    "lead",
    "customer",
    "campaign",
    "from",
    "to",
    "reason",
    "call_id",
    "changed_at"
  ],
  "type": "object"
}
