asyncapi: 3.0.0 info: title: Retail CRM Bot API version: 1.0.0 description: WebSocket API for receiving events from the Retail CRM Bot platform. servers: production: host: mg.rcrm-tech.ru pathname: /api/bot/v1/ws protocol: wss description: Production server for WebSocket connections bindings: ws: method: GET headers: type: object properties: Authorization: type: string description: Authorization token for WebSocket connection channels: events: address: events={events}&options={options} description: Channel for receiving various events from the system. parameters: events: description: Comma-separated list of events to subscribe to examples: - message_new,dialog_opened,user_joined_chat options: description: Comma-separated list of additional options bindings: ws: method: GET query: type: object properties: events: type: string description: Comma-separated list of events to subscribe to options: type: string description: Comma-separated list of additional options messages: event: name: event title: Event from Retail CRM Bot summary: Common interface for all system events description: Unified message type representing all system events. The specific type is determined by the `type` field. contentType: application/json payload: $ref: '#/components/schemas/Event' operations: receiveEvents: action: receive channel: $ref: '#/channels/events' summary: Receiving events from the Retail CRM Bot platform description: Connection for receiving various types of events in real-time messages: - $ref: '#/channels/events/messages/event' components: schemas: Event: description: Event type: object discriminator: type oneOf: - $ref: '#/components/schemas/EventMessageNew' - $ref: '#/components/schemas/EventMessageUpdated' - $ref: '#/components/schemas/EventFileUpdated' - $ref: '#/components/schemas/EventMessageDeleted' - $ref: '#/components/schemas/EventMessageRestored' - $ref: '#/components/schemas/EventChatCreated' - $ref: '#/components/schemas/EventChatUpdated' - $ref: '#/components/schemas/EventChatDeleted' - $ref: '#/components/schemas/EventDialogOpened' - $ref: '#/components/schemas/EventDialogAssign' - $ref: '#/components/schemas/EventDialogClosed' - $ref: '#/components/schemas/EventUserOnlineUpdated' - $ref: '#/components/schemas/EventUserJoinedChat' - $ref: '#/components/schemas/EventUserLeftChat' - $ref: '#/components/schemas/EventUserUpdated' - $ref: '#/components/schemas/EventCustomerUpdated' - $ref: '#/components/schemas/EventBotUpdated' - $ref: '#/components/schemas/EventChannelUpdated' required: - type - meta - data properties: type: $ref: '#/components/schemas/EventType' meta: $ref: '#/components/schemas/Meta' data: type: object description: Data depending on the event type Meta: description: Event metadata type: object required: - timestamp properties: timestamp: type: integer description: Unix-timestamp of the event occurrence time EventMessageNew: description: New message event type: object required: - type - data properties: type: type: string enum: - message_new data: $ref: '#/components/schemas/MessageData' EventMessageUpdated: description: Message update event type: object required: - type - data properties: type: type: string enum: - message_updated data: $ref: '#/components/schemas/MessageData' EventFileUpdated: description: File update event type: object required: - type - data properties: type: type: string enum: - file_updated data: $ref: '#/components/schemas/FileUpdatedData' EventMessageDeleted: description: Message deletion event type: object required: - type - data properties: type: type: string enum: - message_deleted data: $ref: '#/components/schemas/MessageData' EventMessageRestored: description: Message restoration event type: object required: - type - data properties: type: type: string enum: - message_restored data: $ref: '#/components/schemas/MessageData' EventChatCreated: description: Chat creation event type: object required: - type - data properties: type: type: string enum: - chat_created data: $ref: '#/components/schemas/ChatData' EventChatUpdated: description: Chat update event type: object required: - type - data properties: type: type: string enum: - chat_updated data: $ref: '#/components/schemas/ChatData' EventChatDeleted: description: Chat deletion event type: object required: - type - data properties: type: type: string enum: - chats_deleted data: $ref: '#/components/schemas/ChatsDeletedData' EventDialogOpened: description: Dialog opening event type: object required: - type - data properties: type: type: string enum: - dialog_opened data: $ref: '#/components/schemas/DialogData' EventDialogAssign: description: Dialog assignment event type: object required: - type - data properties: type: type: string enum: - dialog_assign data: $ref: '#/components/schemas/DialogAssignData' EventDialogClosed: description: Dialog closing event type: object required: - type - data properties: type: type: string enum: - dialog_closed data: $ref: '#/components/schemas/DialogData' EventUserOnlineUpdated: description: User status update event (online/offline) type: object required: - type - data properties: type: type: string enum: - user_online_updated data: $ref: '#/components/schemas/UserOnlineUpdatedData' EventUserJoinedChat: description: User joined chat event type: object required: - type - data properties: type: type: string enum: - user_joined_chat data: $ref: '#/components/schemas/UserJoinedChatData' EventUserLeftChat: description: User left chat event type: object required: - type - data properties: type: type: string enum: - user_left_chat data: $ref: '#/components/schemas/UserLeftChatData' EventUserUpdated: description: User data update event type: object required: - type - data properties: type: type: string enum: - user_updated data: $ref: '#/components/schemas/UserUpdatedData' EventCustomerUpdated: description: Customer data update event type: object required: - type - data properties: type: type: string enum: - customer_updated data: $ref: '#/components/schemas/CustomerUpdatedData' EventBotUpdated: description: Bot data update event type: object required: - type - data properties: type: type: string enum: - bot_updated data: $ref: '#/components/schemas/BotUpdatedData' EventChannelUpdated: description: Channel data update event type: object required: - type - data properties: type: type: string enum: - channel_updated data: $ref: '#/components/schemas/ChannelUpdatedData' MessageData: description: Message data type: object required: - message properties: message: allOf: - $ref: '#/components/schemas/Message' - $ref: '#/components/schemas/MessageAdditional' ChatData: description: Chat data type: object required: - chat properties: chat: $ref: '#/components/schemas/Chat' DialogData: description: Dialog data type: object required: - dialog properties: dialog: $ref: '#/components/schemas/DialogEvent' ChatsDeletedData: description: Deleted chats data type: object required: - chat_ids properties: chat_ids: type: array items: type: integer DialogAssignData: description: Dialog assignment data type: object required: - dialog - chat properties: dialog: $ref: '#/components/schemas/DialogEvent' chat: $ref: '#/components/schemas/Chat' UserOnlineUpdatedData: description: User status update data type: object required: - user - online - connected properties: user: $ref: '#/components/schemas/UserRef' online: description: Flag indicating that the user is online type: boolean connected: description: Flag indicating that the user is connected type: boolean UserJoinedChatData: description: User joined chat data type: object required: - chat - user properties: chat: $ref: '#/components/schemas/Chat' user: $ref: '#/components/schemas/UserRef' UserLeftChatData: description: User left chat data type: object required: - reason properties: reason: description: Reason for user leaving the chat type: string chat: $ref: '#/components/schemas/ChatID' user: $ref: '#/components/schemas/UserID' UserUpdatedData: description: User information update data type: object allOf: - $ref: '#/components/schemas/UserRef' - required: - is_active properties: is_active: description: User activity flag type: boolean CustomerUpdatedData: description: Customer information update data $ref: '#/components/schemas/UserRef' BotUpdatedData: description: Bot information update data $ref: '#/components/schemas/UserRef' ChannelUpdatedData: description: Channel update data type: object properties: channel: $ref: '#/components/schemas/Channel' Chat: type: object required: - id - last_activity - created_at properties: id: description: Chat ID type: integer name: description: Chat name type: string avatar: description: Avatar URL type: string format: uri unread: description: Unread chat flag type: boolean not_read_messages_count: description: Number of unread messages type: integer last_activity: description: Date and time of last activity type: string format: date-time author_id: description: Author ID type: integer deprecated: true customer: $ref: '#/components/schemas/UserRef' channel: $ref: '#/components/schemas/Channel' last_message: description: Last message in the chat $ref: '#/components/schemas/Message' last_user_message: description: Last user message in the chat $ref: '#/components/schemas/MessageID' last_dialog: description: Last dialog in the chat $ref: '#/components/schemas/Dialog' members: description: Chat participants type: array items: $ref: '#/components/schemas/Member' waiting_level: $ref: '#/components/schemas/WaitingLevel' waiting_level_transition_time: description: Time of transition to the next waiting level type: string format: date-time reply_deadline: description: Reply deadline time type: string format: date-time created_at: description: Creation date and time type: string format: date-time DialogEvent: type: object required: - id - created_at properties: id: description: Dialog ID type: integer begin_message_id: description: ID of the starting message of the dialog type: integer ending_message_id: description: ID of the ending message of the dialog type: integer chat: $ref: '#/components/schemas/Chat' responsible: $ref: '#/components/schemas/Responsible' created_at: description: Dialog creation date and time type: string format: date-time assigned_at: description: Dialog assignment date and time type: string format: date-time closed_at: description: Dialog closing date and time type: string format: date-time utm: description: UTM tags $ref: '#/components/schemas/Utm' Dialog: type: object required: - id - created_at properties: id: description: Dialog ID type: integer responsible: $ref: '#/components/schemas/UserRef' created_at: description: Dialog creation date and time type: string format: date-time assigned_at: description: Dialog assignment date and time type: string format: date-time closed_at: description: Dialog closing date and time type: string format: date-time utm: description: UTM tags $ref: '#/components/schemas/Utm' Utm: type: object properties: source: description: Source type: string maxLength: 255 minLength: 1 medium: description: Medium type: string maxLength: 255 minLength: 1 campaign: description: Campaign type: string maxLength: 255 minLength: 1 term: description: Keyword type: string maxLength: 255 minLength: 1 content: description: Campaign content type: string maxLength: 255 minLength: 1 Message: type: object required: - id - time - type - scope - chat_id - is_read - is_edit - status - created_at properties: id: description: Message ID type: integer type: $ref: '#/components/schemas/MessageType' time: description: Message creation time type: string format: date-time chat_id: description: Chat ID type: integer is_read: description: Message read flag type: boolean is_edit: description: Message edited flag type: boolean scope: $ref: '#/components/schemas/MessageScope' status: $ref: '#/components/schemas/MessageStatus' actions: description: Actions available for this message type: array items: type: string from: $ref: '#/components/schemas/UserRef' content: description: Message text type: string note: description: Annotation to media data (for media messages) type: string quote: $ref: '#/components/schemas/MessageQuote' dialog: $ref: '#/components/schemas/MessageDialog' items: description: Message attachments type: array items: $ref: '#/components/schemas/MessageFile' transport_attachments: description: Message transport attachments $ref: '#/components/schemas/MessageTransportAttachments' order: description: Order information in the message $ref: '#/components/schemas/MessageOrder' product: description: Product information in the message $ref: '#/components/schemas/MessageProduct' error: description: Message error information $ref: '#/components/schemas/MessageError' action: description: System action of the message $ref: '#/components/schemas/MessageAction' responsible: description: Information about the person responsible for the message $ref: '#/components/schemas/UserRef' reactions: description: Reaction emojis added to a message type: array items: $ref: '#/components/schemas/MessageReaction' MessageAdditional: type: object properties: chat: $ref: '#/components/schemas/Chat' created_at: description: Message creation date type: string format: date-time edited_at: description: Message edit date type: string format: date-time template_code: description: Template code for a template message type: string Responsible: description: Information about the responsible person type: object required: - type - id properties: type: $ref: '#/components/schemas/ResponsibleType' id: description: Responsible ID type: integer assigned_at: description: Assignment date/time type: string format: date-time UserRef: type: object required: - id - external_id - type - name properties: id: description: User ID type: integer external_id: description: External user ID type: string type: $ref: '#/components/schemas/UserType' name: description: User nickname type: string avatar: description: User avatar type: string format: uri first_name: description: User first name (only for customer and user types) type: string last_name: description: User last name (only for customer and user types) type: string available: description: Client availability status flag (only for user type) type: boolean is_blocked: description: User blocked flag (only for customer type) type: boolean is_system: description: System user flag (only for bot type) type: boolean is_technical_account: description: Technical account flag (only for user type) type: boolean username: description: Username (only for customer type) type: string email: description: User email (only for customer type) type: string format: email phone: description: User phone number type: string MessageProduct: type: object required: - id - name properties: id: description: Product ID type: integer name: description: Product name type: string maxLength: 255 minLength: 1 article: description: Product description type: string maxLength: 128 cost: $ref: '#/components/schemas/Cost' img: description: Product image URL type: string format: uri maxLength: 2048 url: description: Product URL type: string format: uri maxLength: 2048 unit: description: Product units of measurement type: string maxLength: 16 revoked_at: description: Registration revocation date/time type: string Cost: description: Cost information type: object properties: value: description: Numerical cost value type: number format: double minimum: 0 currency: description: Currency code type: string maxLength: 3 minLength: 3 MessageOrder: description: Order information in message type: object properties: external_id: description: External order ID type: integer number: description: Order number type: string maxLength: 255 url: description: Order URL type: string format: uri maxLength: 2048 cost: $ref: '#/components/schemas/Cost' discount: $ref: '#/components/schemas/Cost' date: description: Order creation date type: string format: date-time status: $ref: '#/components/schemas/MessageOrderStatus' items: description: Array of order products type: array items: $ref: '#/components/schemas/MessageOrderItem' delivery: $ref: '#/components/schemas/MessageOrderDelivery' payments: description: Array of payments type: array items: $ref: '#/components/schemas/MessageOrderPayment' MessageOrderStatus: description: Order status type: object properties: code: $ref: '#/components/schemas/MessageOrderStatusCode' name: description: Status name type: string maxLength: 255 MessageOrderItem: description: Order product information type: object properties: external_id: description: External ID of the order product type: integer name: description: Product name type: string maxLength: 255 url: description: Product URL type: string format: uri maxLength: 2048 img: description: Product image type: string format: uri maxLength: 2048 price: $ref: '#/components/schemas/Cost' quantity: $ref: '#/components/schemas/Quantity' Quantity: description: Quantity information type: object properties: value: description: Quantity value type: number format: double minimum: 0 unit: description: Units of measurement type: string maxLength: 16 MessageOrderDelivery: description: Order delivery data type: object properties: name: description: Delivery method name type: string price: $ref: '#/components/schemas/Cost' address: description: Delivery address type: string comment: description: Delivery comment type: string MessageOrderPayment: description: Order payment data type: object properties: name: description: Payment method name type: string amount: $ref: '#/components/schemas/Cost' status: $ref: '#/components/schemas/MessageOrderPaymentStatus' MessageOrderPaymentStatus: description: Order payment status type: object properties: name: description: Payment name type: string payed: description: Payment completion flag type: boolean MessageFile: description: Message file information type: object required: - id - kind properties: id: description: Attached file UUID type: string kind: $ref: '#/components/schemas/MessageFileKind' type: description: Attachment type type: string preview_url: description: File URL for download type: string format: uri size: description: Attachment size (in bytes) type: integer caption: description: Text description of media attachment type: string width: description: Image width in pixels (only for image type messages) type: integer height: description: Image height in pixels (only for image type messages) type: integer duration: description: Audio recording duration (only for audio type messages) type: integer histogram: description: Sound diagram (only for audio type messages) type: array items: type: integer transcription: description: Uploaded file transcription type: string FileUpdatedData: description: Updated file data type: object required: - file properties: file: $ref: '#/components/schemas/File' File: description: File information type: object required: - id properties: id: description: File UUID type: string transcription: description: File transcription type: string transcription_status: $ref: '#/components/schemas/FileTranscriptionStatus' MessageDialog: description: Dialog data in message type: object properties: id: description: Dialog ID type: integer MessageError: description: Message error information type: object properties: code: $ref: '#/components/schemas/MessageErrorCode' message: description: Text description of the error type: string MessageQuote: description: Quoted message data type: object properties: id: description: Quoted message ID type: integer type: $ref: '#/components/schemas/MessageType' content: description: Message text type: string from: $ref: '#/components/schemas/UserRef' time: description: Message sending time type: string format: date-time items: description: Media attachments of the quoted message type: array items: $ref: '#/components/schemas/MessageFile' MessageTransportAttachments: description: Message transport attachments type: object properties: suggestions: description: Quick replies type: array items: $ref: '#/components/schemas/Suggestion' Suggestion: description: Quick reply type: object properties: title: description: Quick reply name type: string payload: description: Quick reply content type: string type: $ref: '#/components/schemas/SuggestionType' Channel: type: object required: - id - transport_id - type - is_active properties: id: description: Channel ID type: integer transport_id: description: Channel transport ID type: integer type: $ref: '#/components/schemas/ChannelType' name: description: Channel name type: string avatar: description: Channel avatar type: string format: uri is_active: description: Channel activity flag type: boolean settings: $ref: '#/components/schemas/ChannelSettings' ChannelSettings: description: Channel settings type: object properties: text: $ref: '#/components/schemas/TextMessageSetting' audio: $ref: '#/components/schemas/AudioMessageSetting' file: $ref: '#/components/schemas/FileMessageSetting' image: $ref: '#/components/schemas/ImageMessageSetting' order: $ref: '#/components/schemas/OrderMessageSetting' product: $ref: '#/components/schemas/ProductMessageSetting' customer_external_id: $ref: '#/components/schemas/CustomerExternalId' sending_policy: $ref: '#/components/schemas/SendingPolicy' status: $ref: '#/components/schemas/StatusSetting' suggestions: $ref: '#/components/schemas/Suggestions' template: $ref: '#/components/schemas/TemplateSetting' whatsapp: $ref: '#/components/schemas/WAChannelProperties' reactions: $ref: '#/components/schemas/Reactions' TextMessageSetting: description: Text message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' editing: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' max_chars_count: description: Maximum number of characters in a text message type: integer markup_formats: description: Supported text markup formats. Empty or absent list means markup is not supported. type: array items: $ref: '#/components/schemas/MarkupFormat' MarkupFormat: description: Supported text markup format type: string enum: - bold - italic - underline - strikethrough - inline_monospace - block_monospace - link AudioMessageSetting: description: Audio message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' max_item_size: description: Maximum audio size for sending type: integer max_items_count: description: Maximum number of audio attachments in a message type: integer FileMessageSetting: description: File message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' editing: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' max_item_size: description: Maximum file size for sending type: integer max_items_count: description: Maximum number of file attachments in a message type: integer note_max_chars_count: description: Maximum number of characters in a file message annotation type: integer ImageMessageSetting: description: Media message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' editing: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' max_item_size: description: Maximum image size for sending type: integer max_items_count: description: Maximum number of media attachments in a message type: integer note_max_chars_count: description: Maximum number of characters in a media message annotation type: integer OrderMessageSetting: description: Order message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' editing: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' ProductMessageSetting: description: Product message support type: object properties: creating: $ref: '#/components/schemas/ChannelFeature' deleting: $ref: '#/components/schemas/ChannelFeature' editing: $ref: '#/components/schemas/ChannelFeature' reaction: $ref: '#/components/schemas/ChannelFeature' quoting: $ref: '#/components/schemas/ChannelFeature' StatusSetting: description: Message status information transmission type: object properties: delivered: $ref: '#/components/schemas/ChannelFeature' read: $ref: '#/components/schemas/ChannelFeature' SendingPolicy: description: Message sending policy type: object properties: after_reply_timeout: $ref: '#/components/schemas/SendingPolicyAfterReplyTimeout' new_customer: $ref: '#/components/schemas/SendingPolicyNewCustomer' outgoing: $ref: '#/components/schemas/SendingPolicyOutgoing' Suggestions: description: Quick reply types support type: object properties: email: $ref: '#/components/schemas/ChannelFeature' phone: $ref: '#/components/schemas/ChannelFeature' text: $ref: '#/components/schemas/ChannelFeature' url: $ref: '#/components/schemas/ChannelFeature' TemplateSetting: description: Message templates support type: object properties: creation: description: Support for creating templates in the system type: boolean sending: description: Support for sending templates from the system type: boolean WAChannelProperties: description: WhatsApp channel properties type: object properties: channel_quality: $ref: '#/components/schemas/WAChannelQuality' channel_status: $ref: '#/components/schemas/WAChannelStatus' tier: type: integer Reactions: description: Support for working with message reactions type: object required: - dictionary - max_count properties: dictionary: description: Dictionary of available reactions type: array items: type: string max_count: description: Maximum number of reactions added from the system type: integer Member: description: Chat participant type: object required: - is_author - state properties: is_author: description: Chat authorship flag type: boolean deprecated: true state: $ref: '#/components/schemas/MemberState' user: $ref: '#/components/schemas/UserRef' ChatID: description: Object with chat ID type: object required: - id properties: id: description: Chat ID type: integer UserID: description: Object with user ID type: object required: - id properties: id: description: User ID type: integer MessageID: description: Object with message ID type: object required: - id properties: id: description: Message ID type: integer EventType: type: string description: Event type defining the structure of the data field enum: - message_new - message_updated - file_updated - message_deleted - message_restored - chat_created - chat_updated - chats_deleted - dialog_opened - dialog_assign - dialog_closed - user_online_updated - user_joined_chat - user_left_chat - user_updated - customer_updated - bot_updated - channel_updated WaitingLevel: description: Waiting level type: string enum: - warning - danger - none MessageType: description: Message type type: string enum: - text - system - command - order - product - file - image - audio MessageScope: description: Message visibility scope type: string enum: - undefined - public - private MessageStatus: description: Message status type: string enum: - undefined - received - sending - sent - failed - seen ResponsibleType: type: string description: Responsible type enum: - user - bot UserType: description: User type type: string enum: - user - bot - customer - channel MessageOrderStatusCode: description: Status code type: string enum: - new - approval - assembling - delivery - complete - cancel MessageFileKind: description: File type type: string enum: - none - image - video - file - audio FileTranscriptionStatus: description: File transcription status type: string enum: - in_progress - ready - error MessageErrorCode: description: Error code type: string enum: - unknown - network_error - malformed_response - async_send_timeout - general - customer_not_exists - reply_timed_out - spam_suspicion - access_restricted MessageAction: description: Message system action (only for system type messages) type: string enum: - dialog_opened - dialog_closed - user_joined - user_left - dialog_assign - customer_blocked - customer_unblocked - dialog_unassign - dialog_tag_added - dialog_tag_removed SuggestionType: description: Quick reply type type: string enum: - text - email - phone - url ChannelType: description: Channel type type: string enum: - telegram - tiktok - fbmessenger - viber - whatsapp - skype - vk - instagram - consultant - yandex_chat - odnoklassniki - max - ozon - wildberries - yandex_market - mega_market - avito - drom - youla - custom ChannelFeature: description: Support for operations with messages of this type type: string enum: - none - receive - send - both CustomerExternalId: description: Support for customer external IDs type: string enum: - any - phone SendingPolicyAfterReplyTimeout: description: Message types for sending after reply timeout type: string enum: - no - template SendingPolicyNewCustomer: description: Message types for sending to a new customer type: string enum: - no - template - text SendingPolicyOutgoing: description: Outgoing messages support type: string enum: - allowed - restricted WAChannelQuality: description: WhatsApp channel quality type: string enum: - high - medium - low WAChannelStatus: description: WhatsApp channel status type: string enum: - connected - flagged - offline - pending - restricted MemberState: description: Chat participant state type: string enum: - active - kicked - leaved - undefined MessageReaction: description: The object of the reaction added to the message type: object required: - content - created_at properties: content: type: string description: Emoji reaction content user_id: type: integer description: ID of the user who added the reaction created_at: type: string format: date-time description: Reaction creation timestamp