647 lines
13 KiB
JSON
647 lines
13 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://go-sip.local/contracts/v1/event-payloads.schema.json",
|
|
"title": "Agent-call versioned event envelopes and payloads",
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"schema_version",
|
|
"event_id",
|
|
"event_type",
|
|
"tenant_id",
|
|
"tenant_key",
|
|
"trace_id",
|
|
"occurred_at",
|
|
"aggregate_type",
|
|
"aggregate_id",
|
|
"aggregate_version",
|
|
"payload",
|
|
"dispatcher_id"
|
|
],
|
|
"properties": {
|
|
"schema_version": {
|
|
"const": "2.0"
|
|
},
|
|
"event_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"event_type": {
|
|
"type": "string"
|
|
},
|
|
"tenant_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"tenant_key": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 196,
|
|
"not": {
|
|
"pattern": "(^|\\.)[*#](\\.|$)"
|
|
},
|
|
"$comment": "Runtime also enforces 196 UTF-8 bytes and each AMQP resource's 255-byte budget."
|
|
},
|
|
"trace_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"occurred_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"aggregate_type": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 64
|
|
},
|
|
"aggregate_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"aggregate_version": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"payload": {
|
|
"type": "object"
|
|
},
|
|
"dispatcher_id": {
|
|
"type": "string",
|
|
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
}
|
|
},
|
|
"oneOf": [
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "command.result"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/command_result"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "call.status"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/call_status"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "transcript.updated"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/transcript_updated"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "call.finished"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/call_finished"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "recording.uploaded"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/recording_uploaded"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "recording.failed"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/recording_failed"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "transcript.failed"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/transcript_failed"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"properties": {
|
|
"event_type": {
|
|
"const": "contact.opt_out"
|
|
},
|
|
"payload": {
|
|
"$ref": "#/$defs/contact_opt_out"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"$defs": {
|
|
"id": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 128
|
|
},
|
|
"command_result": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"command_id",
|
|
"command_type",
|
|
"status",
|
|
"reason_code"
|
|
],
|
|
"properties": {
|
|
"command_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"command_type": {
|
|
"enum": [
|
|
"call.execute",
|
|
"task.control",
|
|
"call.replay",
|
|
"command.replay"
|
|
]
|
|
},
|
|
"status": {
|
|
"enum": [
|
|
"accepted",
|
|
"waiting",
|
|
"applied",
|
|
"rejected",
|
|
"failed",
|
|
"unknown"
|
|
]
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 128
|
|
},
|
|
"task_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_item_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"execution_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"requested_task_revision": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"applied_task_revision": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"admission_state": {
|
|
"enum": [
|
|
"open",
|
|
"closed",
|
|
"draining",
|
|
"quarantined",
|
|
"unknown"
|
|
]
|
|
},
|
|
"resource_reservation_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"permit_id": {
|
|
"$ref": "#/$defs/id"
|
|
}
|
|
}
|
|
},
|
|
"call_status": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"execution_id",
|
|
"call_state",
|
|
"call_version",
|
|
"attempt_id",
|
|
"attempt_state"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"execution_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_item_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"call_state": {
|
|
"enum": [
|
|
"queued",
|
|
"dialing",
|
|
"ringing",
|
|
"answered",
|
|
"ended"
|
|
]
|
|
},
|
|
"call_version": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"attempt_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"attempt_state": {
|
|
"enum": [
|
|
"pending",
|
|
"active",
|
|
"ended",
|
|
"unknown"
|
|
]
|
|
},
|
|
"route_policy_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"caller_profile_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"trunk_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"cell_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"egress_pool_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"observed_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"maxLength": 128
|
|
}
|
|
}
|
|
},
|
|
"transcript_updated": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"turn_id",
|
|
"segment_id",
|
|
"role",
|
|
"revision",
|
|
"text",
|
|
"is_final",
|
|
"start_ms",
|
|
"end_ms",
|
|
"playback_state"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"execution_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"turn_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"segment_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"role": {
|
|
"enum": [
|
|
"customer",
|
|
"agent",
|
|
"system"
|
|
]
|
|
},
|
|
"revision": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"text": {
|
|
"type": "string",
|
|
"maxLength": 32768
|
|
},
|
|
"is_final": {
|
|
"type": "boolean"
|
|
},
|
|
"start_ms": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"end_ms": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"playback_state": {
|
|
"enum": [
|
|
"not_applicable",
|
|
"generated",
|
|
"sent",
|
|
"playback_confirmed",
|
|
"cancelled",
|
|
"unknown"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"call_finished": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"execution_id",
|
|
"call_version",
|
|
"outcome",
|
|
"started_at",
|
|
"ended_at",
|
|
"duration_ms",
|
|
"reason_code"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"execution_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_item_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"call_version": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"outcome": {
|
|
"enum": [
|
|
"answered",
|
|
"no_answer",
|
|
"busy",
|
|
"failed",
|
|
"opt_out",
|
|
"cancelled",
|
|
"unknown"
|
|
]
|
|
},
|
|
"started_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"ended_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"duration_ms": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 128
|
|
},
|
|
"attempt_summary": {
|
|
"type": "array",
|
|
"maxItems": 32,
|
|
"items": {
|
|
"$ref": "#/$defs/attempt_summary"
|
|
}
|
|
},
|
|
"asset_state": {
|
|
"enum": [
|
|
"pending",
|
|
"complete",
|
|
"failed",
|
|
"unknown"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"attempt_summary": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"attempt_id",
|
|
"state"
|
|
],
|
|
"properties": {
|
|
"attempt_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"state": {
|
|
"enum": [
|
|
"pending",
|
|
"active",
|
|
"ended",
|
|
"unknown"
|
|
]
|
|
},
|
|
"trunk_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"cell_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"maxLength": 128
|
|
}
|
|
}
|
|
},
|
|
"recording_failed": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"recording_id",
|
|
"stage",
|
|
"reason_code",
|
|
"retryable"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"recording_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"stage": {
|
|
"enum": [
|
|
"seal",
|
|
"request",
|
|
"upload",
|
|
"complete",
|
|
"verify",
|
|
"cleanup"
|
|
]
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 128
|
|
},
|
|
"retryable": {
|
|
"type": "boolean"
|
|
},
|
|
"next_retry_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
}
|
|
}
|
|
},
|
|
"transcript_failed": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"reason_code",
|
|
"retryable"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"reason_code": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 128
|
|
},
|
|
"retryable": {
|
|
"type": "boolean"
|
|
},
|
|
"segment_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"affected_segments": {
|
|
"type": "array",
|
|
"maxItems": 256,
|
|
"items": {
|
|
"$ref": "#/$defs/id"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"contact_opt_out": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"task_id",
|
|
"task_item_id",
|
|
"requested_at"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"task_item_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"requested_at": {
|
|
"type": "string",
|
|
"format": "date-time"
|
|
},
|
|
"turn_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"segment_id": {
|
|
"$ref": "#/$defs/id"
|
|
}
|
|
}
|
|
},
|
|
"recording_uploaded": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"required": [
|
|
"call_id",
|
|
"recording_id",
|
|
"format",
|
|
"channels",
|
|
"sample_rate_hz",
|
|
"duration_ms",
|
|
"size_bytes",
|
|
"checksum_sha256",
|
|
"upload_id",
|
|
"bucket",
|
|
"object_key"
|
|
],
|
|
"properties": {
|
|
"call_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"recording_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"format": {
|
|
"enum": [
|
|
"wav",
|
|
"raw_pcm",
|
|
"pcma"
|
|
]
|
|
},
|
|
"channels": {
|
|
"const": 1
|
|
},
|
|
"sample_rate_hz": {
|
|
"type": "integer",
|
|
"minimum": 8000,
|
|
"maximum": 48000
|
|
},
|
|
"duration_ms": {
|
|
"type": "integer",
|
|
"minimum": 0
|
|
},
|
|
"size_bytes": {
|
|
"type": "integer",
|
|
"minimum": 1
|
|
},
|
|
"checksum_sha256": {
|
|
"type": "string",
|
|
"pattern": "^[a-f0-9]{64}$"
|
|
},
|
|
"upload_id": {
|
|
"$ref": "#/$defs/id"
|
|
},
|
|
"bucket": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 63
|
|
},
|
|
"object_key": {
|
|
"type": "string",
|
|
"minLength": 1,
|
|
"maxLength": 1024
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|