{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "title": "ConversationExportModel",
  "type": "object",
  "description": "Модель экспорта диалога.",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "description": "Идентификатор беседы."
    },
    "channelId": {
      "type": "string",
      "description": "Идентификатор канала."
    },
    "status": {
      "description": "Статус беседы.",
      "oneOf": [
        {
          "$ref": "#/definitions/ConversationStatus"
        }
      ]
    },
    "closingStatus": {
      "description": "Статус закрытия беседы.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/ConversationClosingStatus"
        }
      ]
    },
    "closingReason": {
      "description": "Причина закрытия беседы.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/ConversationClosingReason"
        }
      ]
    },
    "channelData": {
      "description": "Данные о канале ELMA365.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/ChannelData"
        }
      ]
    },
    "members": {
      "type": "array",
      "description": "Участники беседы.",
      "items": {
        "$ref": "#/definitions/MemberExportModel"
      }
    },
    "history": {
      "type": "array",
      "description": "История сообщений беседы.",
      "items": {
        "anyOf": [
          {
            "$ref": "#/definitions/EventActivityExportModel"
          },
          {
            "$ref": "#/definitions/CreateElma365AppElementActivityExportModel"
          },
          {
            "$ref": "#/definitions/CustomEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/ErrorEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/MenuItemSelectedEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/PrompterEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/ScenarioStartedEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/StartProcessActivityExportModel"
          },
          {
            "$ref": "#/definitions/TriggerFiredEventActivityExportModel"
          },
          {
            "$ref": "#/definitions/SuccessfulServiceEventExportModel"
          },
          {
            "$ref": "#/definitions/MessageActivityExportModel"
          }
        ]
      }
    }
  },
  "definitions": {
    "ConversationStatus": {
      "type": "string",
      "description": "Статус беседы.",
      "x-enumNames": [
        "Active",
        "Closed",
        "Operator"
      ],
      "enum": [
        "Active",
        "Closed",
        "Operator"
      ]
    },
    "ConversationClosingStatus": {
      "type": "string",
      "description": "Статус закрытия беседы.",
      "x-enumNames": [
        "NotInitiated",
        "Initiated",
        "ClosingMessageSent",
        "DialogResetEventSent",
        "SessionClosed"
      ],
      "enum": [
        "NotInitiated",
        "Initiated",
        "ClosingMessageSent",
        "DialogResetEventSent",
        "SessionClosed"
      ]
    },
    "ConversationClosingReason": {
      "type": "string",
      "description": "Причина закрытия беседы.",
      "x-enumNames": [
        "TimedOut",
        "ClosedByScenarioAction",
        "ClosedByOperator",
        "ConversationRestarted"
      ],
      "enum": [
        "TimedOut",
        "ClosedByScenarioAction",
        "ClosedByOperator",
        "ConversationRestarted"
      ]
    },
    "ChannelData": {
      "type": "object",
      "description": "Данные о канале ELMA365.",
      "additionalProperties": false,
      "properties": {
        "elma365": {
          "description": "Данные о канале ELMA365.",
          "oneOf": [
            {
              "$ref": "#/definitions/Elma365"
            }
          ]
        },
        "originalChannelId": {
          "type": "string",
          "description": "Идентификатор конечного канала связи"
        }
      }
    },
    "Elma365": {
      "type": "object",
      "description": "Данные о канале ELMA365.",
      "additionalProperties": false,
      "properties": {
        "session": {
          "description": "Данные о сессии ELMA365.",
          "oneOf": [
            {
              "$ref": "#/definitions/Session"
            }
          ]
        },
        "client": {
          "description": "Элемент приложения ELMA365, связанный с данной сессией как учетная запись.",
          "oneOf": [
            {
              "$ref": "#/definitions/Client"
            }
          ]
        },
        "options": {
          "description": "Дополнительные параметры.",
          "oneOf": [
            {
              "$ref": "#/definitions/Options"
            }
          ]
        }
      }
    },
    "Session": {
      "type": "object",
      "description": "Данные о сессии ELMA365.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор сессии ELMA365."
        },
        "apps": {
          "description": "Элементы приложений ELMA365, связанные с данной сессией.",
          "oneOf": [
            {},
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "Client": {
      "type": "object",
      "description": "Элемент приложения ELMA365, связанный с данной сессией как учетная запись.",
      "additionalProperties": false,
      "properties": {
        "app": {
          "oneOf": [
            {},
            {
              "type": "null"
            }
          ]
        },
        "externalId": {
          "type": [
            "null",
            "string"
          ]
        },
        "userName": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "Options": {
      "type": "object",
      "description": "Дополнительные параметры.",
      "additionalProperties": false,
      "properties": {
        "prompterMode": {
          "type": "boolean",
          "description": "Режим подключения бота к сессии. Если true, то бот подключен как суфлер, если false, то бот замещает оператора."
        }
      }
    },
    "MemberExportModel": {
      "type": "object",
      "description": "Модель экспорта данных об участнике беседы.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор участника беседы."
        },
        "name": {
          "type": [
            "null",
            "string"
          ],
          "description": "Имя участника беседы."
        },
        "role": {
          "description": "Роль участника беседы.",
          "oneOf": [
            {
              "$ref": "#/definitions/ConversationRole"
            }
          ]
        }
      }
    },
    "ConversationRole": {
      "type": "string",
      "description": "Роль участника беседы.",
      "x-enumNames": [
        "Bot",
        "User"
      ],
      "enum": [
        "Bot",
        "User"
      ]
    },
    "ActivityExportModel": {
      "type": "object",
      "description": "Базовая модель экспорта активности.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "description": "Тип активности.",
          "oneOf": [
            {
              "$ref": "#/definitions/ActivityType"
            }
          ]
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        }
      }
    },
    "ActivityType": {
      "type": "string",
      "description": "Тип активности.",
      "x-enumNames": [
        "Message",
        "Event"
      ],
      "enum": [
        "Message",
        "Event"
      ]
    },
    "EventName": {
      "type": "string",
      "description": "Наименование типа события. Возможные типы событий: successfull-service - событие успешного обслуживания аналитики; custom-event - пользовательское событие аналитики; scenario-started - запущен сценарий; menu-item-selected - выбрана кнопка меню; trigger-fired - сработал триггер; error - произошла ошибка; promptAccepted - в режиме суфлера подсказка принята оператором; promptRejected - в режиме суфлера подсказка отклонена оператором; CreateElma365AppElement - создание элемента приложения ELMA365; StartProcess - запуск процесса ELMA365; TransferToOperatorInitiated - беседа переведена на оператора.",
      "x-enumNames": [
        "successfull-service",
        "custom-event",
        "scenario-started",
        "menu-item-selected",
        "trigger-fired",
        "error",
        "promptAccepted",
        "promptRejected",
        "CreateElma365AppElement",
        "StartProcess",
        "TransferToOperatorInitiated"
      ],
      "enum": [
        "successfull-service",
        "custom-event",
        "scenario-started",
        "menu-item-selected",
        "trigger-fired",
        "error",
        "promptAccepted",
        "promptRejected",
        "CreateElma365AppElement",
        "StartProcess",
        "TransferToOperatorInitiated"
      ]
    },
    "TriggerName": {
      "type": "string",
      "description": "Наименование типа триггера. Возможные типы триггеров: start-trigger - старт бота; intent-trigger - интент; terminal-trigger - триггер завершения; unknown-intent-trigger - неизвестный интент; transition-trigger - переход из др. сценария; menu-button-trigger - кнопка меню.",
      "x-enumNames": [
        "start-trigger",
        "intent-trigger",
        "terminal-trigger",
        "unknown-intent-trigger",
        "transition-trigger",
        "menu-button-trigger",
        "knowledge-base-answer-trigger"
      ],
      "enum": [
        "start-trigger",
        "intent-trigger",
        "terminal-trigger",
        "unknown-intent-trigger",
        "transition-trigger",
        "menu-button-trigger",
        "knowledge-base-answer-trigger"
      ]
    },
    "PrompterModeEventName": {
      "type": "string",
      "description": "Наименование типа события суфлера. Возможные типы событий: promptAccepted - подсказка принята оператором; promptRejected - подсказка отклонена оператором.",
      "x-enumNames": [
        "promptAccepted",
        "promptRejected"
      ],
      "enum": [
        "promptAccepted",
        "promptRejected"
      ]
    },
    "EventActivityExportModel": {
      "type": "object",
      "description": "Базовая модель экспорта события беседы.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "oneOf": [
            {
              "$ref": "#/definitions/EventName"
            }
          ],
          "description": "Наименование типа события."
        }
      }
    },
    "CreateElma365AppElementActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события о создании элемента приложения.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "CreateElma365AppElement",
          "description": "Наименование типа события."
        },
        "url": {
          "type": [
            "null",
            "string"
          ],
          "description": "Адрес ELMA365."
        },
        "appElementName": {
          "type": [
            "null",
            "string"
          ],
          "description": "Наименование элемента приложения."
        },
        "appElementId": {
          "type": [
            "null",
            "string"
          ],
          "description": "Идентификатор элемента приложения."
        },
        "appElementNamespace": {
          "type": [
            "null",
            "string"
          ],
          "description": "Раздел элемента приложения."
        },
        "appElementCode": {
          "type": [
            "null",
            "string"
          ],
          "description": "Код элемента приложения."
        }
      }
    },
    "CustomEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта пользовательского события.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "custom-event",
          "description": "Наименование типа события."
        },
        "name": {
          "type": "string",
          "description": "Наименование пользовательского события."
        }
      }
    },
    "ErrorEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события ошибки.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "error",
          "description": "Наименование типа события."
        },
        "message": {
          "type": [
            "null",
            "string"
          ],
          "description": "Сообщение об ошибке."
        },
        "stackTrace": {
          "type": [
            "null",
            "string"
          ],
          "description": "Трассировка стека."
        }
      }
    },
    "MenuItemSelectedEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события о нажатии элемента меню.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "menu-item-selected",
          "description": "Наименование типа события."
        },
        "text": {
          "type": "string",
          "description": "Наименование перехода."
        }
      }
    },
    "PrompterEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события суфлера.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "oneOf": [
            {
              "$ref": "#/definitions/PrompterModeEventName"
            }
          ],
          "description": "Наименование типа события суфлера."
        },
        "isAccepted": {
          "type": "boolean",
          "description": "Была ли принята подсказка оператором."
        },
        "text": {
          "type": "string",
          "description": "Текст подсказки."
        }
      }
    },
    "ScenarioStartedEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события о запуске сценария.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "scenario-started",
          "description": "Наименование типа события."
        },
        "scenarioId": {
          "type": [
            "null",
            "string"
          ],
          "description": "Идентификатор сценария."
        },
        "scenarioName": {
          "type": "string",
          "description": "Имя сценария."
        }
      }
    },
    "StartProcessActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события о запуске процесса.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "StartProcess",
          "description": "Наименование типа события."
        },
        "url": {
          "type": [
            "null",
            "string"
          ],
          "description": "Адрес ELMA365."
        },
        "instanceId": {
          "type": [
            "null",
            "string"
          ],
          "description": "Идентификатор экземпляра процесса."
        },
        "processId": {
          "type": [
            "null",
            "string"
          ],
          "description": "Идентификатор шаблона процесса."
        },
        "instanceName": {
          "type": [
            "null",
            "string"
          ],
          "description": "Наименование экземпляра процесса."
        }
      }
    },
    "TriggerFiredEventActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта события о сработанном триггере.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "trigger-fired",
          "description": "Наименование типа события."
        },
        "triggerType": {
          "oneOf": [
            {
              "$ref": "#/definitions/TriggerName"
            }
          ],
          "description": "Тип триггера."
        },
        "scenarioId": {
          "type": [
            "null",
            "string"
          ],
          "description": "Идентификатор сценария."
        }
      }
    },
    "SuccessfulServiceEventExportModel": {
      "type": "object",
      "description": "Модель экспорта события успешного обслуживания.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Event",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "eventName": {
          "const": "successfull-service",
          "description": "Наименование типа события."
        },
        "isSuccess": {
          "type": "boolean",
          "description": "Было ли событие успешным."
        }
      }
    },
    "MessageActivityExportModel": {
      "type": "object",
      "description": "Модель экспорта сообщения в беседе.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор активности."
        },
        "type": {
          "const": "Message",
          "description": "Тип активности."
        },
        "timestamp": {
          "type": [
            "null",
            "string"
          ],
          "description": "Временная метка.",
          "format": "date-time"
        },
        "text": {
          "type": "string",
          "description": "Текст сообщения."
        },
        "from": {
          "description": "Отправитель.",
          "oneOf": [
            {
              "$ref": "#/definitions/MemberExportModel"
            }
          ]
        },
        "recipient": {
          "description": "Получатель.",
          "oneOf": [
            {
              "$ref": "#/definitions/MemberExportModel"
            }
          ]
        },
        "buttons": {
          "type": [
            "array",
            "null"
          ],
          "description": "Кнопки и элементы меню, содержащиеся в сообщении.",
          "items": {
            "$ref": "#/definitions/ButtonExportModel"
          }
        },
        "recognizedIntents": {
          "type": [
            "array",
            "null"
          ],
          "description": "Распознанные интенты.",
          "items": {
            "$ref": "#/definitions/IntentExportModel"
          }
        },
        "knowledgeBaseAnswers": {
          "type": [
            "array",
            "null"
          ],
          "description": "Найденные ответы в Базе знаний.",
          "items": {
            "$ref": "#/definitions/KnowledgeBaseAnswerExportModel"
          }
        },
        "attachments": {
          "type": [
            "array",
            "null"
          ],
          "description": "Вложения.",
          "items": {
            "$ref": "#/definitions/Attachment"
          }
        }
      }
    },
    "ButtonExportModel": {
      "type": "object",
      "description": "Модель экспорта кнопки/элемента меню.",
      "additionalProperties": false,
      "properties": {
        "title": {
          "type": "string",
          "description": "Заголовок."
        },
        "value": {
          "description": "Значение."
        },
        "type": {
          "type": "string",
          "description": "Тип кнопки."
        },
        "isSelected": {
          "type": "boolean",
          "description": "Была ли выбрана кнопка."
        }
      }
    },
    "IntentExportModel": {
      "type": "object",
      "description": "Модель экспорта информации о распознанном интенте.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор интента."
        },
        "name": {
          "type": "string",
          "description": "Имя интента."
        },
        "score": {
          "type": "string",
          "description": "Значение уверенности распознавания."
        }
      }
    },
    "KnowledgeBaseAnswerExportModel": {
      "type": "object",
      "description": "Модель экспорта ответа из Базы знаний.",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Идентификатор записи в Базе знаний."
        },
        "question": {
          "type": "string",
          "description": "Текст вопроса."
        },
        "answer": {
          "type": "string",
          "description": "Ответ."
        },
        "score": {
          "type": "string",
          "description": "Значение уверенности распознавания."
        }
      }
    },
    "Attachment": {
      "type": "object",
      "description": "Вложение.",
      "additionalProperties": {
        "oneOf": [
          {},
          {
            "type": "null"
          }
        ]
      },
      "properties": {
        "contentType": {
          "type": [
            "null",
            "string"
          ],
          "description": "Тип контента в формате MIME."
        },
        "contentUrl": {
          "type": [
            "null",
            "string"
          ],
          "description": "Адрес ссылки для скачивания вложения."
        },
        "content": {
          "description": "Контент.",
          "oneOf": [
            {},
            {
              "type": "null"
            }
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ],
          "description": "Наименование файла вложения."
        }
      }
    }
  }
}
