Message Model

Messages make up a conversation.


  "id": long (int),
  "orgId": int,
  "body": string,
  "author": {
    "type": string, // one of {contact, user}
    "id": long,
    "bot": boolean
  "type": string, // one of {chat, private_note},
  "conversationId": long,
  "createdAt": timestamp,
  "buttons": [MessageButton],
  "context": {
    "ip": string,
    "userAgent": string
  "attributes": object // additional information (see below)
Field NameDescription
idA unique identifier for the message. Should be treated as long or integer 64 bit data type.
orgIdThe Drift organization this message belongs to
bodyThe text contents of this message, if applicable. See the message body section for details on the format.
authorAn object describing who authored this message. author.type is contact if the author was a contact and user if they were a user. uniquely identifies the author within the object type specified by author.type. Bot indicates whether the posting user is a bot (won't be true for contacts).
typeSpecifies the type of this message; one of chat, or private_note. See the section types of messages below for details.
conversationIdThe id field of the conversation this message is a part of.
createdAtA Unix timestamp representing the moment this message was created
buttonsA (potentially absent) list of objects representing buttons presented to contacts from this message. See the section on message buttons for details.
contextAn optional object representing potential metadata about where the message was published from.
attributesOther metadata on the message.

Possible fields:
preMessages (object): If there were messages in the conversation prior to this current message, i.e. supplied by a bot user or on behalf of a drift user, these will be supplied here. This is generally present on the first site visitor message.
developer_app_id (string): The dev app ID will be included if the message was posted via the API.

Types of Messages

There are 2 types of messages, corresponding to the type field in that object:

  • chat Messages are the most ubiquitous type. They correspond to a regular text-based communication from either a contact or a user and are visible to both. chat type messages may also contain buttons, in which case they're only visible to the conversation's contact.
  • private_notes are messages that can only be created by a user and seen by other users. These are useful for sharing sensitive, but useful information to users in the context of the communication they're having with a given contact.

Message Bodies

The message.body field is the primary vehicle for communicating information in messages. It follows a format that resembles HTML in order to allow for limited richness, but is heavily and automatically restricted. In particular, HTML reserved characters are automatically converted to their corresponding HTML entities if they're outside the context of an allowed tag. <b>, <em>, and <a> tags are allowed, but most others are automatically stripped, as well as any styles on the allowed ones. Ultimately, you can treat this field as plain text and not include any tags.

Message Buttons

A chat message can be made interactive with buttons.

Buttons can be set as a list in the message.button field and have the following format:

  "label": string,
  "value": string,
  "type": {reply},
  "style": {primary, danger},
  "reaction": {
    "type": {replace, delete},
    "message": string
Field NameDescription
labelFor all button types, the label field is what is actually displayed as a label on the button to the user or contact.
valueFor reply type buttons, value must equal label.
typeOptional: defaulted to reply
reply type buttons cause the text in the button to be immediately used as a new chat message by the contact when pressed. replys are only ever rendered to contacts (users will only see the body of the message) and are the only type allowed in chat messages.