Schema for Ratatoskr Delivery Metadata

From DeliveryMetadata.schema.yaml (ratatoskr/DeliveryMetadata.schema)

---
$id: https://skeleton.botmd.io/ratatoskr/DeliveryMetadata.schema
$schema: http://json-schema.org/draft-07/schema#

title: Delivery Metadata
description: >-
  `Delivery.metadata` is usually set by providers to track the messages being sent and received.

type: object
additionalProperties: false

properties:
  create_delivery:
    title: Create Delivery
    description: Whether to create delivery object during outgoing flows.
    type: boolean

  botmdhospital:
    $ref: "#/definitions/botmdhospital"

  line:
    $ref: "#/definitions/line"

  messagebird:
    $ref: "#/definitions/messagebird"

  messenger:
    $ref: "#/definitions/messenger"

  noop:
    $ref: "#/definitions/noop"

  pinpoint:
    $ref: "#/definitions/pinpoint"

  promotexter:
    $ref: "#/definitions/promotexter"

  pusher:
    $ref: "#/definitions/pusher"

  qiscus:
    $ref: "#/definitions/qiscus"

  qontak:
    $ref: "#/definitions/qontak"

  ses:
    $ref: "#/definitions/ses"

  smooch:
    $ref: "#/definitions/smooch"

  smtp:
    $ref: "#/definitions/smtp"

  telegram:
    $ref: "#/definitions/telegram"

  twilio:
    $ref: "#/definitions/twilio"

  viber:
    $ref: "#/definitions/viber"

  whatsapp:
    $ref: "#/definitions/whatsapp"

  action_state:
    $ref: "#/definitions/action_state"

  fcm:
    $ref: "#/definitions/fcm"

  bifrost:
    $ref: "#/definitions/bifrost"

  chemocalc:
    $ref: "#/definitions/chemocalc"

  cleo:
    $ref: "#/definitions/cleo"

  einstein:
    $ref: "#/definitions/einstein"

  faraday:
    $ref: "#/definitions/faraday"

  healthcheck:
    $ref: "#/definitions/healthcheck"

  heimdall:
    $ref: "#/definitions/heimdall"

  hospital:
    $ref: "#/definitions/hospital"

  jarvis:
    $ref: "#/definitions/jarvis"

  mastermind:
    $ref: "#/definitions/mastermind"

  maxwell:
    $ref: "#/definitions/maxwell"

  ratatoskr:
    $ref: "#/definitions/ratatoskr"

  retry_deliveries:
    $ref: "#/definitions/retry_deliveries"

  has_retried:
    $ref: "#/definitions/has_retried"

  variables:
    $ref: "#/definitions/variables"

  query_metrics:
    $ref: "#/definitions/query_metrics"

  legacy:
    $ref: "#/definitions/legacy"
#end properties

anchors:
  patternProperties: &status_update_datetime
    ^\w+_on$:
      title: Status Update Date-Time
      description: This field is set when the status of the delivery is updated.
      type: string
      format: date-time
  #end patternProperties
#end anchors

definitions:
  botmdhospital:
    title: BotMDHospitalProvider
    description: Delivery metadata for `BotMDHospitalProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      status:
        title: Delivery Status
        description: Delivery status
        enum: [delivered, failed]

      delivery_uids:
        title: Delivery UIDs
        description: Delivery UID of delivery to native app. There can be multiple delivery UIDs when the user has multiple devices.

        type: array
        items:
          title: Delivery UID
          type: string
          minLength: 1
      #end delivery_uids
  #end botmdhospital

  line:
    title: LineProvider
    description: Delivery metadata for `LineProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      status:
        title: Delivery Status
        description: Delivery status enumerated by `LineDeliveryStatus`.
        type: string
        enum: [posted, post_failed, received, hold_until_follow, hold_until_follow_expired]

      webhook_event_id:
        title: Webhook Event ID
        description: The webhook event ID associated with an incoming delivery.
        type: string
        minLength: 1

      message_ids:
        title: Message IDs
        description: Message IDs associated with this delivery.
        type: array

        minItems: 0
        unique: true
        items:
          type: string
          minLength: 1

      unsent:
        title: Unsent
        description: Whether this delivery has been unsent. Defaults to `false`.
        type: boolean
    #end properties

    patternProperties: *status_update_datetime
  #end line

  messagebird:
    title: MessagebirdProvider
    description: Delivery metadata for `MessagebirdProvider`; obtained from `https://developers.messagebird.com/api/conversations/#messagestatus-object`.

    type: object
    additionalProperties: false
    required: [message_id, status]
    properties:
      message_id:
        title: Messagebird Message ID
        description: Messagebird `message_id` is useful for tracking the delivery status of a message.
        type: [string, "null"]

      status:
        title: Delivery Status
        description: Delivery status enumerated by `MessagebirdDeliveryStatus`.
        type: string
        enum: [posted, post_failed, accepted, pending, sent, transmitted, rejected, failed, read, received, deleted, unknown, delivered]

      pricing:
        title: Pricing
        description: Pricing information for the message.
        type: object
        properties:
          billable:
            title: Billable
            description: Whether the message is billable based on conversation window.
            type: boolean
          pricing_model:
            title: Pricing Model
            description: The pricing model used for the message.
            type: string
          category:
            title: Category
            description: The category of the message.
            type: string
          window_expiry:
            title: Expiration timestamp
            description: When the conversation window expires
            type: string
            format: date-time

      error:
        title: Error
        description: The error object within the message payload. Only set when exist.

        $ref: "/skeleton/Any.schema"
    #end properties

    patternProperties: *status_update_datetime
  #end messagebird

  messenger:
    title: MessengerProvider
    description: Delivery metadata for `MessengerProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      entry_id:
        title: Messenger Entry ID
        description: Payload entry ID, i.e., `payload['id']`.
        type: string
        minLength: 1

      message_ids:
        title: Message IDs
        description: List of message IDs, i.e., `payload['messaging'][*]['mid']`. Usually there is only 1.
        type: array
        items:
          type: string
          minLength: 1

      status:
        title: Delivery Status
        description: Delivery status enumerated by `MessengerDeliveryStatus`.
        type: string
        enum: [posted, post_failed, delivered, read, received]
    #end properties

    patternProperties: *status_update_datetime
  #end messenger

  noop:
    title: NoopProvider
    description: Delivery metadata for `NoopProvider` and `NoopPhoneProvider`.

    type: object
    additionalProperties: false
    required: [status]

    properties:
      status:
        title: Status
        description: Delivery status.
        type: string
        enum: [posted, received, unknown]
      #end status
  #end noop

  pinpoint:
    title: NoopProvider
    description: Delivery metadata for `NoopProvider` and `NoopPhoneProvider`.

    type: object
    additionalProperties: false
    required: [status]

    properties:
      status:
        title: Status
        description: Delivery status.
        type: string
        enum: [posted, post_failed, received]
      #end status

      message_id:
        title: Message ID
        description: Message ID of inbound/outbound messages.
        type: string
        minLength: 1
    #end properties

    patternProperties: *status_update_datetime
  #end pinpoint

  promotexter:
    title: PromoTexterProvider
    description: Delivery metadata for `PromoTexterProvider`. See [PromoTexter Messaging API](https://promotexter.docs.apiary.io/#reference/viber-business-messaging-with-sms-fallback) for more information.

    type: object
    additionalProperties: true
    required: [transaction_ids, status]

    properties:
      transaction_ids:
        title: Transaction IDs
        description: PromoTexter specific transaction IDs for each API request.

        type: array
        items:
          title: Transaction ID

          type: string
          minLength: 1

      status:
        title: Status
        description: Delivery status enumerated by `PromoTexterDeliveryStatus`.
        type: string
        enum: [posted, post_failed, delivered, failed, seen, clicked, unknown, received]

      error_code:
        title: Error Code
        description: Error code returned by the provider.
        type: string
    #end properties

    patternProperties: *status_update_datetime
  #end promotexter

  pusher:
    title: PusherProvider
    description: Delivery metadata for `PusherProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      status:
        title: Delivery Status
        description: Delivery status enumerated by `PusherDeliveryStatus`.
        type: string
        enum: [sent, received, read, failed]

      truncated:
        title: Truncated
        description: Message was not included in Pusher payload due to size restrictions.
        type: boolean
    #end properties
  #end pusher

  qiscus:
    title: QiscusMultichannelProvider
    description: Delivery metadata for `QiscusMultichannelProvider`.

    type: object
    additionalProperties: false
    required: [status, message_ids, payload_type]

    properties:
      status:
        title: Delivery Status
        description: Delivery status enumerated by `PromoTexterDeliveryStatus`.
        type: string
        enum: [posted, post_failed, received, deleted, delivered, failed, read, sent, warning]

      message_ids:
        title: Message ID
        description: Message ID for incoming and outgoing messages. For incoming messages, it is of the form `{payload["message"]["unique_temp_id"]}:{payload["message"]["id"]}`. Only messages sent via WhatsApp API have message IDs.

        type: array
        items:
          title: Message ID

          type: string
          minLength: 1
      #end message_ids

      payload_type:
        title: Payload Type
        description: Whether the payload is sent or recieved via the multichannel API or WhatsApp API.
        enum: [multichannel, whatsapp]

      pricing:
        title: Pricing
        description: Pricing information for the message.
        type: object
        properties:
          billable:
            title: Billable
            description: Whether the message is billable based on conversation window.
            type: boolean
          pricing_model:
            title: Pricing Model
            description: The pricing model used for the message.
            type: string
          category:
            title: Category
            description: The category of the message.
            type: string

      handover:
        title: Handover
        description: "`True` if this is a handover delivery and the handover was done successfully. If unsuccessful, it will be `false`. This value is `null` or unspecified for regular message deliveries."
        type: boolean
    #end properties

    patternProperties: *status_update_datetime
  #end qiscus

  qontak:
    title: QiscusMultichannelProvider
    description: Delivery metadata for `QiscusMultichannelProvider`.

    type: object
    additionalProperties: false
    required: [message_ids]

    properties:
      message_ids:
        title: Message ID
        description: Message ID for incoming and outgoing messages. For incoming messages, it is of the form `{payload["id"]}`
        type: array
        items:
          type: string
          minLength: 1
      #end message_id

      handover:
        title: Agent Handover
        description: "`True` if this is a handover delivery and the handover was done successfully. If unsuccessful, it will be `false`. This value is `null` or unspecified for regular message deliveries."
        type: boolean
      #end handover

      error:
        title: Error
        description: Error message.

        $ref: "/skeleton/Any.schema"

      status:
        title: Delivery Status
        description: Delivery status enumerated by `QontakDeliveryStatus`.
        type: string
        enum: [posted, post_failed, received, delivered, read, failed]
    #end properties

    patternProperties: *status_update_datetime
  #end qontak

  ses:
    title: SESProvider
    description: Delivery metadata for `SESProvider`.

    type: object
    additionalProperties: false
    required: []

    properties:
      status:
        title: Delivery Status
        description: Delivery status enumerated by `SESDeliveryStatus`.
        type: string
        enum: [posted, post_failed, received, bounced]

      incoming_receipt:
        title: Incoming Receipt
        description: Receipt metadata. This is basically the SES notification payload.

        type: object
        required: [message_id, payload]
        additionalProperties: false

        properties:
          message_id:
            title: Message ID
            description: The SES assigned message ID.
            type: string
            minLength: 1

          payload:
            title: Payload
            description: The original payload from SES.

            type: object
            required: [mail, receipt]
            additionalProperties: true

            properties:
              mail:
                title: Mail
                description: This is provided by SES. See https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-examples.html
                type: object

              receipt:
                title: Receipt
                description: This is provided by SES. See https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-notifications-examples.html
                type: object
            #end properties
          #end payload
      #end incoming_receipt

      outgoing_metadata:
        title: Outgoing Metadata
        description: Outgoing metadata. This is basically the SES response to `send_email`.

        type: object
        required: [message_id, status_code]
        additionalProperties: false

        properties:
          message_id:
            title: Message ID
            description: The outgoing message ID given by AWS SES.
            type: string
            minLength: 1

          status_code:
            title: Status Code
            description: The `HTTPStatusCode` returned by SES.

            type: integer
          #end status_code
      #end outgoing_metadata
    #end properties

    patternProperties: *status_update_datetime
  #end ses

  smooch:
    title: SmoochProvider
    description: Delivery metadata for `SmoochProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      message_id:
        title: Message ID
        description: Smooch `message_id` is useful for tracking the delivery status of a message.
        type: string

      status:
        title: Delivery Status
        description: Delivery status enumerated by `SmoochDeliveryStatus`.
        type: string
        enum: [sent, delivery_success, delivery_failure, received]

      apikey:
        title: Bot MD API key
        description: An API key used by Bot MD to determine the organization using the Smooch application. This is necessary because we multiplex multiple clients into one Smooch application.
        type: string
        minLength: 1
    #end properties

    patternProperties: *status_update_datetime
  #end smooch

  smtp:
    title: SMTPProvider
    description: Delivery metadata for `SMTPProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      status:
        title: Delivery Status
        description: Delivery status enumerated by `SMTPDeliveryStatus`.
        type: string
        enum: [sent, failed]

      error:
        title: Error
        description: Error message when failed to deliver email.

        $ref: "/skeleton/Any.schema"
    #end properties

    patternProperties: *status_update_datetime
  #end smtp

  telegram:
    title: TelegramProvider
    description: Delivery metadata for `TelegramProvider`.

    type: object
    additionalProperties: false
    required: [message_ids, status]

    properties:
      update_id:
        title: Update ID
        description: The `update_id` in the webhook payload is globally unique. See [Python Telegram Bot documentation](https://python-telegram-bot.readthedocs.io/en/stable/telegram.update.html#telegram.Update).
        type: number

      message_ids:
        title: Message IDs
        description: Telegram `message.message_id`s are incremental ID that are not globally unique.
        type: array
        items:
          type: number

      status:
        title: Delivery Status
        description: Delivery status enumerated by `TelegramDeliveryStatus`.
        type: string
        enum: [received, posted, post_failed]
    #end properties

    patternProperties: *status_update_datetime
  #end telegram

  twilio:
    title: TwilioProvider
    description: Delivery metadata for `TwilioProvider`. Information about message statuses can be found here https://www.twilio.com/docs/messaging/guides/webhook-request#status-callback-parameters

    type: object
    additionalProperties: false
    oneOf:
      - required: [message_sid, status, sent_from]
      - required: [message_sid, status, received_by]

    properties:
      message_sid:
        title: Twilio Message ID
        description: Twilio `message_sid` is useful for tracking the delivery status of a message.
        type: [string, "null"]

      status:
        title: Delivery Status
        description: Delivery status enumerated by `TwilioDeliveryStatus`.
        type: string
        enum: [posted, post_failed, delivered, failed, queued, read, sent, undelivered, received]

      received_by:
        title: Received By
        description: This is the Twilio phone number that received the message. This is useful when multiple numbers are used for the same Twilio provider.

        type: string
        pattern: '^\+\d{5,}$'

      sent_from:
        title: Sent From
        description: This is the Twilio phone that sent the message. This is useful when multiple numbers are used for the same Twilio provider.

        type: string
        pattern: '^\+\d{5,}$'

      billing:
        title: Billing
        description: Metadata related to billing.

        type: object
        required: [num_segments, price, price_unit, updated_on]
        additionalProperties: false

        properties:
          num_segments:
            title: Num Segments
            description: Number of segments used for billing purposes.
            type: integer
            exclusiveMinimum: 0

          price:
            title: Price
            description: Price of this message as charged by Twilio. String because it is treated as a `Decimal`.
            type: string

          price_unit:
            title: Price Unit
            description: The currency of `price`.
            type: string
            minLength: 1

          updated_on:
            title: Updated On
            description: Date/time the billing information was synced.
            type: string
            format: date-time
      #end billing
    #end properties

    patternProperties: *status_update_datetime
  #end twilio

  viber:
    title: ViberProvider
    description: Delivery metadata for `ViberProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      message_token:
        title: Message Token
        description: The message token associated with an incoming delivery.
        type: string
        minLength: 1

      status:
        title: Delivery Status
        description: Delivery status enumerated by `ViberDeliveryStatus`.
        type: string
        enum: [posted, post_failed, received, delivered, hold_until_follow, hold_until_follow_expired, seen, failed]
    #end properties

    patternProperties: *status_update_datetime
  #end viber

  whatsapp:
    title: WhatsAppProvider
    description: Delivery metadata for `WhatsAppProvider`.

    type: object
    additionalProperties: false
    required: [status]
    properties:
      message_ids:
        title: Message IDs
        description: List of message IDs. Usually there is only 1.
        type: array
        items:
          type: string
          minLength: 1

      status:
        title: Delivery Status
        description: Delivery status enumerated by `WhatsAppDeliveryStatus`.
        type: string
        enum: [posted, post_failed, delivered, read, sent, received, failed]

      pricing:
        title: Pricing
        description: Pricing information for the message.
        type: object
        properties:
          billable:
            title: Billable
            description: Whether the message is billable.
            type: boolean
          pricing_model:
            title: Pricing Model
            description: The pricing model used for the message.
            type: string
          category:
            title: Category
            description: The category of the message.
            type: string

      errors:
        title: Errors
        description: Errors received from provider's webhook
        type: array

      error:
        title: Error
        description: Error message for post_failed.

        $ref: "/skeleton/Any.schema"
    #end properties

    patternProperties: *status_update_datetime
  #end whatsapp

  action_state:
    title: Action State
    description: Delivery metadata for `ActionState`.

    type: object
    additionalProperties: false
    oneOf:
      - required: [executed_by]
      - required: [is_execution_successful]

    properties:
      executed_by:
        title: Executed By
        description: If this delivery is the result of an action state execution, it will be the UID of the delivery that "triggered" the execution.
        type: string
        minLength: 1

      is_execution_successful:
        title: Is Execution Successful
        description: "`True` if this action state delivery executed successfully. Only action state deliveries will have this value set."
        type: boolean

      is_via_jwt:
        title: Is Via JWT
        description: Whether this action state's `ApplicationPayload` was created via JWT.
        type: boolean

      ignore_outgoing_delivery:
        title: Ignore outgoing delivery
        description: Ignore outgoing delivey for action state message
        type: boolean

      redirect_to:
        title: Redirect To
        description: When executing in via JWT, this value holds the URL to redirect the user to. This is used internally.
        type: string
        format: uri
    #end properties
  #end action_state

  fcm:
    title: FCMProvider
    description: Delivery metadata for `FCMProvider`.

    type: object
    additionalProperties: false

    properties:
      mute:
        title: Mute delivery
        description: When this is set to true, the delivery doesn't get through the fcm provider.
        type: boolean

      data_message:
        title: Custom Data Message
        description: Use this to override the default data message.
        type: object
        additionalProperties: true

      status:
        title: Delivery Status
        description: Status of FCM delivery message
        enum: [sent, failed, not_sent]
    #end properties
  #end fcm

  bifrost:
    title: Bifrost
    description: Delivery metadata for `Bifrost` application.

    type: object
    additionalProperties: false
    oneOf:
      - required: [organization, flow_uid, connection_uid, purpose]
      - required: [organization, query_delivery_uid]

    properties:
      organization:
        title: Organization
        description: Key of Bifrost organization that created this delivery.
        type: string
        minLength: 1
      #end organization

      flow_uid:
        title: Flow UID
        description: UID of Bifrost flow that created this delivery.
        type: string
        minLength: 1
      #end flow

      connection_uid:
        title: Connection UID
        description: UID of Bifrost connection that created this delivery.
        type: string
        minLength: 1
      #end flow

      purpose:
        title: Purpose
        description: Purpose Bifrost flow-connection that created this delivery.
        type: string
        minLength: 1
      #end flow

      query_delivery_uid:
        title: Query Delivery UID
        description: The UID of the query delivery object. Useful for tracking query and responses.
        type: string
        minLength: 1
    #end properties
  #end bifrost

  chemocalc:
    title: Chemocalc
    description: Delivery metadata for `Chemocalc` application.

    type: object
    additionalProperties: false
    required: [delivery_by]

    properties:
      delivery_by:
        title: Delivery By
        description: Describes the type of the message (e.g., `alert`, `reminder`, etc).
        enum: [user, system, bot, unknown]

      message_template_uid:
        title: Message Template UID
        description: UID of the message template used for outgoing delivery.

        type: string
        minLength: 1

      session_uid:
        title: Session UID
        description: UID of patient/doctor who sent the delivery.

        type: string
        minLength: 1
  cleo:
    title: Cleo
    description: Delivery metadata for `Cleo` application.

    type: object
    additionalProperties: false
    oneOf:
      - required: [delivery_by, clinic, profile_uid]
      - required: [delivery_by, clinics, profile_uids]

    properties:
      delivery_by:
        title: Delivery By
        description: Describes the type of the message (e.g., `alert`, `reminder`, etc).
        enum: [alert, reminder, enrollment, discharge, new_submission_comment, update_metadata_entry, submission, bot, clinician, user, system, unknown, event, payment, greeting, disclaimer, scheduling_reminder]

      clinic:
        title: Clinic (Outgoing)
        description: Clinic that this outgoing delivery is part of.

        type: [string, "null"]
        minLength: 1

      clinics:
        title: Clinics (Incoming)
        description: Clinics that this incoming delivery is part of.

        type: array
        minItems: 0
        items:
          type: string
          minLength: 1

      profile_uid:
        title: Profile UID (Outgoing)
        description: UID of patient/clinician delivered to. This is for all outgoing deliveries.

        type: [string, "null"]
        minLength: 1

      profile_uids:
        title: Profile UIDs (Incoming)
        description: UID of patient for whom the delivery was processed. This is for all incoming deliveries.

        type: array
        minItems: 0
        items:
          type: string
          minLength: 1

      calendar_uid:
        title: Calendar UID (Outgoing)
        description: UID of associated patient-event's calendar. This is for outgoing deliveries related to events.

        type: string
        minLength: 1

      patient_event_uid:
        title: Patient Event UID (Outgoing)
        description: UID of associated patient-event. This is for outgoing deliveries related to events.

        type: string
        minLength: 1

      patient_form_uid:
        title: Patient Form UID (Outgoing)
        description: UID of associated patient-form. This is for outgoing deliveries related to patient-forms.

        type: string
        minLength: 1

      patient_group_uid:
        title: Patient Group UID (Outgoing)
        description: UID of associated patient group. This is for outgoing deliveries using patient groups without monitoring forms.

        type: string
        minLength: 1

      patient_payment_uid:
        title: Patient Payment UID (Outgoing)
        description: UID of associated patient-payment. This is for outgoing deliveries related to patient-payments.

        type: string
        minLength: 1

      patient_payment_transaction_uid:
        title: Patient Payment Transaction UID (Outgoing)
        description: UID of associated patient-payment transaction. This is for outgoing deliveries related to patient-payments.

        type: string
        minLength: 1

      patient_program_uid:
        title: Patient Program UID (Outgoing)
        description: UID of associated patient program. This is for outgoing deliveries using patient program.

        type: string
        minLength: 1

      patient_program_form_uid:
        title: Patient Program Form UID (Outgoing)
        description: UID of associated patient program form. This is for outgoing deliveries using patient program form.

        type: string
        minLength: 1

      query_delivery_uid:
        title: Query Delivery UID (Outgoing)
        description: The UID of the query delivery object. Useful for tracking query and responses.

        type: string
        minLength: 1

      message_template_pk:
        title: Message Template Primary Key
        description: Primary key of the message template used for outgoing delivery.

        type: integer
        minimum: 1

      reminder_event_pk:
        title: Reminder Event Primary Key
        description: Primary key of associated reminder event. This is for reminder deliveries.

        type: integer
        minimum: 1

      clinician_uid:
        title: Clinician UID (Outgoing)
        description: For messages sent by clinicians (i.e., triggered via dashboard), this field will contain the clinician's UID.

        type: string
        minLength: 1

      clinical_parameter_uid:
        title: Clinical Parameter UID
        description: UID for clinical parameter that is being updated.

        type: string
        minLength: 1

      engage:
        title: Engage
        description: Delivery metadata associated with the specialized Engage application.

        type: object
        required: [module, stage]
        additionalProperties: false

        properties:
          module:
            title: Module
            description: The module corresponding to this delivery.
            type: string
            minLength: 1

          stage:
            title: Stage
            description: The stage corresponding to this delivery.
            type: string
      #end engage
    #end properties
  #end cleo

  einstein:
    title: Einstein
    description: Delivery metadata for Einstein related features.

    type: object
    additionalProperties: false
    required: []

    properties:
      broadcast_uid:
        title: Broadcast UID
        description: Broadcast UID which this delivery is sent from.

        type: string
        minLength: 1
  #end einstein

  faraday:
    title: Faraday
    description: Delivery metadata for `Faraday` application.

    type: object
    additionalProperties: false
    required: [delivery_by, clinic, profile_uid]

    properties:
      delivery_by:
        title: Delivery By
        description: Describes the type of the message (e.g., `alert`, `reminder`, etc).
        enum: [alert, reminder, bot, user, system, unknown]

      clinic:
        title: Clinic
        description: Clinic that this delivery is part of.

        type: [string, "null"]
        minLength: 1

      message_template_pk:
        title: Message Template Primary Key
        description: Primary key of the message template used for outgoing delivery.

        type: integer
        minimum: 1

      order_uid:
        title: Order UID
        description: For messages sent to patients, this field will contain the order's UIDs.

        type: string
        minLength: 1

      order_exam_uids:
        title: OrderExam UIDs
        description: For messages sent to patients, this field will contain the orderexam's UIDs.

        type: array
        items:
          type: string
          minLength: 1

      profile_uid:
        title: Profile UID
        description: UID of staff/patient delivered to.

        type: [string, "null"]
        minLength: 1

      query_delivery_uid:
        title: Query Delivery UID
        description: The UID of the query delivery object. Useful for tracking query and responses.
        type: string
        minLength: 1

  healthcheck:
    title: Healthcheck
    description: Delivery metadata for Healthcheck.

    type: object
    required: []
    additionalProperties: false

    properties:
      ping_delivery_uid:
        title: Ping Delivery UID
        description: Delivery UID for the incoming ping delivery. This is set for outgoing pong deliveries.
        type: string
        minLength: 1
    #end properties
  #end healthcheck

  heimdall:
    title: Heimdall
    description: Delivery metadata for Heimdall.

    type: object
    additionalProperties: false
    required: [provider_application_uid]

    properties:
      provider_application_uid:
        title: Provider Application UID
        description: The Heimdall OTP provider that created this delivery.
        type: string
        minLength: 1
      #end provider_application_uid
    #end properties
  #end heimdall

  hospital:
    title: Hospital
    description: Delivery metadata for `Hospital` application.

    type: object
    additionalProperties: false
    required: []

    properties:
      delivery_by:
        title: Delivery By
        description: Describes how the message was delivered.
        type: string
        anyOf:
          - $ref: "/hospital/Settings.schema#/definitions/Notification Types"
          - enum: [query]

      short_name:
        title: Short Name
        description: Hospital short name for the profile recieving this delivery.
        type: string

      query_delivery_uid:
        title: Query Delivery UID
        description: The UID of the query delivery object. Useful for tracking query and responses.
        type: string
        minLength: 1

      response_time:
        title: Response Time
        description: Time taken to get response from athena. Includes internal service network RTT.
        type: number
        minimum: 0
    #end properties
  #end hospital

  jarvis:
    title: Jarvis
    description: Delivery metadata for `Jarvis` application.
    type: object
    additionalProperties: false
    required: [query_engine, version]

    properties:
      query_engine:
        type: object
        additionalProperties: true
        properties:
          name:
            title: Name
            description: Name of the query engine as specified in the query engine settings.
            type: string
            minLength: 1
          version:
            title: Version
            description: Version of the query engine. This is based on the Kondo version (i.e., commit ID of the corresponding Kondo resource).
            type: string
      #end query_engine

      version:
        title: Version
        description: Version of Jarvis. This is usually equivalent to the deploy Hippocrates version.
        type: string
        minLength: 1

      module_response:
        title: Module Response
        description: Summary of the module that responded to this query.
        type: object
        additionalProperties: true
        required: [type]
        properties:
          type:
            title: Type
            description: Type/Name of the module that responded to this query.
            type: string
            minLength: 1
      #end module_response
  #end jarvis

  mastermind:
    title: Mastermind
    description: Delivery metadata for when a delivery is sent by a Mastermind user from the device page.

    type: object
    additionalProperties: false
    required: [delivery_by]
    properties:
      delivery_by:
        title: Delivery By
        description: The Mastermind user that sent this delivery.
        type: string
    #end properties
  #end mastermind

  maxwell:
    title: Maxwell
    description: Delivery metadata for maxwell orders.

    type: object
    additionalProperties: false
    required: [order_id]
    properties:
      order_id:
        title: Order ID
        description: Maxwell Order ID associated with this message delivery.
        type: integer
    #end properties
  #end maxwell

  ratatoskr:
    title: Ratatoskr
    description: Delivery metadata related to Ratatoskr.

    type: object
    additionalProperties: false
    required: []
    properties:
      is_technical_error_message:
        title: Is Technical Error Message
        description: This delivery is in response to an unhandled exception.
        type: boolean

      is_subscribe_message:
        title: Is Subscribe Message
        description: This delivery is in response to an subscribe request.
        type: boolean
      #end properties

      is_unsubscribe_message:
        title: Is Unsubscribe Message
        description: This delivery is in response to an unsubscribe request.
        type: boolean
    #end properties
  #end ratatoskr

  retry_deliveries:
    title: Retry Deliveries
    description: Delivery metadata for when a delivery is retried using the `retry_deliveries` management command.

    type: object
    additionalProperties: false
    required: [delivery_by, delivery_uid, retried_by]
    properties:
      delivery_by:
        title: Delivery By
        description: How retry delivery was invoked.

        enum: [cli, mastermind, kronos]

      delivery_uid:
        title: Delivery UID
        description: The `uid` of the delivery that is being retried.

        type: string
        minLength: 1

      retried_by:
        title: Retried By
        description: Either the AWS STS caller ID or Mastermind username of the user who triggered the retry.

        type: string
        minLength: 1

      retry_attempts:
        title: Retry Attempts
        description: Number of times the delivery has been retried.
        type: integer

  has_retried:
    title: Has Retried
    description: Whether the delivery has been retried to sent so it won't auto-retry again.
    type: boolean

    #end properties
  #end retry_deliveries

  variables:
    title: Variables
    description: Used for variable substitution inside message content. Any instance of `${name}` in the message content will be replaced using simple string substitution.

    type: object
    propertyNames:
      pattern: '^[A-Za-z0-9][A-Za-z0-9\[\]\_\-\(\)\s]*$'

    additionalProperties:
      type: string
  #end variables

  query_metrics:
    title: Query Metrics
    description: Contains information related to the Jarvis query flow for use in analysis.
    type: object
    properties:
      modules:
        title: Jarvis modules related to the query flow.
        type: array
        items:
          type: string
          minLength: 1
      miniapps:
        title: Jarvis Chernobyl miniapps related to the query flow.
        type: array
        items:
          type: string
          minLength: 1
      is_sorry:
        title: Indicates if the message is a sorry message.
        type: boolean
      is_confident:
        title: Indicates if Jarvis is is confident of the reply.
        type: boolean
      query:
        title: Query used in the query flow.
        type: string
      hospital:
        title: The querying hospital
        type: string
        minLength: 1
      query_nonce:
        title: Query Nonce (one occasion) used for identifying multipart messages that belong to the same querying session.
        type: string
        minLength: 1
  #end query_metrics

  legacy:
    title: Legacy
    description: Delivery metadata for legacy ChatResponses.

    type: object
    additionalProperties: true
  #end legacy
#end definitions

[Main Page] [Schema Documentation] [Examples]