Markdown
The SDK uses mdast (Markdown AST) as the canonical format for message formatting. Each adapter converts the AST to the platform's native format.
Type re-exports
The chat package re-exports mdast's union and content types so adapters and downstream code can build exhaustively typed AST walkers without depending on mdast directly:
Adapters use this pattern to make the type checker reject the build when a new mdast node type is introduced upstream.
Node builders
root
Root node. Every AST needs one as its top-level wrapper.
Prop
Type
paragraph
A paragraph block.
text
Plain text node.
strong
Bold text.
emphasis
Italic text.
strikethrough
Strikethrough text.
inlineCode
Inline code span.
codeBlock
Fenced code block with optional language.
Prop
Type
link
Hyperlink.
Prop
Type
blockquote
Block quotation.
Parsing and stringifying
parseMarkdown
Parse a markdown string into an mdast AST.
stringifyMarkdown
Convert an mdast AST back to a markdown string.
toPlainText
Strip all formatting and return plain text.
markdownToPlainText
Shorthand for parsing markdown and extracting plain text.
AST utilities
walkAst
Transform an AST by visiting each node. Return a new value to replace the node, or undefined to keep it unchanged.
Type guards
Functions for checking node types:
| Guard | Matches |
|---|---|
isTextNode(node) | Plain text |
isParagraphNode(node) | Paragraph |
isStrongNode(node) | Bold |
isEmphasisNode(node) | Italic |
isDeleteNode(node) | Strikethrough |
isInlineCodeNode(node) | Inline code |
isCodeNode(node) | Code block |
isLinkNode(node) | Link |
isBlockquoteNode(node) | Blockquote |
isListNode(node) | List |
isListItemNode(node) | List item |
isTableNode(node) | Table |
isTableRowNode(node) | Table row |
isTableCellNode(node) | Table cell |
getNodeChildren / getNodeValue
Safely access node properties without type narrowing.
Table utilities
tableToAscii
Render an mdast Table node as a padded ASCII table string. Used by adapters that lack native table support (Google Chat, Discord, Telegram).
Output:
tableElementToAscii
Render a table from headers and string row arrays as a padded ASCII table. Used for card TableElement fallback rendering.
Platform formatting
You write standard markdown, and each adapter converts it to the platform's native syntax. This table shows how each platform renders common formatting.
| Feature | Slack | Teams | Google Chat |
|---|---|---|---|
| Bold | **text** | **text** | *text* |
| Italic | _text_ | _text_ | _text_ |
| Strikethrough | ~~text~~ | ~~text~~ | ~text~ |
| Code | `code` | `code` | `code` |
| Code blocks | ``` | ``` | ``` |
| Links | [text](url) | [text](url) | [text](url) |
| Lists | Supported | Supported | Supported |
| Blockquotes | > | > | Simulated with > prefix |
| Tables | Native (markdown_text) | Native GFM | ASCII fallback |
| Mentions | <@USER> | <at>name</at> | <users/{id}> |
Slack accepts standard markdown via the markdown_text field on chat.postMessage and related methods, so the SDK passes markdown through directly. Incoming Slack messages still arrive as legacy mrkdwn (*bold*, <url|text>) and are parsed transparently. If you need to send mrkdwn yourself, use { raw: "..." }.
The AST builders and parseMarkdown handle these conversions for you. The table is mainly useful when you work with raw platform payloads or debug formatting issues.