{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://calligence.ai/docs/webhooks/schemas/whatsapp.message.sent/v1.json",
  "title": "whatsapp.message.sent",
  "description": "Cuando aceptamos el envío de un mensaje nuestro: una plantilla, el aviso previo a una llamada, una respuesta de la IA o de tu equipo. Que salga hacia WhatsApp y llegue lo cuenta después whatsapp.message.status_updated. Una vez por mensaje.",
  "$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"
    },
    "SentMessage": {
      "properties": {
        "id": {
          "title": "Id",
          "type": "integer"
        },
        "sent_at": {
          "format": "date-time",
          "title": "Sent At",
          "type": "string"
        },
        "author": {
          "examples": [
            "template",
            "precall_notice",
            "ai",
            "operator"
          ],
          "type": "string",
          "title": "Author"
        },
        "template_key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Template Key"
        },
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Text"
        },
        "sender_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Sender Number"
        },
        "customer_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Customer Number"
        }
      },
      "required": [
        "id",
        "sent_at",
        "author",
        "template_key",
        "text",
        "sender_number",
        "customer_number"
      ],
      "title": "SentMessage",
      "type": "object"
    }
  },
  "properties": {
    "customer": {
      "anyOf": [
        {
          "$ref": "#/$defs/CustomerRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "lead": {
      "anyOf": [
        {
          "$ref": "#/$defs/LeadRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "campaign": {
      "anyOf": [
        {
          "$ref": "#/$defs/CampaignRef"
        },
        {
          "type": "null"
        }
      ]
    },
    "message": {
      "$ref": "#/$defs/SentMessage"
    },
    "call_id": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Call Id"
    }
  },
  "required": [
    "customer",
    "lead",
    "campaign",
    "message",
    "call_id"
  ],
  "type": "object"
}
