Skip to content

Add a Slack-specific mrkdwn formatter #159

Description

@owainlewis

Problem

Slack responses are sent as raw model output. The model commonly returns standard Markdown, but Slack uses its own mrkdwn syntax. As a result, formatting such as **Title:** is shown literally in Slack instead of being rendered as bold text.

Example:

**Title:** I Built an AI Personal Assistant in Slack

Slack expects:

*Title:* I Built an AI Personal Assistant in Slack

This is separate from agent prompting and should be handled by the Slack channel adapter.

Proposed solution

Add a Slack-specific formatter that converts supported Markdown into Slack mrkdwn before messages are split and sent through chat.postMessage.

Support at least:

  • Bold: **text** to *text*
  • Strikethrough: ~~text~~ to ~text~
  • Links: [label](https://example.com) to <https://example.com|label>
  • Headings: render as bold text because Slack has no heading syntax
  • Blockquotes and lists
  • Inline and fenced code without rewriting formatting inside code spans
  • Correct escaping of Slack control characters such as &, <, and > where required

Prefer a parser-based conversion or another approach that avoids fragile global regular-expression replacements.

Acceptance criteria

  • Slack messages render common model-generated Markdown correctly.
  • **Title:** no longer appears literally in Slack.
  • Code spans and fenced code blocks preserve their contents.
  • Links are converted to Slack link syntax.
  • Formatting conversion happens before Slack message chunking.
  • Telegram and other channel formatting remain unchanged.
  • Unit tests cover bold text, headings, links, blockquotes, lists, code, escaping, and mixed formatting.
  • Existing Slack tests continue to pass.

Verification

Send a Slack response containing headings, bold text, a link, a blockquote, a list, inline code, and a fenced code block. Confirm it renders correctly in the Slack desktop or web client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions