Message Format

When you post a message on a Channel, there are a few things that happen on the server:

  1. The text markdown format is parsed.
  2. The first URL found in message.text is enriched, and additional information is added automatically. This gives you a preview of the images, videos, etc. from the open-graph data on the associated page.

Any slash commands such as /giphy, /ban, /flag, etc. are handled.### Attachment Format

Messages containing URLs will have a generated attachment with the following structure:

nametypedescriptiondefaultoptional
typestringThe attachment type based on the URL resource. This can be: audio, image or video
author_namestringThe name of the author.
titlestringThe attachment title.
title_linkstringThe link to which the attachment message points to.
textstringThe attachment text. It will be displayed in the channel next to the original message.
image_urlstringThe URL to the attached image. This is present for URL pointing to an image article (eg. Unsplash)
thumb_urlstringThe URL to the attached file thumbnail. You can use this to represent the attached link.
asset_urlstringThe URL to the audio, video or image related to the URL.
og_scrape_urlstringThe original URL that was used to scrape this attachment.

Open Graph Scraper

Our scraper uses the following user agent, as well as the latest desktop and mobile user agents: getstream.io/opengraph-bot facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php) If you plan to scrape any links to websites you can control, please ensure that this user agent isn’t blocked and returns valid opengraph data, for the best results.

Below is an example of URL enrichment as well as the resulting message structure:

await messageClient.SendMessageAsync(channel.Type,
 channel.Id,
 "jenny",
 "Check this bear out https://imgur.com/r/bears/4zmGbMN");
{
 "id": "thierry-5e9619ec-1a0d-443b-ab26-c597ed7af3d0",
 "text": "Check this bear out https://imgur.com/r/bears/4zmGbMN",
 "html": "<p>Check this bear out <a href=\"https://imgur.com/r/bears/4zmGbMN\" rel=\"nofollow\">https://imgur.com/r/bears/4zmGbMN</a></p>\n",
 "type": "regular",
 "user": {
  "id": "thierry",
  "role": "user",
  "created_at": "2019-04-03T14:42:47.087869Z",
  "updated_at": "2019-04-16T09:20:03.982283Z",
  "last_active": "2019-04-16T11:23:51.168113408+02:00",
  "online": true
 },
 "attachments": [
  {
   "type": "image",
   "author_name": "Imgur",
   "title": "An update: Dushi made it safe to Bear Sanctuary Müritz",
   "title_link": "https://imgur.com/4zmGbMN",
   "text": "1678 views on Imgur",
   "image_url": "https://i.imgur.com/4zmGbMN.jpg?fb",
   "thumb_url": "https://i.imgur.com/4zmGbMN.jpg?fb",
   "og_scrape_url": "https://imgur.com/r/bears/4zmGbMN"
  }
 ],
 "latest_reactions": [],
 "own_reactions": [],
 "reaction_groups": {
  "love": {
    "count": 9,
    "sum_scores": 9,
    "first_reaction_at": "2024-09-05T13:17:05.138248Z",
    "last_reaction_at": "2024-09-05T13:17:11.454912Z"
  },
  "clap":
    "count": 9,
    "sum_scores": 13,
    "first_reaction_at": "2024-09-05T13:17:05.673605Z",
    "last_reaction_at": "2024-09-05T13:17:13.211086Z"
  },
  "wow": {
    "count": 9,
    "sum_scores": 9,
    "first_reaction_at": "2024-09-05T13:17:05.059252Z",
    "last_reaction_at": "2024-09-05T13:17:13.066055Z"
  },
  "haha": {
    "count": 9,
    "sum_scores": 9,
    "first_reaction_at": "2024-09-05T13:17:05.522053Z",
    "last_reaction_at": "2024-09-05T13:17:10.87445Z"
  },
  "like": {
    "count": 7,
    "sum_scores": 7,
    "first_reaction_at": "2024-09-05T13:17:04.977203Z",
    "last_reaction_at": "2024-09-05T13:17:14.856949Z"
  }
 },
 "reply_count": 0,
 "created_at": "2019-04-16T09:40:04.665274Z",
 "updated_at": "2019-04-16T09:40:04.665274Z",
 "message_text_updated_at":"2024-02-26T10:26:38.26136Z"
}

Messages returned by the API follow this structure

nametypedescriptiondefaultoptional
idstringThe message ID. This is either created by Stream or set client side when the message is added.
htmlstringThe safe HTML generated from the raw text message. This field can only be set using server-side APIs or via the import
typestringThe message type. See below for more information.
userobjectThe author user object. Schema is as described in the Setting the user portion of the docs.
attachmentsarrayThe list of attachments, either provided by the user or generated from a command or as a result of URL scraping. A message can have at most 30 attachments.
latest_reactionsarrayThe latest reactions to the message created by any user. (Max 10 reactions)
own_reactionsarrayThe array of reactions added to the message by the current user. e.g. [ReactionObject1, ReactionObject2].
reaction_countsobjectThe reaction count by type for this message e.g. {“haha”: 3, “angry”: 2}. Please use reaction_groups instead, this field only exists for compatibility reasons.
reply_countintegerReserved field indicating the number of replies for this message.
parent_idstringThe ID of the parent message, if the message is a reply.
created_atdateReserved field indicating when the message was created.
updated_atdateReserved field indicating when the message was updated last time.
deleted_atdateReserved field indicating when the message was deleted.
mentioned_usersarray of usersThe list of users that are mentioned in this message.
message_text_updated_atdateField indicating when the message text was updated last time-
reaction_groupsobjectThe reaction groups by type. For example: {clap: {count: 5, sum_scores: 13, first_reaction_at: “2024-09-05T13:17:11.454912Z”, last_reaction_at: “2024-09-10T21:23:12.675478Z”}}-

Message Types

Chat supports different types of messages. The type of the message is set by the APIs or by chat bots and custom commands.

NameDescription
regularA regular message created in the channel. This is the default type for messages posted on a channel.
ephemeralA temporary message which is only delivered to one user. It is not stored in the channel history. Ephemeral messages are normally used by commands (e.g. /giphy ) to prompt messages or request for actions.
errorAn error message generated as a result of a failed command. It is also ephemeral, as it is not stored in the channel history and is only delivered to one user.
replyA message in a reply thread. Messages created with parent_id are automatically of this type.
systemA message generated by a system event, like updating the channel or muting a user.
deletedA soft deleted message.
© Getstream.io, Inc. All Rights Reserved.