Slack Interactive Workflow - Deployment Summary

Date: 2026-02-19
Status: βœ… Scripts built, awaiting Slack app configuration


πŸ“¦ What Was Built

1. Core Handler

  • slack-interaction-handler.js - Processes button clicks, dropdown selections
  • Handles: Add Contact, Skip Contact, Mark Complete, Approve/Review/Skip workflows
  • Calls add-contact-to-deal.js and validate-deal-v3.js
  • Posts thread confirmations

2. Gateway Integration

  • gateway-slack-webhook.js - Express server for /api/slack/interactions
  • Verifies Slack signatures (prevents unauthorized requests)
  • Timestamp validation (prevents replay attacks)
  • Health check endpoint

3. Message Generator

  • generate-slack-contact-suggestion.js - Builds interactive message blocks
  • Dropdowns for role + association type
  • Action buttons (Add/Skip)
  • Footer actions (View HubSpot/Mark Complete)

4. Testing & Utilities

  • test-slack-interactive.js - End-to-end test suite
  • send-contact-suggestion-slack.js - Post messages for specific deals
  • slack-dr-commands.js - /dr command handlers (future)

5. Documentation

  • slack-button-workflow-guide.md - Implementation guide
  • slack-app-interactive-setup.md - Step-by-step config instructions
  • SLACK-INTERACTIVE-DEPLOYMENT.md - This file

πŸš€ Quick Start (5 Steps)

Step 1: Save Slack Signing Secret

echo "YOUR_SIGNING_SECRET" > /home/opsadmin/.openclaw/workspace/data/slack-signing-secret.txt
chmod 600 /home/opsadmin/.openclaw/workspace/data/slack-signing-secret.txt

Get signing secret from: https://api.slack.com/apps β†’ Your App β†’ Basic Information β†’ App Credentials

Step 2: Start Webhook Server

cd /home/opsadmin/.openclaw/workspace/scripts
node gateway-slack-webhook.js 18791 &

Or with PM2:

pm2 start gateway-slack-webhook.js --name slack-webhook -- 18791
pm2 save

Step 3: Configure Firewall

sudo ufw allow 18791/tcp comment "Slack webhook"
curl http://localhost:18791/api/slack/health

Step 4: Enable Interactivity in Slack App

  1. Go to https://api.slack.com/apps β†’ Your App
  2. Features β†’ Interactivity & Shortcuts
  3. Toggle On
  4. Request URL: http://YOUR_SERVER_IP:18791/api/slack/interactions
  5. Save Changes

Slack will verify the endpoint immediately.

Step 5: Test

cd /home/opsadmin/.openclaw/workspace/scripts
node test-slack-interactive.js 54223789480

Follow test output to post message and click buttons.


πŸ“‹ File Locations

Scripts

/home/opsadmin/.openclaw/workspace/scripts/
β”œβ”€β”€ slack-interaction-handler.js        (core handler)
β”œβ”€β”€ gateway-slack-webhook.js            (express server)
β”œβ”€β”€ generate-slack-contact-suggestion.js (message builder)
β”œβ”€β”€ send-contact-suggestion-slack.js    (post to Slack)
β”œβ”€β”€ test-slack-interactive.js           (test suite)
β”œβ”€β”€ add-contact-to-deal.js              (existing, called by handler)
└── validate-deal-v3.js                 (existing, called by handler)

Documentation

/home/opsadmin/.openclaw/workspace/docs/
β”œβ”€β”€ slack-button-workflow-guide.md      (implementation guide)
β”œβ”€β”€ slack-app-interactive-setup.md      (Slack app config)
└── SLACK-INTERACTIVE-DEPLOYMENT.md     (this file)

Data

/home/opsadmin/.openclaw/workspace/data/
β”œβ”€β”€ slack-signing-secret.txt            (create this)
β”œβ”€β”€ hubspot-pat.txt                     (existing)
└── salesmessage-oauth.json             (existing)

🎯 Production Deployment

Create /etc/systemd/system/slack-webhook.service:

[Unit]
Description=Slack Interactive Webhook Handler
After=network.target
 
[Service]
Type=simple
User=opsadmin
WorkingDirectory=/home/opsadmin/.openclaw/workspace/scripts
ExecStart=/usr/bin/node gateway-slack-webhook.js 18791
Restart=always
RestartSec=10
StandardOutput=append:/var/log/slack-webhook.log
StandardError=append:/var/log/slack-webhook.error.log
 
[Install]
WantedBy=multi-user.target

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable slack-webhook
sudo systemctl start slack-webhook
sudo systemctl status slack-webhook

2. Update Daily Cron

Modify 6 AM compliance cron to post interactive messages:

# Get current job
openclaw cron list
 
# Update payload to use new interactive format
openclaw cron update --id 4075e471-4190-4b16-841e-d0e68bf32b10 \
  --payload '{
    "kind": "agentTurn",
    "message": "Run contact compliance check. For any blocking deals, use send-contact-suggestion-slack.js to post interactive Slack messages to #atlas-build."
  }'

Or create new isolated job:

{
  name: "Contact Compliance with Slack Buttons",
  schedule: { kind: "cron", expr: "0 6 * * *", tz: "America/Los_Angeles" },
  payload: {
    kind: "agentTurn",
    message: "Check deal contact compliance and post interactive Slack suggestions"
  },
  sessionTarget: "isolated",
  enabled: true,
  notify: true
}

3. Monitoring

# Check webhook logs
tail -f /var/log/slack-webhook.log
 
# Check interaction counts
grep "Interaction received" /var/log/slack-webhook.log | wc -l
 
# Check errors
grep "ERROR" /var/log/slack-webhook.log
 
# Health check
watch -n 10 'curl -s http://localhost:18791/api/slack/health | jq'

πŸ§ͺ Testing Scenarios

Scenario 1: Single Contact Add

node send-contact-suggestion-slack.js 54223789480
# Click "Add to Deal" in Slack
# Verify contact added to HubSpot
# Check thread for confirmation

Scenario 2: Multiple Contacts

# Same deal, add multiple contacts via buttons
# Verify all added correctly
# Check final validation shows no missing contacts

Scenario 3: Skip Contact

# Click "Not Associated" button
# Verify contact skipped (logged but not added)
# Check thread confirmation

Scenario 4: Mark Complete

# After adding all contacts, click "Mark Complete"
# Verify deal marked as reviewed
# Check next cron run skips this deal

Scenario 5: Dry Run Review

node slack-dr-commands.js review 54223789480
# Post message to Slack
# Click "Approve All" / "Review Each" / "Skip All"
# Verify appropriate action taken

πŸ”’ Security Checklist

  • Signing secret verification implemented
  • Timestamp validation (5-minute window)
  • Bot token not exposed to client
  • HTTPS enabled (use nginx reverse proxy)
  • Rate limiting configured
  • Webhook endpoint firewall rules
  • Logs secured (no sensitive data)
  • Backup server configured (optional)

πŸ› Known Issues

Issue 1: Dropdowns Don’t Pre-Select

Status: Slack UI limitation
Impact: User must select from dropdown each time
Workaround: None needed, selections are correctly captured

Issue 2: Thread Reply Integration

Status: Pending OpenClaw message tool integration
Impact: Thread replies currently logged to console
Fix: Update postToThread() in slack-interaction-handler.js

Issue 3: Contact Suggestion Extraction

Status: suggest-missing-contacts.js not yet integrated
Impact: Messages show β€œno contacts found”
Fix: Wire up email template parser and SalesMessage search


πŸ“Š Success Metrics

Track these after deployment:

  • Button click rate: % of posted messages that get clicks
  • Add vs Skip ratio: How often contacts are added vs skipped
  • Time to resolution: Average time from post β†’ all contacts added
  • Error rate: % of button clicks that fail
  • Manual intervention: Deals marked complete without buttons

Dashboard query:

# Count interactions by type
grep "Interaction received" /var/log/slack-webhook.log | \
  grep -oP 'action: \K[^,}]+' | sort | uniq -c

πŸ”„ Rollback Plan

If something breaks:

  1. Stop webhook server:

    pm2 stop slack-webhook
    # or
    sudo systemctl stop slack-webhook
  2. Revert Slack app:

    • Disable Interactivity in Slack app settings
    • Messages will still post, buttons just won’t work
  3. Revert cron:

    openclaw cron update --id 4075e471-4190-4b16-841e-d0e68bf32b10 \
      --payload '{"kind":"systemEvent","text":"Run original compliance check"}'
  4. Fallback to manual: Users can still run add-contact-to-deal.js directly


πŸŽ‰ Next Steps

  1. βœ… Scripts built (this task)
  2. ⏳ Slack app configured (manual step, see setup guide)
  3. ⏳ Webhook server deployed (systemd service)
  4. ⏳ End-to-end test passed (real deal + buttons)
  5. ⏳ Cron job updated (6 AM daily run)
  6. ⏳ Monitoring enabled (logs + health checks)
  7. ⏳ Team trained (how to use buttons)

Ready to deploy? Follow the Quick Start above or see slack-app-interactive-setup.md for detailed steps.

Questions? Check troubleshooting section or review handler logs.

Last updated: 2026-02-19 01:05 AM UTC