{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/JSONQueryOnEventsTable",
  "title": "JSONQueryOnEventsTable",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "description": "This is the type of query. Only allowed type is \"vapiql-json\".",
      "example": "vapiql-json",
      "enum": [
        "vapiql-json"
      ]
    },
    "table": {
      "type": "string",
      "description": "This is the table that will be queried.\nMust be \"events\" for event-based insights.",
      "enum": [
        "events"
      ]
    },
    "on": {
      "type": "string",
      "description": "The event type to query",
      "example": "assistant.model.requestFailed",
      "enum": [
        "call.started",
        "call.ended",
        "call.inProgress",
        "call.queued",
        "call.transportConnected",
        "call.transportDisconnected",
        "call.transportReconnected",
        "call.transferInitiated",
        "call.transferCompleted",
        "call.transferFailed",
        "call.transferCancelled",
        "call.handoffInitiated",
        "call.handoffCompleted",
        "call.handoffFailed",
        "call.assistantSwapped",
        "call.assistantStarted",
        "call.customerJoined",
        "call.customerLeft",
        "call.controlReceived",
        "call.listenStarted",
        "call.recordingStarted",
        "call.recordingPaused",
        "call.recordingResumed",
        "call.voicemailDetected",
        "call.voicemailNotDetected",
        "call.dtmfReceived",
        "call.dtmfSent",
        "call.amdDetected",
        "call.hookTriggered",
        "call.hookSucceeded",
        "call.hookFailed",
        "call.statusReceived",
        "call.silenceTimeout",
        "call.microphoneTimeout",
        "call.maxDurationReached",
        "assistant.voice.requestStarted",
        "assistant.voice.requestSucceeded",
        "assistant.voice.requestFailed",
        "assistant.voice.connectionOpened",
        "assistant.voice.connectionClosed",
        "assistant.voice.firstAudioReceived",
        "assistant.voice.audioChunkReceived",
        "assistant.voice.generationSucceeded",
        "assistant.voice.generationFailed",
        "assistant.voice.textPushed",
        "assistant.voice.reconnecting",
        "assistant.voice.cleanup",
        "assistant.voice.clearing",
        "assistant.voice.voiceSwitched",
        "assistant.model.requestStarted",
        "assistant.model.requestSucceeded",
        "assistant.model.requestFailed",
        "assistant.model.requestAttemptStarted",
        "assistant.model.requestAttemptSucceeded",
        "assistant.model.requestAttemptFailed",
        "assistant.model.connectionOpened",
        "assistant.model.connectionClosed",
        "assistant.model.firstTokenReceived",
        "assistant.model.tokenReceived",
        "assistant.model.responseSucceeded",
        "assistant.model.responseFailed",
        "assistant.model.toolCallsReceived",
        "assistant.model.reconnecting",
        "assistant.model.cleanup",
        "assistant.model.clearing",
        "assistant.tool.started",
        "assistant.tool.completed",
        "assistant.tool.failed",
        "assistant.tool.delayedMessageSent",
        "assistant.tool.timeout",
        "assistant.tool.asyncCallbackReceived",
        "assistant.transcriber.requestStarted",
        "assistant.transcriber.requestSucceeded",
        "assistant.transcriber.requestFailed",
        "assistant.transcriber.connectionOpened",
        "assistant.transcriber.connectionClosed",
        "assistant.transcriber.partialTranscript",
        "assistant.transcriber.finalTranscript",
        "assistant.transcriber.keepAlive",
        "assistant.transcriber.reconnecting",
        "assistant.transcriber.cleanup",
        "assistant.transcriber.clearing",
        "assistant.transcriber.transcriptIgnored",
        "assistant.transcriber.languageSwitched",
        "assistant.analysis.structuredOutputGenerated",
        "pipeline.turnStarted",
        "pipeline.cleared",
        "pipeline.botSpeechStarted",
        "pipeline.botSpeechStopped",
        "pipeline.userSpeechStarted",
        "pipeline.userSpeechStopped",
        "pipeline.endpointingTriggered",
        "pipeline.firstMessageStarted",
        "pipeline.firstMessageCompleted"
      ]
    },
    "operation": {
      "type": "string",
      "description": "This is the operation to perform on matching events.\n- \"count\": Returns the raw count of matching events\n- \"percentage\": Returns (count of matching events / total calls) * 100",
      "example": "count",
      "enum": [
        "count",
        "percentage"
      ]
    },
    "filters": {
      "type": "array",
      "description": "These are the filters to apply to the events query.\nEach filter filters on a field specific to the event type.",
      "items": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/EventsTableStringCondition"
          },
          {
            "$ref": "#/components/schemas/EventsTableNumberCondition"
          },
          {
            "$ref": "#/components/schemas/EventsTableBooleanCondition"
          }
        ]
      }
    },
    "name": {
      "type": "string",
      "description": "This is the name of the query.\nIt will be used to label the query in the insight board on the UI.",
      "example": "Model Failures"
    }
  },
  "required": [
    "type",
    "table",
    "on",
    "operation"
  ]
}