Skip to content

fix(slack): extract attachment text for bot messages with empty text (#27616)#27642

Merged
Takhoffman merged 2 commits intoopenclaw:mainfrom
lailoo:fix/slack-empty-bot-text-27616
Mar 1, 2026
Merged

fix(slack): extract attachment text for bot messages with empty text (#27616)#27642
Takhoffman merged 2 commits intoopenclaw:mainfrom
lailoo:fix/slack-empty-bot-text-27616

Conversation

@lailoo
Copy link
Copy Markdown
Contributor

@lailoo lailoo commented Feb 26, 2026

Summary

Bot messages with empty text but content in attachments now trigger sessions when allowBots: true is set.

Problem

Monitoring webhooks (Prometheus Alertmanager, Gatus, etc.) send Slack messages with text: "" and all content in attachments. These messages were silently dropped because resolveSlackAttachmentContent only processes forwarded attachments (is_share: true), and the empty-body check at the end of prepareSlackMessage returned null.

Closes #27616

Changes

  • Added a botAttachmentText fallback in prepareSlackMessage that extracts text or fallback from non-forwarded attachments when the message is from a bot and would otherwise have an empty body.
  • The fallback only activates for bot messages (isBotMessage) and only when resolveSlackAttachmentContent didn't already extract text, avoiding double-inclusion.

Test plan

  • Added regression test: bot message with allowBots: true, empty text, and non-forwarded attachments now produces a non-null prepared message with attachment text in RawBody.
  • All 17 existing tests in prepare.test.ts continue to pass.
  • pnpm lint and pnpm format:check pass clean.

Effect on User Experience

Before: Bot messages from monitoring webhooks with empty text were silently ignored even with allowBots: true. Users had to manually reply in thread to trigger the agent.

After: The agent receives the attachment content and can autonomously react to alerts, enabling hands-free monitoring workflows.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Adds a fallback to extract text from bot message attachments when text is empty but content exists in attachments, fixing silent drops of monitoring webhook messages.

Key changes:

  • Extracts text or fallback from attachments for bot messages only when no forwarded attachment text was already extracted
  • Prevents double-inclusion by checking !attachmentContent?.text before running the bot fallback
  • Adds regression test verifying bot messages with empty text and non-forwarded attachments produce valid prepared messages

The implementation is targeted and sound, properly handling edge cases with .filter(Boolean) and empty string checks in rawBody.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is well-targeted with clear logic that prevents double-inclusion, includes proper edge case handling, and has good test coverage. All existing tests pass and the new test validates the exact scenario described in the linked issue.
  • No files require special attention

Last reviewed commit: e4fe011

@Takhoffman Takhoffman force-pushed the fix/slack-empty-bot-text-27616 branch from e4fe011 to cd9c889 Compare March 1, 2026 16:49
@Takhoffman Takhoffman merged commit 43ddb41 into openclaw:main Mar 1, 2026
9 checks passed
@Takhoffman
Copy link
Copy Markdown
Contributor

PR #27642 - fix(slack): extract attachment text for bot messages with empty text (#27616) (#27642)

Merged via squash.

  • Merge commit: 43ddb41
  • Verified: pnpm install --frozen-lockfile, pnpm build, pnpm check, pnpm test:macmini
  • Changes made: rebased onto current main, resolved CHANGELOG conflict, and fixed one strict typing issue in src/slack/monitor/message-handler/prepare.test.ts to keep CI green.

Thank you for the contribution.

@Takhoffman Takhoffman mentioned this pull request Mar 1, 2026
18 tasks
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 1, 2026
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
amitmiran137 pushed a commit to amitmiran137/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 15, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

(cherry picked from commit 43ddb41)
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 15, 2026
…penclaw#27616) (openclaw#27642)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

(cherry picked from commit 43ddb41)
alexey-pelykh added a commit to remoteclaw/remoteclaw that referenced this pull request Mar 15, 2026
…penclaw#27616) (openclaw#27642) (#1424)

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check
- pnpm test:macmini

(cherry picked from commit 43ddb41)

Co-authored-by: lailoo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack: Bot messages with empty text property don't trigger sessions

2 participants