Skip to content

Commit 0cd3999

Browse files
Merge pull request #1384 from TheHive-Project/slackintegration-2
Add Slack responder to sync created channels into task
2 parents f6944dc + 787d789 commit 0cd3999

File tree

9 files changed

+721
-39
lines changed

9 files changed

+721
-39
lines changed

responders/Slack/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Slack Responders
2+
3+
<div align="center">
4+
<img src="./assets/slack-logo.png" alt="Slack Logo" width="150"/>
5+
</div>
6+
7+
This directory contains two Slack responders for TheHive integration:
8+
9+
1. **Slack_CreateChannel**: Creates a Slack channel for a TheHive case, invites participants, and optionally posts a case summary and description.
10+
2. **Slack_SyncChannel**: Syncs Slack channel conversations to TheHive task logs. Imports messages chronologically with file attachments for traceability.
11+
12+
---
13+
14+
## Features
15+
16+
### Slack_CreateChannel
17+
- Creates a Slack channel named `case-<caseId>` (customizable prefix)
18+
- Invites default participants by email
19+
- Sets channel visibility (private or public)
20+
- Posts case summary and/or case description (optional)
21+
22+
### Slack_SyncChannel
23+
- Retrieves all conversation history from channels with format `#case-CASEID`
24+
- Creates TheHive tasks in "Communication" category with individual task logs for each message
25+
- Downloads and attaches file attachments (images, documents) to task logs
26+
- Chronologically ordered messages with timestamps and usernames
27+
- Prevents duplicate syncing by tracking message timestamps
28+
- Converts Slack user IDs to readable usernames for better readability
29+
30+
## Preview
31+
32+
<div align="center">
33+
<a href="./assets/slack-history.png" target="_blank">
34+
<img src="./assets/slack-history.png" alt="Slack History" width="300" style="margin: 10px;"/>
35+
</a>
36+
<a href="./assets/thehive-slacksync-1.png" target="_blank">
37+
<img src="./assets/thehive-slacksync-1.png" alt="TheHive Slack Sync 1" width="300" style="margin: 10px;"/>
38+
</a>
39+
<a href="./assets/thehive-slacksync-2.png" target="_blank">
40+
<img src="./assets/thehive-slacksync-2.png" alt="TheHive Slack Sync 2" width="300" style="margin: 10px;"/>
41+
</a>
42+
</div>
43+
---
44+
45+
## Requirements
46+
47+
- A Slack workspace where you have permissions to create a bot.
48+
- Your bot must be allowed to create channels and invite users.
49+
50+
---
51+
52+
## 1. Create a Slack App & Bot Token
53+
54+
1. Go to [Slack API: Your Apps](https://api.slack.com/apps) and click **"Create New App"**.
55+
2. Choose **From scratch**, name your app, and pick your workspace.
56+
3. Under **Features**, click **OAuth & Permissions**.
57+
4. **Add these OAuth scopes** under **Bot Token Scopes**:
58+
59+
**For Slack_CreateChannel:**
60+
- `groups:write` - Manage private channels that your slack app has been added to and create new ones
61+
- `groups:write.invites` - Invite members to private channels
62+
- `groups:write.topic` - Set the description of private channels
63+
- `groups:read` - View basic information about private channels that your slack app has been added to
64+
- `users:read.email` - Look up user IDs by email
65+
- `chat:write` — Send messages as the bot
66+
67+
**For Slack_SyncChannel (additional scopes required):**
68+
- `channels:history` - Read messages in public channels
69+
- `groups:history` - View messages and other content in private channels that your slack app has been added to
70+
- `channels:read` - View basic information about public channels
71+
- `files:read` - Access file content and info (for downloading attachments)
72+
- `users:read` - View people in a workspace (for username conversion)
73+
74+
**⚠️ Important for File Downloads:**
75+
- Your Slack bot must be **added to the channel** where files were shared
76+
- Files shared before the bot was added may not be downloadable
77+
- Private files require the bot to have proper permissions
78+
79+
5. **Install the app to your workspace** (top right: "Install to Workspace").
80+
6. After install, **copy your Bot User OAuth Token** (starts with `xoxb-...`).
81+
82+
***Note: don't forget to reinstall your app to workspace to refresh permissions of your BOT.***
83+
84+
---
85+
86+
## 2. Enable and configure the Responders
87+
88+
Log into your Cortex instance, go to Organization > Responders and enable the desired JIRA responders with the appropriate configuration & API keys.
89+

responders/Slack/Slack_CreateChannel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "Fabien Bloume, StrangeBee",
55
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
66
"license": "AGPL-V3",
7-
"description": "Creates a Slack channel for a TheHive case, invites participants, and optionally posts a summary.",
7+
"description": "Creates a Slack channel for a TheHive case, invites participants, and optionally posts a case summary and description.",
88
"dataTypeList": ["thehive:case"],
99
"command": "Slack/slack.py",
1010
"baseConfig": "Slack",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "Slack_SyncChannel",
3+
"version": "1.0",
4+
"author": "Fabien Bloume, StrangeBee",
5+
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
6+
"license": "AGPL-V3",
7+
"description": "Syncs Slack channel conversations to TheHive task logs. Imports messages chronologically with file attachments for traceability.",
8+
"dataTypeList": ["thehive:case"],
9+
"command": "Slack/slack.py",
10+
"baseConfig": "Slack",
11+
"config": {
12+
"service": "syncchannel"
13+
},
14+
"configurationItems": [
15+
{
16+
"name": "slack_token",
17+
"description": "Slack Bot Token used for API authentication.",
18+
"type": "string",
19+
"multi": false,
20+
"required": true
21+
},
22+
{
23+
"name": "thehive_base_url",
24+
"description": "TheHive base URL for API access.",
25+
"type": "string",
26+
"multi": false,
27+
"required": true
28+
},
29+
{
30+
"name": "thehive_apikey",
31+
"description": "TheHive API key for authentication.",
32+
"type": "string",
33+
"multi": false,
34+
"required": true
35+
},
36+
{
37+
"name": "channel_prefix",
38+
"description": "Prefix to use for the Slack channel name. By default, 'case-'",
39+
"type": "string",
40+
"multi": false,
41+
"required": false,
42+
"defaultValue": "case-"
43+
}
44+
],
45+
"registration_required": true,
46+
"subscription_required": false,
47+
"free_subscription": true,
48+
"service_homepage": "https://www.slack.com"
49+
}
446 KB
Loading
75.6 KB
Loading
613 KB
Loading
427 KB
Loading

responders/Slack/image.png

75.6 KB
Loading

0 commit comments

Comments
 (0)