Skip to content

Add Slack Socket Mode listener (bux-slack.service)#174

Open
mathisdittrich wants to merge 1 commit into
mainfrom
slack-bot
Open

Add Slack Socket Mode listener (bux-slack.service)#174
mathisdittrich wants to merge 1 commit into
mainfrom
slack-bot

Conversation

@mathisdittrich
Copy link
Copy Markdown
Collaborator

Summary

  • New bux-slack.service + agent/slack_bot.py: Socket Mode listener that watches @mentions and DMs for a configured Slack user, dispatches a one-shot claude -p turn per event, and lets claude reply via the Composio MCP's SLACK_SEND_MESSAGE. Mirrors bux-tg.service architecture: persistent unit, dedupe on ts, EnvironmentFile=/etc/bux/slack.env.
  • Unit is ConditionPathExists=/etc/bux/slack.env, so it stays inert on boxes without Slack wired up. gh-equivalent for opt-in.
  • bootstrap.sh: re-adds bux-slack.service to the unit-install loop + the polkit allow-list; clears the stale-cleanup entry left over from the previous Slack incarnation.

Test plan

  • Deployed live on the box for the Browser Use workspace (Leia Assistant app A0B3E984DPZ). Socket Mode log shows hello received and persistent connection.
  • /invite @Leia Assistant into a channel, @harald to verify claude responds.
  • DM Harald in Slack to verify DM path triggers a reply.
  • Confirm dedupe on duplicate events_api envelopes (Slack does retry).

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread agent/slack_bot.py
ts = event.get("ts")
if not ts:
return
if ts in seen:
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 14, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

Comment thread agent/bootstrap.sh

# 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
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 14, 2026

Choose a reason for hiding this comment

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

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>
Fix with Cubic

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.

1 participant