Slack Bot Integration (Experimental)

The sfp-server includes an AI-powered Slack bot that enables teams to interact with their Salesforce DevOps workflows through natural language conversations. The bot provides real-time insights into builds, releases, environments, and can execute sfp commands directly from Slack.

Overview

The Slack bot integration uses Slack's Bolt framework with Socket Mode for secure, bidirectional communication. It features:

  • Natural Language Processing: Ask questions in plain English

  • Real-time Status Updates: Get build, release, and environment information

  • Thread Context: Maintains conversation history for contextual responses

  • AI-Powered Assistance: Leverages LLM providers for intelligent responses

Prerequisites

Before setting up the Slack bot:

  1. sfp-server must be running (see Setting up sfp server)

  2. Admin access to your Slack workspace

  3. LLM Provider configured (OpenAI or Anthropic) for AI features

Quick Setup

Step 1: Create a Slack App

  1. Visit api.slack.com/apps and click Create New App

  2. Choose From an app manifest

  3. Select your workspace

  4. Use the sfp CLI to generate the manifest:

sfp server slack manifest
  1. Copy the generated manifest and paste it in Slack

  2. Review and create the app

Step 2: Configure Tokens

After creating your Slack app:

  1. Navigate to Basic Information > App-Level Tokens

  2. Create a token with connections:write scope

  3. Copy the xapp- token (SLACK_APP_TOKEN)

  4. Go to OAuth & Permissions and copy the Bot User OAuth Token (starts with xoxb-)

  5. From Basic Information, copy the Signing Secret

Step 3: Configure sfp-server

Run the interactive setup wizard:

sfp server slack setup

This will guide you through:

  • Entering your Slack tokens

  • Configuring the AI provider (optional)

  • Testing the connection

Alternatively, set environment variables manually:

# Required for Socket Mode
export SLACK_APP_TOKEN="xapp-your-app-token"
export SLACK_SIGNING_SECRET="your-signing-secret"
export SLACK_BOT_TOKEN="xoxb-your-bot-token"

# Optional - for AI features
export OPENAI_API_KEY="your-openai-key"
# OR
export ANTHROPIC_API_KEY="your-anthropic-key"

Step 4: Install to Workspace

  1. In your Slack app settings, go to Install App

  2. Click Install to Workspace

  3. Review and authorize permissions

  4. The bot should now appear in your workspace

Usage

Natural Language Queries

Mention the bot (@codev or your configured name) with questions:

@codev what's the status of the latest build for sf-core?
@codev show me recent releases for the sales domain
@codev list all active environments

Direct Messages

Send direct messages to the bot for private interactions:

What packages failed validation today?
Show me the deployment history for UAT

Example Interactions

Build Status

User: @codev build status for my-repo
Bot: 📊 Latest builds for my-repo:
  ✅ Build #123 - Completed (10 min ago)
  🔄 Build #124 - In Progress (started 2 min ago)

Release Information

User: @codev recent releases for sales domain
Bot: 📦 Recent releases for sales:
  • v2.1.0 - Deployed to PROD (2 days ago)
  • v2.0.9 - Deployed to UAT (5 days ago)

Configuration Options

Docker Compose Configuration

When using Docker Compose, add these environment variables to your .env file:

# Slack Configuration
SLACK_APP_TOKEN=xapp-your-token
SLACK_SIGNING_SECRET=your-signing-secret
SLACK_BOT_TOKEN=xoxb-your-bot-token

# Optional AI Configuration
AI_PROVIDER=openai
OPENAI_API_KEY=your-api-key

Advanced Configuration

The bot behavior can be customized through environment variables:

Variable
Description
Default

SLACK_LOG_LEVEL

Logging verbosity (debug, info, warn, error)

info

SLACK_APP_NAME

Display name for the bot

codev

AI_MODEL

Specific AI model to use

Provider default

AI_TIMEOUT

Timeout for AI responses (ms)

30000

CLI Commands

sfp provides several commands to manage the Slack integration:

Setup Wizard

sfp server slack setup [--manual] [--skip-test]

Check Status

sfp server slack status

Test Connection

sfp server slack test

Update Configuration

sfp server slack update --token <token-type> --value <token-value>

List Workspaces

sfp server slack list

Generate Manifest

sfp server slack manifest [--name <app-name>]

Troubleshooting

Bot Not Responding

  1. Check Socket Mode Connection:

sfp server slack status
  1. Verify Tokens:

  • Ensure all three tokens are correctly configured

  • Check token scopes match the manifest

  1. Review Logs:

sfp server logs --service api --tail 100

Permission Errors

Ensure the bot has these OAuth scopes:

  • app_mentions:read

  • chat:write

  • im:history

  • im:write

  • reactions:write

AI Features Not Working

  1. Verify LLM provider configuration:

sfp ai auth --provider <provider>
  1. Check API key validity

  2. Ensure sufficient API credits/quota

Limitations

  • Workspace Limit: Currently supports single workspace configuration

  • Rate Limits: Subject to Slack API rate limits

  • Context Window: AI responses limited by LLM context window

  • Command Execution: Some sfp commands may timeout in Slack's 3-second limit

Next Steps

Last updated