Message Format
Confused about "Message Format"?
Let us know how we can improve our documentation:
When you post a message on a Channel, there are a few things that happen on the server:
- The text markdown format is parsed.
- 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.
/giphy
, /ban
, /flag
, etc. are handled.Attachment Format
Copied!Confused about "Attachment Format"?
Let us know how we can improve our documentation:
Messages containing URLs will have a generated attachment with the following structure:
name | type | description | default | optional |
---|---|---|---|---|
type | string | The attachment type based on the URL resource. This can be: audio, image or video | ✓ | |
author_name | string | The name of the author. | ✓ | |
title | string | The attachment title. | ✓ | |
title_link | string | The link to which the attachment message points to. | ✓ | |
text | string | The attachment text. It will be displayed in the channel next to the original message. | ✓ | |
image_url | string | The URL to the attached image. This is present for URL pointing to an image article (eg. Unsplash) | ✓ | |
thumb_url | string | The URL to the attached file thumbnail. You can use this to represent the attached link. | ✓ | |
asset_url | string | The URL to the audio, video or image related to the URL. | ✓ | |
og_scrape_url | string | The original URL that was used to scrape this attachment. | ✓ |
Open Graph Scraper
Copied!Confused about "Open Graph Scraper"?
Let us know how we can improve our documentation:
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:
Messages returned by the API follow this structure:
Copied!Confused about "Messages returned by the API follow this structure: "?
Let us know how we can improve our documentation:
name | type | description | default | optional |
---|---|---|---|---|
id | string | The message ID. This is either created by Stream or set client side when the message is added. | ✓ | |
html | string | The safe HTML generated from the raw text message. This field can only be set using server-side APIs or via the import | ✓ | |
type | string | The message type. See below for more information. | ✓ | |
user | object | The author user object. Schema is as described in the Setting the user portion of the docs. | ✓ | |
attachments | array | The 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_reactions | array | The latest reactions to the message created by any user. (Max 10 reactions) | ✓ | |
own_reactions | array | The array of reactions added to the message by the current user. e.g. [ReactionObject1, ReactionObject2] . | ✓ | |
reaction_counts | object | The 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_count | integer | Reserved field indicating the number of replies for this message. | ✓ | |
parent_id | string | The ID of the parent message, if the message is a reply. | ✓ | |
created_at | date | Reserved field indicating when the message was created. | ✓ | |
updated_at | date | Reserved field indicating when the message was updated last time. | ✓ | |
deleted_at | date | Reserved field indicating when the message was deleted. | ✓ | |
mentioned_users | array of users | The list of users that are mentioned in this message. | ✓ | |
message_text_updated_at | date | Field indicating when the message text was updated last time | - | ✓ |
reaction_groups | object | The 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
Copied!Confused about "Message Types"?
Let us know how we can improve our documentation:
Chat supports different types of messages. The type of the message is set by the APIs or by chat bots and custom commands.
Name | Description |
---|---|
regular | A regular message created in the channel. This is the default type for messages posted on a channel. |
ephemeral | A 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. |
error | An 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. |
reply | A message in a reply thread. Messages created with |
system | A message generated by a system event, like updating the channel or muting a user. |
deleted | A soft deleted message. |