|
2 | 2 |
|
3 | 3 | Transform the agent into a visible collaborator by bridging it to your Slack workspace. |
4 | 4 |
|
5 | | -## 1. Webhook Setup |
6 | | -To receive notifications, you need an **Incoming Webhook URL**: |
7 | | -1. Go to [Slack API Apps](https://api.slack.com/apps). |
8 | | -2. Create a new app (from scratch). |
9 | | -3. Enable **Incoming Webhooks**. |
10 | | -4. Add a new webhook to your channel and copy the URL. |
| 5 | +## 1. Webhook Setup (Step-by-Step) |
| 6 | + |
| 7 | +### Step 1: Access Slack API |
| 8 | +1. Open your browser and navigate to **[api.slack.com/apps](https://api.slack.com/apps)** |
| 9 | +2. Sign in with your Slack workspace credentials if prompted |
| 10 | + |
| 11 | +### Step 2: Create a New App |
| 12 | +1. Click the green **"Create New App"** button |
| 13 | +2. Select **"From scratch"** (not from a manifest) |
| 14 | +3. Fill in the form: |
| 15 | + - **App Name:** `CommitGuard AI` (or any name you prefer) |
| 16 | + - **Pick a workspace:** Select your Slack workspace from the dropdown |
| 17 | +4. Click **"Create App"** |
| 18 | + |
| 19 | +### Step 3: Enable Incoming Webhooks |
| 20 | +1. After creating the app, you'll land on the **Basic Information** page |
| 21 | +2. In the left sidebar under **"Features"**, click **"Incoming Webhooks"** |
| 22 | +3. Toggle the switch **ON** at the top of the page |
| 23 | +4. You'll see a confirmation: *"Incoming Webhooks are On"* |
| 24 | + |
| 25 | +### Step 4: Add Webhook to Channel |
| 26 | +1. Scroll down to **"Webhook URLs for Your Workspace"** |
| 27 | +2. Click **"Add New Webhook to Workspace"** |
| 28 | +3. A popup will ask: *"Where should CommitGuard AI post?"* |
| 29 | +4. Select your target channel (e.g., `#engineering`, `#accountability`) |
| 30 | +5. Click **"Allow"** |
| 31 | +6. Copy the generated webhook URL: |
| 32 | + ``` |
| 33 | + https://hooks.slack.com/services/YOUR_WORKSPACE_ID/YOUR_APP_ID/YOUR_WEBHOOK_TOKEN |
| 34 | + ``` |
11 | 35 |
|
12 | 36 | ## 2. Configuration |
13 | | -Add the URL to your `.env`: |
| 37 | + |
| 38 | +Add the webhook URL to your `.env` file: |
| 39 | +```bash |
| 40 | +SLACK_WEBHOOK_URL="https://hooks.slack.com/services/WORKSPACE_ID/APP_ID/TOKEN" |
| 41 | +``` |
| 42 | + |
| 43 | +Restart the service to apply changes: |
14 | 44 | ```bash |
15 | | -SLACK_WEBHOOK_URL="https://hooks.slack.com/services/T000.../B000.../XXXX..." |
| 45 | +docker-compose down && docker-compose up --build |
16 | 46 | ``` |
17 | 47 |
|
18 | | -## 3. User @Mentions (Identity Mapping) |
| 48 | +## 3. Test the Webhook |
| 49 | + |
| 50 | +Verify connectivity with a simple curl command: |
| 51 | +```bash |
| 52 | +curl -X POST \ |
| 53 | + -H 'Content-Type: application/json' \ |
| 54 | + -d '{"text": "🛡️ CommitGuard AI is connected!"}' \ |
| 55 | + 'YOUR_WEBHOOK_URL' |
| 56 | +``` |
| 57 | + |
| 58 | +You should see `ok` in the terminal and the message in your Slack channel. |
| 59 | + |
| 60 | +## 4. User @Mentions (Identity Mapping) |
| 61 | + |
19 | 62 | CommitGuard can ping users directly using their **Slack Member ID**. |
20 | 63 |
|
21 | | -### How to map a user: |
22 | | -Call the configuration endpoint with the user's Slack ID (found in their Slack Profile -> More -> Copy Member ID): |
| 64 | +### How to Find a Slack Member ID |
| 65 | +1. Open Slack and go to the user's profile |
| 66 | +2. Click **"More"** (three dots) |
| 67 | +3. Select **"Copy Member ID"** |
23 | 68 |
|
| 69 | +### How to Map a User |
| 70 | +Call the configuration endpoint: |
24 | 71 | ```bash |
25 | | -POST /api/v1/users/config/slack?user_id=john_dev&slack_id=U12345678 |
26 | | -Headers: X-API-Key: YOUR_API_KEY |
| 72 | +curl -X POST \ |
| 73 | + -H 'X-API-Key: YOUR_API_KEY' \ |
| 74 | + 'http://localhost:8000/api/v1/users/config/slack?user_id=john_dev&slack_id=U12345678' |
27 | 75 | ``` |
28 | 76 |
|
29 | 77 | ### The Result |
30 | 78 | When an alert is triggered, Slack turns the ID into a real mention: |
31 | 79 | > 🔔 **CommitGuard Alert for @John:** Checking in on commitment: fix the CSS bugs |
| 80 | +
|
| 81 | +--- |
| 82 | + |
| 83 | +> [!TIP] |
| 84 | +> You can create multiple webhooks for different channels (e.g., `#urgent-alerts` for critical issues, `#commitment-log` for routine tracking). |
0 commit comments