Skip to content

Add Slack blocks support to post_message - #6676

Open
suhaibmujahid wants to merge 2 commits into
slack-metadatafrom
slack-blocks
Open

Add Slack blocks support to post_message#6676
suhaibmujahid wants to merge 2 commits into
slack-metadatafrom
slack-blocks

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Resolves #6669

Extend Slack message actions to accept optional blocks payloads.


Stack created with GitHub Stacks CLIGive Feedback 💬

@suhaibmujahid
suhaibmujahid requested a review from a team as a code owner August 20, 2026 01:49
Extend Slack message actions to accept optional `blocks` payloads.
Copilot AI lite review requested due to automatic review settings August 20, 2026 03:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends Hackbot’s Slack action plumbing to support Slack Block Kit payloads on recorded slack.post_message actions, enabling richer message layouts while keeping text as a fallback.

Changes:

  • Add blocks recording support on the Slack action recording side (tests included).
  • Pass recorded blocks through to chat.postMessage in the apply-side Slack handler.
  • Add apply-side test coverage for posting recorded blocks while keeping text as a fallback.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
libs/hackbot-runtime/tests/test_slack_handler.py Adds an apply-side test asserting blocks are posted and text remains as fallback.
libs/hackbot-runtime/tests/test_slack_actions.py Adds recording-side tests for blocks behavior and validation around text/blocks.
libs/hackbot-runtime/hackbot_runtime/actions/slack.py Updates parameter shaping to optionally include blocks and adds blocks support to record_message.
libs/hackbot-runtime/hackbot_runtime/actions/handlers/slack_handler.py Threads optional blocks into the Slack SDK chat_postMessage call.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +27 to +40
def _params(
channel: str, text: str | None, blocks: list[dict] | None = None
) -> dict[str, str | list[dict]]:
if not channel:
raise ToolError("channel must not be blank")
if not text:
raise ToolError("text must not be blank")
return {"channel": channel, "text": text}
if not text and not blocks:
raise ToolError("either 'text' or 'blocks' must be provided")

params: dict[str, str | list[dict]] = {"channel": channel, "text": text}

if blocks:
params["blocks"] = blocks

return params
Comment on lines 77 to 82
def record_message(
recorder: ActionsRecorder,
channel: str,
text: str,
blocks: list[dict] | None = None,
*,
Comment on lines 58 to 63
response = _client().chat_postMessage(
channel=channel,
text=params["text"],
blocks=params.get("blocks"),
metadata=metadata,
)
Comment on lines 87 to +90
For a run whose outcome is always worth reporting: the wording is code, not
a model turn, and the message is recorded once the result exists.
"""
return recorder.record(ACTION_TYPE, _params(channel, text), ref=ref)
return recorder.record(ACTION_TYPE, _params(channel, text, blocks), ref=ref)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants