For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

Message content

Structure text, attachments, and location shares in a message.

View as Markdown

Every message has "content" which specifies the information in the message. This could be some formatted text, a file attachment, or a shared location.

See the conceptual documentation for message content to learn more about how TalkJS represents message content.

protocol ContentBlock

Conforms to: Codable, Equatable, Sendable

The content of a message is structured as a list of content blocks.

No properties or methods are currently defined.

struct TextBlock

Conforms to: ContentBlock, SendContentBlock

A block of formatted text in a message’s content.

Method Overview

Properties

children
: EntityTree { get set }

constructor

TextBlock(children:)

Parameters

children
: EntityTree
Full documentation of each TextNode variant

struct Markup

Conforms to: Entity

A node in a TextBlock that renders its children with a specific style.

Method Overview

Properties

children
: EntityTree { get set }
type
: String

The kind of formatting to apply when rendering the children

  • type: "bold" is used when users type *text* and is rendered with HTML <strong>
  • type: "italic" is used when users type _text_ and is rendered with HTML <em>
  • type: "strikethrough" is used when users type ~text~ and is rendered with HTML <s>

constructor

Markup(type:children:) throws

Parameters

type
: String
children
: EntityTree

struct BulletList

Conforms to: Entity

A node in a TextBlock that adds indentation for a bullet-point list around its children (HTML <ul>).

Method Overview

Properties

children
: EntityTree { get set }

constructor

BulletList(children:)

Parameters

children
: EntityTree

struct BulletPoint

Conforms to: Entity

A node in a TextBlock that renders its children with a bullet-point (HTML <li>).

Method Overview

Properties

children
: [EntityTreeNode] { get set }

constructor

BulletPoint(children:)

Parameters

children
: [EntityTreeNode]

Conforms to: Clickable

A node in a TextBlock that renders its children as a clickable link (HTML <a>).

: EntityTree { get set }

Inherited from Clickable.children.

: String

The URL to open when the node is clicked.

Link(url:children:)

Parameters

: String
: EntityTree

Conforms to: Leaf

A node in a TextBlock that renders text as a link (HTML <a>).

: String

The text to display in the link.

: String

The URL to open when a user clicks this node.

AutoLink(url:text:)

Parameters

: String
: String

Conforms to: Clickable

A node in a TextBlock that renders its children as a clickable action link which triggers a custom action.

: String

The name of the custom action to invoke when the link is clicked.

: EntityTree { get set }

Inherited from Clickable.children.

: CustomData

The parameters to pass to the custom action when the link is clicked.

ActionLink(action:params:children:)

Parameters

: String
: CustomData
: EntityTree

struct ActionButton

Conforms to: Clickable

A node in a TextBlock that renders its children as a clickable action button which triggers a custom action.

Method Overview

Properties

action
: String

The name of the custom action to invoke when the button is clicked.

children
: EntityTree { get set }

Inherited from Clickable.children.

params
: CustomData

The parameters to pass to the custom action when the button is clicked.

constructor

ActionButton(action:params:children:)

Parameters

action
: String
params
: CustomData
children
: EntityTree

struct CodeSpan

Conforms to: Leaf

A node in a TextBlock that renders text in an inline code span (HTML <code>).

Method Overview

Properties

text
: String

Inherited from Leaf.text.

constructor

CodeSpan(text:)

Parameters

text
: String

struct CustomEmoji

Conforms to: Leaf

A node in a TextBlock that is used for custom emoji.

Method Overview

Properties

text
: String

The name (including colons at the start and end) of the custom emoji to show.

constructor

CustomEmoji(text:)

Parameters

text
: String

struct Mention

Conforms to: Leaf

A node in a TextBlock that is used when a user is mentioned.

Method Overview

Properties

id
: String

The ID of the user who is mentioned.

text
: String

The name of the user who is mentioned.

constructor

Mention(id:text:)

Parameters

id
: String
text
: String

protocol FileBlock

Conforms to: ContentBlock

No properties or methods are currently defined.

Full documentation of each FileBlock variant

struct GenericFileBlock

Conforms to: FileBlock

The most basic FileBlock variant, used whenever there is no additional metadata for a file.

Method Overview

Properties

filename
: String

The name of the file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this file in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

GenericFileBlock(url:size:filename:fileToken:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String

struct VideoBlock

Conforms to: FileBlock

A FileBlock variant for a video attachment, with additional video-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the video in seconds, if known.

filename
: String

The name of the video file, including file extension.

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this video in another message.

height (optional)
: Int?

The height of the video in pixels, if known.

size
: Int64

The size of the file in bytes.

url
: String

The URL where you can fetch the file.

width (optional)
: Int?

The width of the video in pixels, if known.

constructor

VideoBlock(url:size:filename:fileToken:width:height:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
width (optional)
: Int?
height (optional)
: Int?
duration (optional)
: Double?

struct ImageBlock

Conforms to: FileBlock

A FileBlock variant for an image attachment, with additional image-specific metadata.

Method Overview

Properties

filename
: String

The name of the image file, including file extension.

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this image in another message.

height (optional)
: Int?

The height of the image in pixels, if known.

size
: Int64

The size of the file in bytes.

url
: String

The URL where you can fetch the file.

width (optional)
: Int?

The width of the image in pixels, if known.

constructor

ImageBlock(url:size:filename:fileToken:width:height:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
width (optional)
: Int?
height (optional)
: Int?

struct AudioBlock

Conforms to: FileBlock

A FileBlock variant for an audio attachment, with additional audio-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the audio in seconds, if known

filename
: String

The name of the audio file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this file in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

AudioBlock(url:size:filename:fileToken:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
duration (optional)
: Double?

struct VoiceBlock

Conforms to: FileBlock

A FileBlock variant for a voice recording attachment, with additional voice-recording-specific metadata.

Method Overview

Properties

duration (optional)
: Double?

The duration of the voice recording in seconds, if known

filename
: String

The name of the file, including file extension

fileToken
: String

An encoded identifier for this file. Use in SendFileBlock to send this voice recording in another message.

size
: Int64

The size of the file in bytes

url
: String

The URL where you can fetch the file

constructor

VoiceBlock(url:size:filename:fileToken:duration:)

Parameters

url
: String
size
: Int64
filename
: String
fileToken
: String
duration (optional)
: Double?

struct LocationBlock

Conforms to: ContentBlock, SendContentBlock

A block showing a location in the world, typically because a user shared their location in the chat.

Method Overview

Properties

latitude
: Double

The north-south coordinate of the location.

Usually listed first in a pair of coordinates.

Must be a number between -90 and 90

longitude
: Double

The east-west coordinate of the location.

Usually listed second in a pair of coordinates.

Must be a number between -180 and 180

constructor

LocationBlock(latitude:longitude:)

Parameters

latitude
: Double
longitude
: Double

protocol SendContentBlock

Conforms to: Codable, Equatable, Sendable

The version of ContentBlock that is used when sending or editing messages.

No properties or methods are currently defined.

struct SendFileBlock

Conforms to: SendContentBlock

The version of FileBlock that is used when sending or editing messages.

Method Overview

Properties

fileToken
: String

The encoded identifier for the file, obtained by uploading a file with Session/sendFile, or taken from another message.

constructor

SendFileBlock(fileToken:)

Parameters

fileToken
: String