Add Slack Socket Mode listener (bux-slack.service)#174
Open
mathisdittrich wants to merge 1 commit into
Open
Conversation
Listens for @mentions of the configured Slack user and DMs over Socket Mode, dispatches a one-shot claude turn per event, and lets claude reply via the Composio MCP's SLACK_SEND_MESSAGE. Mirrors bux-tg's architecture (persistent unit, dedupe on ts, EnvironmentFile from /etc/bux/slack.env). The unit is ConditionPathExists-gated on slack.env so it stays inert on boxes that haven't been wired to a Slack workspace yet. Bootstrap drops the stale-cleanup entry for the previous bux-slack incarnation and re-adds the unit to the install loop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="agent/bootstrap.sh">
<violation number="1" location="agent/bootstrap.sh:318">
P2: `bux-slack.service` is enabled but not included in update restart/order handling, so Slack code changes may not take effect after bootstrap updates.</violation>
</file>
<file name="agent/slack_bot.py">
<violation number="1" location="agent/slack_bot.py:189">
P1: Deduping by `ts` alone can drop legitimate events from other channels; use a channel-scoped dedupe key (e.g., `channel:ts`).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
| ts = event.get("ts") | ||
| if not ts: | ||
| return | ||
| if ts in seen: |
Contributor
There was a problem hiding this comment.
P1: Deduping by ts alone can drop legitimate events from other channels; use a channel-scoped dedupe key (e.g., channel:ts).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent/slack_bot.py, line 189:
<comment>Deduping by `ts` alone can drop legitimate events from other channels; use a channel-scoped dedupe key (e.g., `channel:ts`).</comment>
<file context>
@@ -0,0 +1,258 @@
+ ts = event.get("ts")
+ if not ts:
+ return
+ if ts in seen:
+ LOG.info("dup ts=%s, skipping", ts)
+ return
</file context>
|
|
||
| # bux-slack is enabled-but-conditional on /etc/bux/slack.env existing | ||
| # (ConditionPathExists in the unit). Writing slack.env starts it. | ||
| systemctl enable bux-slack.service |
Contributor
There was a problem hiding this comment.
P2: bux-slack.service is enabled but not included in update restart/order handling, so Slack code changes may not take effect after bootstrap updates.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At agent/bootstrap.sh, line 318:
<comment>`bux-slack.service` is enabled but not included in update restart/order handling, so Slack code changes may not take effect after bootstrap updates.</comment>
<file context>
@@ -313,6 +313,10 @@ systemctl enable bux-browser-keeper.service
+# bux-slack is enabled-but-conditional on /etc/bux/slack.env existing
+# (ConditionPathExists in the unit). Writing slack.env starts it.
+systemctl enable bux-slack.service
+
# Boot-time pull runs ahead of the others on every reboot.
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bux-slack.service+agent/slack_bot.py: Socket Mode listener that watches @mentions and DMs for a configured Slack user, dispatches a one-shotclaude -pturn per event, and lets claude reply via the Composio MCP'sSLACK_SEND_MESSAGE. Mirrorsbux-tg.servicearchitecture: persistent unit, dedupe on ts,EnvironmentFile=/etc/bux/slack.env.ConditionPathExists=/etc/bux/slack.env, so it stays inert on boxes without Slack wired up.gh-equivalent for opt-in.bootstrap.sh: re-addsbux-slack.serviceto the unit-install loop + the polkit allow-list; clears the stale-cleanup entry left over from the previous Slack incarnation.Test plan
A0B3E984DPZ). Socket Mode log showshello receivedand persistent connection./invite @Leia Assistantinto a channel,@haraldto verify claude responds.events_apienvelopes (Slack does retry).🤖 Generated with Claude Code