@elizaos/plugin-slack 2.0.0-alpha.5 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/README.md +209 -0
- package/auto-enable.ts +21 -0
- package/dist/index.js +2480 -2656
- package/dist/index.js.map +10 -21
- package/package.json +25 -24
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"message":"Not Found","documentation_url":"https://docs.github.com/rest/repos/contents#get-repository-content","status":"404"}
|
package/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# @elizaos/plugin-slack
|
|
2
|
+
|
|
3
|
+
Slack integration plugin for ElizaOS agents with Socket Mode support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Socket Mode**: Real-time event handling via Slack Socket Mode
|
|
8
|
+
- **Message Operations**: Send, edit, delete, read messages
|
|
9
|
+
- **Reactions**: Add and remove emoji reactions
|
|
10
|
+
- **Pins**: Pin and unpin messages, list pinned items
|
|
11
|
+
- **Channels**: List channels, read channel history
|
|
12
|
+
- **User Info**: Get user profile information
|
|
13
|
+
- **Threads**: Full thread support with reply tracking
|
|
14
|
+
- **Media**: Handle file uploads and attachments
|
|
15
|
+
- **Custom Emoji**: List workspace custom emoji
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @elizaos/plugin-slack
|
|
21
|
+
# or
|
|
22
|
+
bun add @elizaos/plugin-slack
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
### Required Environment Variables
|
|
28
|
+
|
|
29
|
+
```env
|
|
30
|
+
# Bot Token (starts with xoxb-)
|
|
31
|
+
SLACK_BOT_TOKEN=xoxb-your-bot-token
|
|
32
|
+
|
|
33
|
+
# App Token for Socket Mode (starts with xapp-)
|
|
34
|
+
SLACK_APP_TOKEN=xapp-your-app-token
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Optional Environment Variables
|
|
38
|
+
|
|
39
|
+
```env
|
|
40
|
+
# Signing Secret for request verification
|
|
41
|
+
SLACK_SIGNING_SECRET=your-signing-secret
|
|
42
|
+
|
|
43
|
+
# User Token for enhanced permissions (starts with xoxp-)
|
|
44
|
+
SLACK_USER_TOKEN=xoxp-your-user-token
|
|
45
|
+
|
|
46
|
+
# Comma-separated list of channel IDs to restrict bot to
|
|
47
|
+
SLACK_CHANNEL_IDS=C123456789,C987654321
|
|
48
|
+
|
|
49
|
+
# Ignore messages from other bots
|
|
50
|
+
SLACK_SHOULD_IGNORE_BOT_MESSAGES=false
|
|
51
|
+
|
|
52
|
+
# Only respond when mentioned
|
|
53
|
+
SLACK_SHOULD_RESPOND_ONLY_TO_MENTIONS=false
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Slack App Setup
|
|
57
|
+
|
|
58
|
+
1. Create a new Slack App at https://api.slack.com/apps
|
|
59
|
+
2. Enable Socket Mode in your app settings
|
|
60
|
+
3. Generate an App-Level Token with `connections:write` scope
|
|
61
|
+
4. Add the following Bot Token Scopes:
|
|
62
|
+
- `channels:history` - Read messages in public channels
|
|
63
|
+
- `channels:read` - View basic channel information
|
|
64
|
+
- `chat:write` - Send messages
|
|
65
|
+
- `emoji:read` - View custom emoji
|
|
66
|
+
- `files:read` - View files
|
|
67
|
+
- `groups:history` - Read messages in private channels
|
|
68
|
+
- `groups:read` - View basic private channel information
|
|
69
|
+
- `im:history` - Read direct messages
|
|
70
|
+
- `im:read` - View basic direct message information
|
|
71
|
+
- `mpim:history` - Read group direct messages
|
|
72
|
+
- `mpim:read` - View basic group direct message information
|
|
73
|
+
- `pins:read` - View pinned items
|
|
74
|
+
- `pins:write` - Add and remove pinned items
|
|
75
|
+
- `reactions:read` - View reactions
|
|
76
|
+
- `reactions:write` - Add and remove reactions
|
|
77
|
+
- `team:read` - View workspace information
|
|
78
|
+
- `users:read` - View basic user information
|
|
79
|
+
- `users:read.email` - View user email addresses
|
|
80
|
+
|
|
81
|
+
5. Enable Events and subscribe to:
|
|
82
|
+
- `message.channels` - Messages in public channels
|
|
83
|
+
- `message.groups` - Messages in private channels
|
|
84
|
+
- `message.im` - Direct messages
|
|
85
|
+
- `message.mpim` - Group direct messages
|
|
86
|
+
- `app_mention` - When the app is mentioned
|
|
87
|
+
- `member_joined_channel` - When a user joins a channel
|
|
88
|
+
- `member_left_channel` - When a user leaves a channel
|
|
89
|
+
- `reaction_added` - When a reaction is added
|
|
90
|
+
- `reaction_removed` - When a reaction is removed
|
|
91
|
+
|
|
92
|
+
6. Install the app to your workspace
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
|
|
96
|
+
### Add to your agent configuration
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import slackPlugin from "@elizaos/plugin-slack";
|
|
100
|
+
|
|
101
|
+
const agent = {
|
|
102
|
+
// ... other configuration
|
|
103
|
+
plugins: [slackPlugin],
|
|
104
|
+
};
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Character file configuration
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"name": "MyAgent",
|
|
112
|
+
"clients": ["slack"],
|
|
113
|
+
"settings": {
|
|
114
|
+
"slack": {
|
|
115
|
+
"shouldIgnoreBotMessages": true,
|
|
116
|
+
"shouldRespondOnlyToMentions": false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Actions
|
|
123
|
+
|
|
124
|
+
Slack messaging is exposed through the canonical message connector actions. Use
|
|
125
|
+
`source: "slack"` when a request needs to target Slack explicitly.
|
|
126
|
+
|
|
127
|
+
| Primary action | Operation | Description |
|
|
128
|
+
|----------------|-----------|-------------|
|
|
129
|
+
| `MESSAGE` | `send` | Send a message to a channel, DM, or thread |
|
|
130
|
+
| `MESSAGE` | `read` | Read recent message history from a channel, DM, or thread |
|
|
131
|
+
| `MESSAGE` | `search` | Search Slack message history |
|
|
132
|
+
| `MESSAGE` | `list_channels` | List available channels |
|
|
133
|
+
| `MESSAGE` | `list_servers` | List connected Slack workspaces |
|
|
134
|
+
| `MESSAGE` | `react` | Add or remove emoji reactions |
|
|
135
|
+
| `MESSAGE` | `edit` | Edit an existing message |
|
|
136
|
+
| `MESSAGE` | `delete` | Delete a message |
|
|
137
|
+
| `MESSAGE` | `pin` | Pin or unpin a message |
|
|
138
|
+
| `MESSAGE` | `get_user` | Get information about a user |
|
|
139
|
+
|
|
140
|
+
## Providers
|
|
141
|
+
|
|
142
|
+
| Provider | Description |
|
|
143
|
+
|----------|-------------|
|
|
144
|
+
| `slackChannelState` | Current channel context and metadata |
|
|
145
|
+
| `slackWorkspaceInfo` | Workspace-level information |
|
|
146
|
+
| `slackMemberList` | Members in the current channel |
|
|
147
|
+
|
|
148
|
+
## Events
|
|
149
|
+
|
|
150
|
+
The plugin emits the following events:
|
|
151
|
+
|
|
152
|
+
- `SLACK_MESSAGE_RECEIVED` - When a message is received
|
|
153
|
+
- `SLACK_MESSAGE_SENT` - When a message is sent
|
|
154
|
+
- `SLACK_REACTION_ADDED` - When a reaction is added
|
|
155
|
+
- `SLACK_REACTION_REMOVED` - When a reaction is removed
|
|
156
|
+
- `SLACK_APP_MENTION` - When the bot is mentioned
|
|
157
|
+
- `SLACK_MEMBER_JOINED_CHANNEL` - When a member joins a channel
|
|
158
|
+
- `SLACK_MEMBER_LEFT_CHANNEL` - When a member leaves a channel
|
|
159
|
+
- `SLACK_FILE_SHARED` - When a file is shared
|
|
160
|
+
|
|
161
|
+
## API Reference
|
|
162
|
+
|
|
163
|
+
### SlackService
|
|
164
|
+
|
|
165
|
+
The main service class providing direct access to Slack functionality:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { SlackService, SLACK_SERVICE_NAME } from "@elizaos/plugin-slack";
|
|
169
|
+
|
|
170
|
+
// Get service from runtime
|
|
171
|
+
const slackService = runtime.getService(SLACK_SERVICE_NAME) as SlackService;
|
|
172
|
+
|
|
173
|
+
// Send a message
|
|
174
|
+
await slackService.sendMessage(channelId, "Hello!", { threadTs: "..." });
|
|
175
|
+
|
|
176
|
+
// Add a reaction
|
|
177
|
+
await slackService.sendReaction(channelId, messageTs, "thumbsup");
|
|
178
|
+
|
|
179
|
+
// Get user info
|
|
180
|
+
const user = await slackService.getUser(userId);
|
|
181
|
+
|
|
182
|
+
// List channels
|
|
183
|
+
const channels = await slackService.listChannels();
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Troubleshooting
|
|
187
|
+
|
|
188
|
+
### Bot not responding to messages
|
|
189
|
+
|
|
190
|
+
1. Verify your `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` are correct
|
|
191
|
+
2. Check that Socket Mode is enabled in your Slack app
|
|
192
|
+
3. Ensure the bot has been invited to the channel
|
|
193
|
+
4. Check if `SLACK_SHOULD_RESPOND_ONLY_TO_MENTIONS` is enabled
|
|
194
|
+
|
|
195
|
+
### Permission errors
|
|
196
|
+
|
|
197
|
+
1. Verify the bot has all required OAuth scopes
|
|
198
|
+
2. Reinstall the app to your workspace after adding new scopes
|
|
199
|
+
3. Check if the channel is private and the bot is a member
|
|
200
|
+
|
|
201
|
+
### Socket Mode connection issues
|
|
202
|
+
|
|
203
|
+
1. Verify your `SLACK_APP_TOKEN` starts with `xapp-`
|
|
204
|
+
2. Check that the app-level token has `connections:write` scope
|
|
205
|
+
3. Ensure only one instance of the bot is running per token
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
package/auto-enable.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Auto-enable check for @elizaos/plugin-slack.
|
|
2
|
+
//
|
|
3
|
+
// Plugin manifest entry-point — referenced by package.json's
|
|
4
|
+
// `elizaos.plugin.autoEnableModule`. Keep this module light: env reads only,
|
|
5
|
+
// no service init, no transitive imports of the full plugin runtime. The
|
|
6
|
+
// auto-enable engine loads dozens of these per boot.
|
|
7
|
+
import type { PluginAutoEnableContext } from "@elizaos/core";
|
|
8
|
+
|
|
9
|
+
/** Enable when a `slack` connector block is present and not explicitly disabled. */
|
|
10
|
+
export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
|
|
11
|
+
const c = (ctx.config?.connectors as Record<string, unknown> | undefined)
|
|
12
|
+
?.slack;
|
|
13
|
+
if (!c || typeof c !== "object") return false;
|
|
14
|
+
const config = c as Record<string, unknown>;
|
|
15
|
+
if (config.enabled === false) return false;
|
|
16
|
+
// The full per-connector field check (botToken/appToken) lives in the
|
|
17
|
+
// central engine's isConnectorConfigured. We delegate to a simple "block
|
|
18
|
+
// present + not explicitly disabled" check here; the central engine's
|
|
19
|
+
// stricter check remains as a fallback during migration.
|
|
20
|
+
return true;
|
|
21
|
+
}
|