{
  "$defs": {
    "CsatReceivedEvent": {
      "properties": {
        "company_id": {
          "description": "UUID of the company (tenant) the conversation belongs to.",
          "format": "uuid",
          "title": "Company Id",
          "type": "string"
        },
        "conversation_id": {
          "description": "UUID of the conversation this event belongs to.",
          "format": "uuid",
          "title": "Conversation Id",
          "type": "string"
        },
        "digital_employee_id": {
          "description": "UUID of the digital employee handling the conversation.",
          "format": "uuid",
          "title": "Digital Employee Id",
          "type": "string"
        },
        "event_id": {
          "description": "Unique, stable identifier for this event. Delivery is at-least-once, so consumers must deduplicate on this value.",
          "title": "Event Id",
          "type": "string"
        },
        "event_type": {
          "const": "csat_received",
          "default": "csat_received",
          "description": "Discriminator; always \"csat_received\" for this record.",
          "title": "Event Type",
          "type": "string"
        },
        "feedback": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Optional free-text feedback; null when none was given.",
          "title": "Feedback"
        },
        "message_id": {
          "description": "UUID of the message this event relates to. Events that fan out from the same message share it, so it can be used to rejoin them.",
          "format": "uuid",
          "title": "Message Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When the event occurred, as an RFC 3339 / ISO 8601 timestamp.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "rating": {
          "description": "CSAT rating, 1 (worst) to 5 (best).",
          "maximum": 5,
          "minimum": 1,
          "title": "Rating",
          "type": "integer"
        },
        "rating_source": {
          "description": "How the rating was obtained (e.g. \"ai\" or \"user\").",
          "title": "Rating Source",
          "type": "string"
        },
        "schema_version": {
          "const": "v1",
          "default": "v1",
          "description": "Schema version of this record. Always \"v1\" here; a breaking change ships as \"v2\".",
          "title": "Schema Version",
          "type": "string"
        }
      },
      "required": [
        "event_id",
        "company_id",
        "digital_employee_id",
        "conversation_id",
        "message_id",
        "occurred_at",
        "rating",
        "rating_source"
      ],
      "title": "CsatReceivedEvent",
      "type": "object"
    },
    "MessageClassifiedEvent": {
      "properties": {
        "classification_label": {
          "description": "The classification label assigned to the message.",
          "title": "Classification Label",
          "type": "string"
        },
        "company_id": {
          "description": "UUID of the company (tenant) the conversation belongs to.",
          "format": "uuid",
          "title": "Company Id",
          "type": "string"
        },
        "conversation_id": {
          "description": "UUID of the conversation this event belongs to.",
          "format": "uuid",
          "title": "Conversation Id",
          "type": "string"
        },
        "digital_employee_id": {
          "description": "UUID of the digital employee handling the conversation.",
          "format": "uuid",
          "title": "Digital Employee Id",
          "type": "string"
        },
        "event_id": {
          "description": "Unique, stable identifier for this event. Delivery is at-least-once, so consumers must deduplicate on this value.",
          "title": "Event Id",
          "type": "string"
        },
        "event_type": {
          "const": "message_classified",
          "default": "message_classified",
          "description": "Discriminator; always \"message_classified\" for this record.",
          "title": "Event Type",
          "type": "string"
        },
        "message_id": {
          "description": "UUID of the message this event relates to. Events that fan out from the same message share it, so it can be used to rejoin them.",
          "format": "uuid",
          "title": "Message Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When the event occurred, as an RFC 3339 / ISO 8601 timestamp.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "schema_version": {
          "const": "v1",
          "default": "v1",
          "description": "Schema version of this record. Always \"v1\" here; a breaking change ships as \"v2\".",
          "title": "Schema Version",
          "type": "string"
        }
      },
      "required": [
        "event_id",
        "company_id",
        "digital_employee_id",
        "conversation_id",
        "message_id",
        "occurred_at",
        "classification_label"
      ],
      "title": "MessageClassifiedEvent",
      "type": "object"
    },
    "MessageSentEvent": {
      "properties": {
        "company_id": {
          "description": "UUID of the company (tenant) the conversation belongs to.",
          "format": "uuid",
          "title": "Company Id",
          "type": "string"
        },
        "conversation_id": {
          "description": "UUID of the conversation this event belongs to.",
          "format": "uuid",
          "title": "Conversation Id",
          "type": "string"
        },
        "digital_employee_id": {
          "description": "UUID of the digital employee handling the conversation.",
          "format": "uuid",
          "title": "Digital Employee Id",
          "type": "string"
        },
        "event_id": {
          "description": "Unique, stable identifier for this event. Delivery is at-least-once, so consumers must deduplicate on this value.",
          "title": "Event Id",
          "type": "string"
        },
        "event_type": {
          "const": "message_sent",
          "default": "message_sent",
          "description": "Discriminator; always \"message_sent\" for this record.",
          "title": "Event Type",
          "type": "string"
        },
        "message_id": {
          "description": "UUID of the message this event relates to. Events that fan out from the same message share it, so it can be used to rejoin them.",
          "format": "uuid",
          "title": "Message Id",
          "type": "string"
        },
        "occurred_at": {
          "description": "When the event occurred, as an RFC 3339 / ISO 8601 timestamp.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "role": {
          "$ref": "#/$defs/ParticipantRole",
          "description": "Who sent the message."
        },
        "schema_version": {
          "const": "v1",
          "default": "v1",
          "description": "Schema version of this record. Always \"v1\" here; a breaking change ships as \"v2\".",
          "title": "Schema Version",
          "type": "string"
        },
        "text": {
          "description": "The message text.",
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "event_id",
        "company_id",
        "digital_employee_id",
        "conversation_id",
        "message_id",
        "occurred_at",
        "role",
        "text"
      ],
      "title": "MessageSentEvent",
      "type": "object"
    },
    "ParticipantRole": {
      "enum": [
        "user",
        "digital_employee",
        "agent",
        "system",
        "statistics"
      ],
      "title": "ParticipantRole",
      "type": "string"
    },
    "SkillExecutedEvent": {
      "properties": {
        "company_id": {
          "description": "UUID of the company (tenant) the conversation belongs to.",
          "format": "uuid",
          "title": "Company Id",
          "type": "string"
        },
        "conversation_id": {
          "description": "UUID of the conversation this event belongs to.",
          "format": "uuid",
          "title": "Conversation Id",
          "type": "string"
        },
        "digital_employee_id": {
          "description": "UUID of the digital employee handling the conversation.",
          "format": "uuid",
          "title": "Digital Employee Id",
          "type": "string"
        },
        "end_state": {
          "description": "Terminal state of the execution (e.g. \"success\", \"internal_system_error\").",
          "title": "End State",
          "type": "string"
        },
        "event_id": {
          "description": "Unique, stable identifier for this event. Delivery is at-least-once, so consumers must deduplicate on this value.",
          "title": "Event Id",
          "type": "string"
        },
        "event_type": {
          "const": "skill_executed",
          "default": "skill_executed",
          "description": "Discriminator; always \"skill_executed\" for this record.",
          "title": "Event Type",
          "type": "string"
        },
        "message_id": {
          "description": "UUID of the message this event relates to. Events that fan out from the same message share it, so it can be used to rejoin them.",
          "format": "uuid",
          "title": "Message Id",
          "type": "string"
        },
        "name": {
          "description": "Name of the skill that executed.",
          "title": "Name",
          "type": "string"
        },
        "occurred_at": {
          "description": "When the event occurred, as an RFC 3339 / ISO 8601 timestamp.",
          "format": "date-time",
          "title": "Occurred At",
          "type": "string"
        },
        "schema_version": {
          "const": "v1",
          "default": "v1",
          "description": "Schema version of this record. Always \"v1\" here; a breaking change ships as \"v2\".",
          "title": "Schema Version",
          "type": "string"
        }
      },
      "required": [
        "event_id",
        "company_id",
        "digital_employee_id",
        "conversation_id",
        "message_id",
        "occurred_at",
        "name",
        "end_state"
      ],
      "title": "SkillExecutedEvent",
      "type": "object"
    }
  },
  "$id": "https://async-api-docs.freeday.ai/export/export-event.v1.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "discriminator": {
    "mapping": {
      "csat_received": "#/$defs/CsatReceivedEvent",
      "message_classified": "#/$defs/MessageClassifiedEvent",
      "message_sent": "#/$defs/MessageSentEvent",
      "skill_executed": "#/$defs/SkillExecutedEvent"
    },
    "propertyName": "event_type"
  },
  "oneOf": [
    {
      "$ref": "#/$defs/MessageSentEvent"
    },
    {
      "$ref": "#/$defs/CsatReceivedEvent"
    },
    {
      "$ref": "#/$defs/MessageClassifiedEvent"
    },
    {
      "$ref": "#/$defs/SkillExecutedEvent"
    }
  ]
}
