{"protocol_version":1,"limits":{"frameBytes":16384,"visitorText":4000,"agentText":10000,"attachmentsPerMessage":5,"attachmentBytes":10485760,"customDataBytes":8192},"close_codes":{"4001":"auth_timeout","4003":"auth_failed","4004":"protocol_outdated","4005":"session_replaced"},"error_codes":["validation_error","rate_limit_exceeded","not_found","unauthenticated","invalid_visitor_token","origin_not_allowed","site_disabled","invalid_app_key","app_key_revoked","conversation_closed","file_too_large","unsupported_file_type","bad_frame","error"],"ping_interval_ms":25000,"auth_timeout_ms":5000,"request_timeout_ms":10000,"backoff":{"base_ms":500,"max_ms":30000,"jitter_ms":500,"immediate_on_close":[4005]},"visitor_frames":{"$id":"https://hatang.dev/schema/chat-protocol/v1/visitor-frames.json","title":"Ha Tang chat protocol v1: visitor → server frames","$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"type":"object","properties":{"t":{"type":"string","const":"auth"},"id":{"type":"string"},"v":{"type":"number"},"d":{"type":"object","properties":{"token":{"type":"string","maxLength":2048},"site_id":{"type":"string","minLength":1,"maxLength":64},"page":{"type":"object","properties":{"url":{"type":"string","maxLength":2048},"title":{"type":"string","maxLength":300},"referrer":{"type":"string","maxLength":2048}},"required":["url"]},"screen":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"params":{"type":"object","propertyNames":{"type":"string","maxLength":60},"additionalProperties":{"type":"string","maxLength":500}}},"required":["name"]},"app":{"type":"object","properties":{"install_id":{"type":"string","minLength":8,"maxLength":128},"version":{"type":"string","maxLength":40},"sdk":{"type":"string","maxLength":60},"os":{"type":"string","maxLength":20},"os_version":{"type":"string","maxLength":40},"device_model":{"type":"string","maxLength":80},"locale":{"type":"string","maxLength":10}},"required":["install_id"]},"client":{"type":"object","properties":{"sdk":{"type":"string","maxLength":40},"version":{"type":"string","maxLength":40}},"required":["sdk","version"]},"locale":{"type":"string","maxLength":10},"app_state":{"type":"object","properties":{"foreground":{"type":"boolean"}},"required":["foreground"]}},"required":["token","site_id"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"page"},"id":{"type":"string"},"d":{"type":"object","properties":{"url":{"type":"string","maxLength":2048},"title":{"type":"string","maxLength":300},"referrer":{"type":"string","maxLength":2048}},"required":["url"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"screen"},"id":{"type":"string"},"d":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"params":{"type":"object","propertyNames":{"type":"string","maxLength":60},"additionalProperties":{"type":"string","maxLength":500}}},"required":["name"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"app.state"},"id":{"type":"string"},"d":{"type":"object","properties":{"foreground":{"type":"boolean"},"conversation_id":{"anyOf":[{"type":"string","minLength":1,"maxLength":64},{"type":"null"}]}},"required":["foreground"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"message.send"},"id":{"type":"string"},"d":{"type":"object","properties":{"conversation_id":{"type":"string","minLength":1,"maxLength":64},"client_id":{"type":"string","minLength":1,"maxLength":64},"content":{"type":"string","maxLength":4000},"attachments":{"maxItems":5,"type":"array","items":{"type":"string","minLength":1,"maxLength":64}}},"required":["client_id","content"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"typing"},"id":{"type":"string"},"d":{"type":"object","properties":{"conversation_id":{"type":"string","minLength":1,"maxLength":64},"on":{"type":"boolean"}},"required":["conversation_id","on"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"read"},"id":{"type":"string"},"d":{"type":"object","properties":{"conversation_id":{"type":"string","minLength":1,"maxLength":64},"up_to_seq":{"type":"integer","minimum":0,"maximum":2147483647}},"required":["conversation_id","up_to_seq"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"identify"},"id":{"type":"string"},"d":{"type":"object","properties":{"user_id":{"type":"string","maxLength":200},"email":{"type":"string","maxLength":320,"format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},"name":{"type":"string","maxLength":200},"phone":{"type":"string","maxLength":40},"hash":{"type":"string","maxLength":128},"data":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}}}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"event"},"id":{"type":"string"},"d":{"type":"object","properties":{"name":{"type":"string","maxLength":100},"data":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{}}},"required":["name"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"resume"},"id":{"type":"string"},"d":{"type":"object","properties":{"conversation_id":{"type":"string","minLength":1,"maxLength":64},"after_seq":{"type":"integer","minimum":0,"maximum":2147483647}},"required":["conversation_id","after_seq"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"rate"},"id":{"type":"string"},"d":{"type":"object","properties":{"conversation_id":{"type":"string","minLength":1,"maxLength":64},"score":{"type":"integer","minimum":1,"maximum":5},"comment":{"type":"string","maxLength":1000}},"required":["conversation_id","score"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"campaign"},"id":{"type":"string"},"d":{"type":"object","properties":{"campaign_id":{"type":"string","minLength":1,"maxLength":64},"action":{"type":"string","enum":["shown","clicked","open","submit"]},"button":{"type":"string","maxLength":40},"fields":{"type":"object","properties":{"name":{"type":"string","maxLength":200},"phone":{"type":"string","maxLength":40},"email":{"type":"string","maxLength":320,"format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"}}}},"required":["campaign_id","action"]}},"required":["t","d"]},{"type":"object","properties":{"t":{"type":"string","const":"ping"},"id":{"type":"string"},"d":{"type":"null"}},"required":["t"]}]},"server_frames":{"$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}]},"http":{"$id":"https://hatang.dev/schema/chat-protocol/v1/http.json","title":"Ha Tang chat protocol v1: HTTP shapes","bootstrap":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"visitor_token":{"type":"string"},"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":{}},"config":{"type":"object","properties":{"site_id":{"type":"string","minLength":1,"maxLength":64},"name":{"type":"string"},"color":{"type":"string"},"position":{"type":"string","enum":["right","left"]},"locale_default":{"type":"string","enum":["vi","en","auto"]},"greeting":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"away_message":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"offline_capture":{"type":"string","enum":["email_required","email_optional","off"]},"hide_when_offline":{"type":"boolean"},"theme":{"type":"string","enum":["light","dark","auto"]},"bot_enabled":{"type":"boolean"},"agent_avatars":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"avatar_url":{"type":["string","null"]}},"required":["name","avatar_url"],"additionalProperties":{}}},"launcher":{"type":"object","properties":{"icon":{"type":"string"},"image_url":{"type":["string","null"]},"label":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}}},"required":["icon","image_url","label"],"additionalProperties":{}},"header":{"type":"object","properties":{"subtitle":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"logo_url":{"type":["string","null"]},"profile":{"type":"string","enum":["agents","business"]}},"required":["subtitle","logo_url","profile"],"additionalProperties":{}},"greeting_options":{"type":"object","properties":{"enabled":{"type":"boolean"},"on_mobile":{"type":"boolean"},"sender":{"type":"string","enum":["none","online_agent"]},"teaser_seconds":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["enabled","on_mobile","sender","teaser_seconds"],"additionalProperties":{}},"contact_buttons":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["zalo","messenger","phone","email"]},"url":{"type":"string"},"label":{"type":"string"}},"required":["kind","url","label"],"additionalProperties":{}}},"layout":{"type":"object","properties":{"size":{"type":"string","enum":["s","m","l"]},"offset":{"anyOf":[{"type":"object","properties":{"bottom":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"side":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["bottom","side"],"additionalProperties":{}},{"type":"null"}]},"mobile_offset":{"anyOf":[{"type":"object","properties":{"bottom":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"side":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["bottom","side"],"additionalProperties":{}},{"type":"null"}]}},"required":["size","offset","mobile_offset"],"additionalProperties":{}},"prechat":{"type":"object","properties":{"enabled":{"type":"boolean"},"fields":{"type":"object","properties":{"name":{"type":"string","enum":["off","optional","required"]},"phone":{"type":"string","enum":["off","optional","required"]},"email":{"type":"string","enum":["off","optional","required"]}},"required":["name","phone","email"],"additionalProperties":{}}},"required":["enabled","fields"],"additionalProperties":{}},"visibility":{"type":"object","properties":{"devices":{"type":"string","enum":["all","desktop","mobile"]},"url_include":{"type":"array","items":{"type":"string"}},"url_exclude":{"type":"array","items":{"type":"string"}}},"required":["devices","url_include","url_exclude"],"additionalProperties":{}},"notifications":{"type":"object","properties":{"sound":{"type":"boolean"},"title_alert":{"type":"boolean"}},"required":["sound","title_alert"],"additionalProperties":{}},"allow_in_iframe":{"type":"boolean"}},"required":["site_id","name","color","position","locale_default","greeting","away_message","offline_capture","hide_when_offline","theme","bot_enabled","agent_avatars"],"additionalProperties":{}},"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":{}},"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"},"bundle":{"type":"string"},"ws_url":{"type":"string"},"protocol_version":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"app":{"anyOf":[{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":64},"platform":{"type":"string"}},"required":["id","platform"],"additionalProperties":{}},{"type":"null"}]}},"required":["visitor_token","visitor","config","availability","conversation","timeline","bundle","ws_url","protocol_version","app"],"additionalProperties":{}},"message_card":{"$schema":"https://json-schema.org/draft/2020-12/schema","oneOf":[{"type":"object","properties":{"kind":{"type":"string","const":"product"},"products":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"price":{"type":"number"},"compare_at_price":{"type":["number","null"]},"currency":{"type":"string"},"image_url":{"type":["string","null"]},"url":{"type":["string","null"]},"sku":{"type":["string","null"]},"store_product_ids":{"anyOf":[{"type":"object","properties":{"app_store":{"type":["string","null"]},"google_play":{"type":["string","null"]}},"additionalProperties":{}},{"type":"null"}]},"base_plan_id":{"type":["string","null"]},"offer_id":{"type":["string","null"]},"billing_period":{"type":["string","null"]},"trial_days":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]}},"required":["id","name","price","currency"],"additionalProperties":{}}},"intro":{"type":"string"}},"required":["kind","products"],"additionalProperties":{}},{"type":"object","properties":{"kind":{"type":"string","const":"order"},"order":{"type":"object","properties":{"id":{"type":"string"},"code":{"type":"string"},"status":{"type":"string"},"items":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"quantity":{"type":"number"},"price":{"type":"number"},"variant":{"type":["string","null"]}},"required":["name","quantity","price"],"additionalProperties":{}}},"subtotal":{"type":"number"},"discount":{"type":"number"},"shipping":{"type":"number"},"total":{"type":"number"},"currency":{"type":"string"},"payment_status":{"type":"string","enum":["unpaid","paid"]}},"required":["id","code","status","items","subtotal","discount","shipping","total","currency","payment_status"],"additionalProperties":{}},"intro":{"type":"string"}},"required":["kind","order"],"additionalProperties":{}},{"type":"object","properties":{"kind":{"type":"string","const":"payment"},"payment":{"type":"object","properties":{"id":{"type":"string"},"order_id":{"type":["string","null"]},"order_code":{"type":["string","null"]},"amount":{"type":"number"},"currency":{"type":"string"},"checkout_url":{"type":"string"},"qr_image_url":{"type":"string"},"qr_payload":{"type":"string"},"code":{"type":"string"},"expires_at":{"type":["string","null"]},"status":{"type":"string"}},"required":["id","order_id","order_code","amount","currency","checkout_url","qr_image_url","code","expires_at","status"],"additionalProperties":{}},"intro":{"type":"string"}},"required":["kind","payment"],"additionalProperties":{}},{"type":"object","properties":{"kind":{"type":"string","const":"quick_replies"},"options":{"type":"array","items":{"type":"string"}}},"required":["kind","options"],"additionalProperties":{}},{"type":"object","properties":{"kind":{"type":"string","const":"csat"},"options":{"type":"array","items":{"type":"string"}},"answered":{"type":"boolean"}},"required":["kind","options"],"additionalProperties":{}}]}}}