{
  "$id": "https://hatang.dev/schema/chat-protocol/v1/server-frames.json",
  "title": "Ha Tang chat protocol v1: server → visitor frames",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "ready"
        },
        "d": {
          "type": "object",
          "properties": {
            "visitor": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "site_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "channel": {
                  "type": "string"
                },
                "email": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "phone": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "avatar_url": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "external_id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "custom_data": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {}
                },
                "locale": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "vi",
                        "en"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "browser": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "os": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "device": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "country": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "city": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "current_url": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "current_title": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "referrer": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "first_seen_at": {
                  "type": "string"
                },
                "last_seen_at": {
                  "type": "string"
                },
                "identified_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "utm": {
                  "type": "object",
                  "propertyNames": {
                    "type": "string"
                  },
                  "additionalProperties": {
                    "type": "string"
                  }
                },
                "visits": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "customer_id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "client": {
                  "type": "string",
                  "enum": [
                    "web",
                    "app"
                  ]
                },
                "app": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "platform": {
                          "type": "string"
                        },
                        "version": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "sdk": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "platform",
                        "version",
                        "sdk"
                      ],
                      "additionalProperties": {}
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "current_screen": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "id",
                "site_id",
                "channel",
                "email",
                "name",
                "phone",
                "avatar_url",
                "external_id",
                "custom_data",
                "locale",
                "browser",
                "os",
                "device",
                "country",
                "city",
                "current_url",
                "current_title",
                "referrer",
                "first_seen_at",
                "last_seen_at",
                "identified_at",
                "utm",
                "visits",
                "customer_id",
                "client"
              ],
              "additionalProperties": {}
            },
            "conversation": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "site_id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "visitor_id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    },
                    "channel": {
                      "type": "string"
                    },
                    "channel_account_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "open",
                        "pending",
                        "resolved",
                        "closed"
                      ]
                    },
                    "assignee_kind": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "user",
                            "bot"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assignee_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "seq": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "visitor_unread": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "agent_unread": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "last_message_at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last_message_preview": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last_message_sender_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "visitor",
                            "agent",
                            "bot",
                            "system"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_visitor_message_at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "first_response_at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "resolved_at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "member_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "flag": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "hidden",
                            "spam"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "type": "string"
                    },
                    "muted_by": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "subject": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "site_id",
                    "visitor_id",
                    "channel",
                    "status",
                    "assignee_kind",
                    "assignee_id",
                    "seq",
                    "visitor_unread",
                    "agent_unread",
                    "last_message_at",
                    "last_message_preview",
                    "last_message_sender_type",
                    "first_response_at",
                    "resolved_at",
                    "tags",
                    "member_ids",
                    "flag",
                    "subject",
                    "created_at",
                    "updated_at"
                  ],
                  "additionalProperties": {}
                },
                {
                  "type": "null"
                }
              ]
            },
            "timeline": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "conversation_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "seq": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "sender_type": {
                        "type": "string",
                        "enum": [
                          "visitor",
                          "agent",
                          "bot",
                          "system"
                        ]
                      },
                      "sender_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "sender_name": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "visibility": {
                        "type": "string",
                        "enum": [
                          "public",
                          "private"
                        ]
                      },
                      "content_type": {
                        "type": "string",
                        "enum": [
                          "text",
                          "file"
                        ]
                      },
                      "content": {
                        "type": "string"
                      },
                      "attachments": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64
                            },
                            "name": {
                              "type": "string"
                            },
                            "size": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "type": {
                              "type": "string"
                            },
                            "url": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "size",
                            "type"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      "client_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "metadata": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "delivery_status": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "pending",
                              "sent",
                              "failed"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "delivery_error": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "read_at": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "created_at": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string",
                        "const": "message"
                      }
                    },
                    "required": [
                      "id",
                      "conversation_id",
                      "seq",
                      "sender_type",
                      "sender_id",
                      "visibility",
                      "content_type",
                      "content",
                      "attachments",
                      "created_at",
                      "kind"
                    ],
                    "additionalProperties": {}
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "conversation_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "seq": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "type": {
                        "type": "string"
                      },
                      "actor_type": {
                        "type": "string",
                        "enum": [
                          "visitor",
                          "agent",
                          "bot",
                          "system"
                        ]
                      },
                      "actor_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "data": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "created_at": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string",
                        "const": "event"
                      }
                    },
                    "required": [
                      "id",
                      "conversation_id",
                      "seq",
                      "type",
                      "actor_type",
                      "actor_id",
                      "data",
                      "created_at",
                      "kind"
                    ],
                    "additionalProperties": {}
                  }
                ]
              }
            },
            "timeline_has_more": {
              "type": "boolean"
            },
            "availability": {
              "type": "object",
              "properties": {
                "online": {
                  "type": "boolean"
                },
                "within_hours": {
                  "type": "boolean"
                },
                "next_open_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "agents_online": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                }
              },
              "required": [
                "online",
                "within_hours",
                "next_open_at",
                "agents_online"
              ],
              "additionalProperties": {}
            }
          },
          "required": [
            "visitor",
            "conversation",
            "timeline",
            "availability"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "message"
        },
        "d": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "seq": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "sender_type": {
              "type": "string",
              "enum": [
                "visitor",
                "agent",
                "bot",
                "system"
              ]
            },
            "sender_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "sender_name": {
              "type": [
                "string",
                "null"
              ]
            },
            "visibility": {
              "type": "string",
              "enum": [
                "public",
                "private"
              ]
            },
            "content_type": {
              "type": "string",
              "enum": [
                "text",
                "file"
              ]
            },
            "content": {
              "type": "string"
            },
            "attachments": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "name": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "type": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "size",
                  "type"
                ],
                "additionalProperties": {}
              }
            },
            "client_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "metadata": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "delivery_status": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "pending",
                    "sent",
                    "failed"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "delivery_error": {
              "type": [
                "string",
                "null"
              ]
            },
            "read_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "created_at": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "conversation_id",
            "seq",
            "sender_type",
            "sender_id",
            "visibility",
            "content_type",
            "content",
            "attachments",
            "created_at"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "message.ack"
        },
        "d": {
          "type": "object",
          "properties": {
            "client_id": {
              "type": "string"
            },
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "seq": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "required": [
            "client_id",
            "id",
            "seq",
            "conversation_id"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "event"
        },
        "d": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "seq": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "type": {
              "type": "string"
            },
            "actor_type": {
              "type": "string",
              "enum": [
                "visitor",
                "agent",
                "bot",
                "system"
              ]
            },
            "actor_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "data": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "created_at": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "conversation_id",
            "seq",
            "type",
            "actor_type",
            "actor_id",
            "data",
            "created_at"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "typing"
        },
        "d": {
          "type": "object",
          "properties": {
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "side": {
              "type": "string",
              "enum": [
                "visitor",
                "agent"
              ]
            },
            "on": {
              "type": "boolean"
            },
            "name": {
              "type": "string"
            }
          },
          "required": [
            "conversation_id",
            "side",
            "on"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "availability"
        },
        "d": {
          "type": "object",
          "properties": {
            "online": {
              "type": "boolean"
            },
            "within_hours": {
              "type": "boolean"
            },
            "next_open_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "agents_online": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "online",
            "within_hours",
            "next_open_at",
            "agents_online"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "read"
        },
        "d": {
          "type": "object",
          "properties": {
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "side": {
              "type": "string",
              "enum": [
                "visitor",
                "agent"
              ]
            },
            "up_to_seq": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            }
          },
          "required": [
            "conversation_id",
            "side",
            "up_to_seq"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "conversation.update"
        },
        "d": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "site_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "status": {
              "type": "string",
              "enum": [
                "open",
                "pending",
                "resolved",
                "closed"
              ]
            },
            "seq": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "visitor_unread": {
              "type": "integer",
              "minimum": -9007199254740991,
              "maximum": 9007199254740991
            },
            "last_message_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "last_message_preview": {
              "type": [
                "string",
                "null"
              ]
            },
            "last_message_sender_type": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "visitor",
                    "agent",
                    "bot",
                    "system"
                  ]
                },
                {
                  "type": "null"
                }
              ]
            },
            "first_response_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "resolved_at": {
              "type": [
                "string",
                "null"
              ]
            },
            "subject": {
              "type": [
                "string",
                "null"
              ]
            },
            "created_at": {
              "type": "string"
            },
            "updated_at": {
              "type": "string"
            },
            "agent": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "avatar_url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "name",
                    "avatar_url"
                  ],
                  "additionalProperties": {}
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "id",
            "site_id",
            "status",
            "seq",
            "visitor_unread",
            "last_message_at",
            "last_message_preview",
            "last_message_sender_type",
            "first_response_at",
            "resolved_at",
            "subject",
            "created_at",
            "updated_at",
            "agent"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "resume"
        },
        "d": {
          "type": "object",
          "properties": {
            "conversation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "items": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "conversation_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "seq": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "sender_type": {
                        "type": "string",
                        "enum": [
                          "visitor",
                          "agent",
                          "bot",
                          "system"
                        ]
                      },
                      "sender_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "sender_name": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "visibility": {
                        "type": "string",
                        "enum": [
                          "public",
                          "private"
                        ]
                      },
                      "content_type": {
                        "type": "string",
                        "enum": [
                          "text",
                          "file"
                        ]
                      },
                      "content": {
                        "type": "string"
                      },
                      "attachments": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64
                            },
                            "name": {
                              "type": "string"
                            },
                            "size": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "type": {
                              "type": "string"
                            },
                            "url": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "size",
                            "type"
                          ],
                          "additionalProperties": {}
                        }
                      },
                      "client_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "metadata": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "delivery_status": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "pending",
                              "sent",
                              "failed"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "delivery_error": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "read_at": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "created_at": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string",
                        "const": "message"
                      }
                    },
                    "required": [
                      "id",
                      "conversation_id",
                      "seq",
                      "sender_type",
                      "sender_id",
                      "visibility",
                      "content_type",
                      "content",
                      "attachments",
                      "created_at",
                      "kind"
                    ],
                    "additionalProperties": {}
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "conversation_id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64
                      },
                      "seq": {
                        "type": "integer",
                        "minimum": -9007199254740991,
                        "maximum": 9007199254740991
                      },
                      "type": {
                        "type": "string"
                      },
                      "actor_type": {
                        "type": "string",
                        "enum": [
                          "visitor",
                          "agent",
                          "bot",
                          "system"
                        ]
                      },
                      "actor_id": {
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "data": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string"
                        },
                        "additionalProperties": {}
                      },
                      "created_at": {
                        "type": "string"
                      },
                      "kind": {
                        "type": "string",
                        "const": "event"
                      }
                    },
                    "required": [
                      "id",
                      "conversation_id",
                      "seq",
                      "type",
                      "actor_type",
                      "actor_id",
                      "data",
                      "created_at",
                      "kind"
                    ],
                    "additionalProperties": {}
                  }
                ]
              }
            },
            "has_more": {
              "type": "boolean"
            }
          },
          "required": [
            "conversation_id",
            "items",
            "has_more"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "conversation.start"
        },
        "d": {
          "type": "object",
          "properties": {
            "conversation": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "site_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "visitor_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "channel": {
                  "type": "string"
                },
                "channel_account_id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "open",
                    "pending",
                    "resolved",
                    "closed"
                  ]
                },
                "assignee_kind": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "user",
                        "bot"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "assignee_id": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "seq": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "visitor_unread": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "agent_unread": {
                  "type": "integer",
                  "minimum": -9007199254740991,
                  "maximum": 9007199254740991
                },
                "last_message_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "last_message_preview": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "last_message_sender_type": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "visitor",
                        "agent",
                        "bot",
                        "system"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "last_visitor_message_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "first_response_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "resolved_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "tags": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "member_ids": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "flag": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "hidden",
                        "spam"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "snoozed_until": {
                  "type": "string"
                },
                "muted_by": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "subject": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "created_at": {
                  "type": "string"
                },
                "updated_at": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "site_id",
                "visitor_id",
                "channel",
                "status",
                "assignee_kind",
                "assignee_id",
                "seq",
                "visitor_unread",
                "agent_unread",
                "last_message_at",
                "last_message_preview",
                "last_message_sender_type",
                "first_response_at",
                "resolved_at",
                "tags",
                "member_ids",
                "flag",
                "subject",
                "created_at",
                "updated_at"
              ],
              "additionalProperties": {}
            },
            "open": {
              "type": "boolean"
            }
          },
          "required": [
            "conversation",
            "open"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "session"
        },
        "d": {
          "type": "object",
          "properties": {
            "visitor_token": {
              "type": "string"
            },
            "visitor_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "reason": {
              "type": "string",
              "enum": [
                "identity_merged",
                "reset"
              ]
            }
          },
          "required": [
            "visitor_token",
            "visitor_id",
            "reason"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "identified"
        },
        "d": {
          "type": "object",
          "properties": {
            "visitor_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            },
            "verified": {
              "type": "boolean"
            }
          },
          "required": [
            "visitor_id",
            "verified"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "reload"
        },
        "d": {
          "type": "object",
          "properties": {
            "reason": {
              "type": "string"
            }
          },
          "required": [
            "reason"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "error"
        },
        "d": {
          "type": "object",
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "for": {
              "type": "string"
            }
          },
          "required": [
            "code",
            "message"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "t": {
          "type": "string",
          "const": "pong"
        },
        "d": {
          "type": "object",
          "properties": {
            "now": {
              "type": "string"
            }
          },
          "required": [
            "now"
          ],
          "additionalProperties": {}
        },
        "id": {
          "type": "string"
        },
        "v": {
          "type": "number"
        }
      },
      "required": [
        "t",
        "d"
      ],
      "additionalProperties": false
    }
  ]
}
