{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:proven:ingest-event:1",
  "title": "Attify ingest event (proven.ingest/1)",
  "$defs": {
    "ActionData": {
      "additionalProperties": false,
      "properties": {
        "name": {
          "description": "The tool or function the agent called, as the agent names it (book_appointment, schedule_meeting, create_ticket).",
          "maxLength": 128,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "kind": {
          "anyOf": [
            {
              "pattern": "^[a-z][a-z0-9_.]{0,63}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "What the action did, in the job type's words where it has them (booking.created, meeting.scheduled). Optional: a job type can read the name instead.",
          "title": "Kind"
        },
        "status": {
          "default": "unknown",
          "description": "What the tool answered: succeeded, failed, or unknown.",
          "enum": [
            "succeeded",
            "failed",
            "unknown"
          ],
          "title": "Status",
          "type": "string"
        },
        "external_ref": {
          "anyOf": [
            {
              "maxLength": 128,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The record the action made or changed in the customer's own system (a booking, a calendar event, a CRM record): what a spot check looks up.",
          "title": "External Ref"
        },
        "detail": {
          "anyOf": [
            {
              "maxLength": 500,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Detail"
        }
      },
      "required": [
        "name"
      ],
      "title": "ActionData",
      "type": "object"
    },
    "ActionEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "action",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/ActionData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type",
        "data"
      ],
      "title": "ActionEvent",
      "type": "object"
    },
    "ClaimData": {
      "additionalProperties": false,
      "properties": {
        "outcome": {
          "description": "The vendor's own claim for this interaction, from the job type's vocabulary (support: resolved, not_resolved). The latest claim is the one tested.",
          "pattern": "^[a-z][a-z_]{0,63}$",
          "title": "Outcome",
          "type": "string"
        },
        "detail": {
          "anyOf": [
            {
              "maxLength": 500,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Detail"
        }
      },
      "required": [
        "outcome"
      ],
      "title": "ClaimData",
      "type": "object"
    },
    "ClaimEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "outcome.claimed",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/ClaimData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type",
        "data"
      ],
      "title": "ClaimEvent",
      "type": "object"
    },
    "DeploymentData": {
      "additionalProperties": false,
      "properties": {
        "agent": {
          "anyOf": [
            {
              "maxLength": 200,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The agent's name.",
          "title": "Agent"
        },
        "version": {
          "anyOf": [
            {
              "maxLength": 100,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Version"
        },
        "model": {
          "anyOf": [
            {
              "maxLength": 200,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The model it runs on.",
          "title": "Model"
        }
      },
      "title": "DeploymentData",
      "type": "object"
    },
    "DeploymentEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "type": {
          "const": "deployment",
          "title": "Type",
          "type": "string"
        },
        "interaction": {
          "default": null,
          "title": "Interaction",
          "type": "null"
        },
        "data": {
          "$ref": "#/$defs/DeploymentData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "type"
      ],
      "title": "DeploymentEvent",
      "type": "object"
    },
    "EndedData": {
      "additionalProperties": false,
      "properties": {
        "reason": {
          "anyOf": [
            {
              "enum": [
                "completed",
                "abandoned",
                "timeout",
                "transferred"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Reason"
        }
      },
      "title": "EndedData",
      "type": "object"
    },
    "EndedEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "interaction.ended",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/EndedData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type"
      ],
      "title": "EndedEvent",
      "type": "object"
    },
    "FeedbackData": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "description": "resolution: the end user said whether it was resolved (score 1 yes, 0 no).",
          "enum": [
            "resolution",
            "csat",
            "thumbs",
            "nps",
            "other"
          ],
          "title": "Kind",
          "type": "string"
        },
        "score": {
          "title": "Score",
          "type": "number"
        },
        "scale_max": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Scale Max"
        },
        "text": {
          "anyOf": [
            {
              "maxLength": 2000,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Text"
        }
      },
      "required": [
        "kind",
        "score"
      ],
      "title": "FeedbackData",
      "type": "object"
    },
    "FeedbackEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "feedback",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/FeedbackData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type",
        "data"
      ],
      "title": "FeedbackEvent",
      "type": "object"
    },
    "HandoffData": {
      "additionalProperties": false,
      "properties": {
        "to": {
          "description": "human: a person took over; agent: another AI agent; external: another channel (a phone line, a form).",
          "enum": [
            "human",
            "agent",
            "external"
          ],
          "title": "To",
          "type": "string"
        },
        "reason": {
          "anyOf": [
            {
              "maxLength": 500,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Reason"
        }
      },
      "required": [
        "to"
      ],
      "title": "HandoffData",
      "type": "object"
    },
    "HandoffEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "handoff",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/HandoffData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type",
        "data"
      ],
      "title": "HandoffEvent",
      "type": "object"
    },
    "MessageData": {
      "additionalProperties": false,
      "properties": {
        "role": {
          "description": "customer: the end user; agent: the AI; human: a person on the customer's side; system and tool messages are counted, their text is not kept.",
          "enum": [
            "customer",
            "agent",
            "human",
            "system",
            "tool"
          ],
          "title": "Role",
          "type": "string"
        },
        "text": {
          "maxLength": 20000,
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "role",
        "text"
      ],
      "title": "MessageData",
      "type": "object"
    },
    "MessageEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "message",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/MessageData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type",
        "data"
      ],
      "title": "MessageEvent",
      "type": "object"
    },
    "StartedData": {
      "additionalProperties": false,
      "properties": {
        "channel": {
          "anyOf": [
            {
              "maxLength": 64,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "chat, email, voice, messaging, ...",
          "title": "Channel"
        },
        "customer": {
          "anyOf": [
            {
              "maxLength": 128,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The end user's id in the customer's own system, so a repeat contact can be found (in the stream or in the customer's own help desk).",
          "title": "Customer"
        },
        "external_ref": {
          "anyOf": [
            {
              "maxLength": 128,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "This interaction's id in the customer's own system (a ticket, a CRM record, a calendar event): what a spot check looks up.",
          "title": "External Ref"
        }
      },
      "title": "StartedData",
      "type": "object"
    },
    "StartedEvent": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "description": "Idempotency key, unique within the deployment: the same id with the same content is a duplicate; with other content it is refused.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When it happened, by the agent's clock.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "stream": {
          "default": "default",
          "description": "One sender process; seq counts within it.",
          "pattern": "^[A-Za-z0-9._:-]{1,64}$",
          "title": "Stream",
          "type": "string"
        },
        "seq": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Position in the stream: 1, 2, 3, ... with no gaps, so a missing event shows.",
          "title": "Seq"
        },
        "interaction": {
          "description": "The conversation, call or task it belongs to.",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$",
          "title": "Interaction",
          "type": "string"
        },
        "type": {
          "const": "interaction.started",
          "title": "Type",
          "type": "string"
        },
        "data": {
          "$ref": "#/$defs/StartedData"
        }
      },
      "required": [
        "id",
        "occurred_at",
        "interaction",
        "type"
      ],
      "title": "StartedEvent",
      "type": "object"
    }
  },
  "discriminator": {
    "mapping": {
      "action": "#/$defs/ActionEvent",
      "deployment": "#/$defs/DeploymentEvent",
      "feedback": "#/$defs/FeedbackEvent",
      "handoff": "#/$defs/HandoffEvent",
      "interaction.ended": "#/$defs/EndedEvent",
      "interaction.started": "#/$defs/StartedEvent",
      "message": "#/$defs/MessageEvent",
      "outcome.claimed": "#/$defs/ClaimEvent"
    },
    "propertyName": "type"
  },
  "oneOf": [
    {
      "$ref": "#/$defs/DeploymentEvent"
    },
    {
      "$ref": "#/$defs/StartedEvent"
    },
    {
      "$ref": "#/$defs/MessageEvent"
    },
    {
      "$ref": "#/$defs/HandoffEvent"
    },
    {
      "$ref": "#/$defs/ActionEvent"
    },
    {
      "$ref": "#/$defs/ClaimEvent"
    },
    {
      "$ref": "#/$defs/FeedbackEvent"
    },
    {
      "$ref": "#/$defs/EndedEvent"
    }
  ]
}
