@chat-adapter/slack 4.2.0 → 4.4.0

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/README.md CHANGED
@@ -37,29 +37,70 @@ chat.onNewMention(async (thread, message) => {
37
37
  | `botToken` | Yes | Slack bot token (starts with `xoxb-`) |
38
38
  | `signingSecret` | Yes | Slack signing secret for webhook verification |
39
39
 
40
- ## Required Slack Scopes
41
-
42
- Your Slack app needs these OAuth scopes:
43
-
44
- **Bot Token Scopes:**
45
- - `chat:write` - Send messages
46
- - `channels:history` - Read channel messages
47
- - `groups:history` - Read private channel messages
48
- - `im:history` - Read DM messages
49
- - `mpim:history` - Read group DM messages
50
- - `reactions:read` - Read reactions
51
- - `reactions:write` - Add reactions
52
- - `files:read` - Read file attachments
53
- - `users:read` - Read user info
54
-
55
- **Event Subscriptions:**
56
- - `message.channels` - Channel messages
57
- - `message.groups` - Private channel messages
58
- - `message.im` - Direct messages
59
- - `message.mpim` - Group DMs
60
- - `app_mention` - @mentions
61
- - `reaction_added` - Reaction events
62
- - `reaction_removed` - Reaction events
40
+ ## Environment Variables
41
+
42
+ ```bash
43
+ SLACK_BOT_TOKEN=xoxb-...
44
+ SLACK_SIGNING_SECRET=...
45
+ ```
46
+
47
+ ## Slack App Setup
48
+
49
+ ### 1. Create a Slack App
50
+
51
+ 1. Go to [api.slack.com/apps](https://api.slack.com/apps)
52
+ 2. Click **Create New App** → **From scratch**
53
+ 3. Enter app name and select workspace
54
+ 4. Click **Create App**
55
+
56
+ ### 2. Configure Bot Token Scopes
57
+
58
+ 1. Go to **OAuth & Permissions** in the sidebar
59
+ 2. Under **Scopes** → **Bot Token Scopes**, add:
60
+ - `app_mentions:read` - Receive @mention events
61
+ - `channels:history` - Read messages in public channels
62
+ - `channels:read` - View basic channel info
63
+ - `chat:write` - Send messages
64
+ - `groups:history` - Read messages in private channels
65
+ - `groups:read` - View basic private channel info
66
+ - `im:history` - Read direct messages
67
+ - `im:read` - View basic DM info
68
+ - `reactions:read` - View emoji reactions
69
+ - `reactions:write` - Add/remove emoji reactions
70
+ - `users:read` - View user info (for display names)
71
+
72
+ ### 3. Install App to Workspace
73
+
74
+ 1. Go to **OAuth & Permissions**
75
+ 2. Click **Install to Workspace**
76
+ 3. Authorize the app
77
+ 4. Copy the **Bot User OAuth Token** (starts with `xoxb-`) → `SLACK_BOT_TOKEN`
78
+
79
+ ### 4. Get Signing Secret
80
+
81
+ 1. Go to **Basic Information**
82
+ 2. Under **App Credentials**, copy **Signing Secret** → `SLACK_SIGNING_SECRET`
83
+
84
+ ### 5. Configure Event Subscriptions
85
+
86
+ 1. Go to **Event Subscriptions**
87
+ 2. Toggle **Enable Events** to On
88
+ 3. Set **Request URL** to: `https://your-domain.com/api/webhooks/slack`
89
+ - Slack will verify the URL immediately
90
+ 4. Under **Subscribe to bot events**, add:
91
+ - `app_mention` - When someone @mentions your bot
92
+ - `message.channels` - Messages in public channels
93
+ - `message.groups` - Messages in private channels
94
+ - `message.im` - Direct messages
95
+ 5. Click **Save Changes**
96
+
97
+ ### 6. (Optional) Enable Interactivity
98
+
99
+ If you want to use buttons, modals, or other interactive components:
100
+
101
+ 1. Go to **Interactivity & Shortcuts**
102
+ 2. Toggle **Interactivity** to On
103
+ 3. Set **Request URL** to: `https://your-domain.com/api/webhooks/slack`
63
104
 
64
105
  ## Features
65
106
 
@@ -71,6 +112,17 @@ Your Slack app needs these OAuth scopes:
71
112
  - Action callbacks (interactive components)
72
113
  - Direct messages
73
114
 
115
+ ## Troubleshooting
116
+
117
+ ### "Invalid signature" error
118
+ - Verify `SLACK_SIGNING_SECRET` is correct
119
+ - Check that the request timestamp is within 5 minutes (clock sync issue)
120
+
121
+ ### Bot not responding to messages
122
+ - Verify Event Subscriptions are configured
123
+ - Check that the bot has been added to the channel
124
+ - Ensure the webhook URL is correct and accessible
125
+
74
126
  ## License
75
127
 
76
128
  MIT
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CardElement, BaseFormatConverter, AdapterPostableMessage, Root, Adapter, ChatInstance, WebhookOptions, RawMessage, EmojiValue, StreamOptions, FetchOptions, FetchResult, ThreadInfo, Message, FormattedContent } from 'chat';
1
+ import { CardElement, BaseFormatConverter, AdapterPostableMessage, Root, Logger, Adapter, ChatInstance, WebhookOptions, RawMessage, ModalElement, EmojiValue, StreamOptions, FetchOptions, FetchResult, ThreadInfo, Message, FormattedContent } from 'chat';
2
2
 
3
3
  /**
4
4
  * Slack Block Kit converter for cross-platform cards.
@@ -60,6 +60,8 @@ interface SlackAdapterConfig {
60
60
  botToken: string;
61
61
  /** Signing secret for webhook verification */
62
62
  signingSecret: string;
63
+ /** Logger instance for error reporting */
64
+ logger: Logger;
63
65
  /** Override bot username (optional) */
64
66
  userName?: string;
65
67
  /** Bot user ID (will be fetched if not provided) */
@@ -132,7 +134,7 @@ declare class SlackAdapter implements Adapter<SlackThreadId, unknown> {
132
134
  private lookupUser;
133
135
  handleWebhook(request: Request, options?: WebhookOptions): Promise<Response>;
134
136
  /**
135
- * Handle Slack interactive payloads (button clicks, etc.).
137
+ * Handle Slack interactive payloads (button clicks, view submissions, etc.).
136
138
  * These are sent as form-urlencoded with a `payload` JSON field.
137
139
  */
138
140
  private handleInteractivePayload;
@@ -140,6 +142,9 @@ declare class SlackAdapter implements Adapter<SlackThreadId, unknown> {
140
142
  * Handle block_actions payload (button clicks in Block Kit).
141
143
  */
142
144
  private handleBlockActions;
145
+ private handleViewSubmission;
146
+ private handleViewClosed;
147
+ private modalResponseToSlack;
143
148
  private verifySignature;
144
149
  /**
145
150
  * Handle message events from Slack.
@@ -157,14 +162,12 @@ declare class SlackAdapter implements Adapter<SlackThreadId, unknown> {
157
162
  */
158
163
  private createAttachment;
159
164
  postMessage(threadId: string, message: AdapterPostableMessage): Promise<RawMessage<unknown>>;
160
- /**
161
- * Extract card element from a AdapterPostableMessage if present.
162
- */
163
- private extractCard;
164
- /**
165
- * Extract files from a AdapterPostableMessage if present.
166
- */
167
- private extractFiles;
165
+ openModal(triggerId: string, modal: ModalElement): Promise<{
166
+ viewId: string;
167
+ }>;
168
+ updateModal(viewId: string, modal: ModalElement): Promise<{
169
+ viewId: string;
170
+ }>;
168
171
  /**
169
172
  * Upload files to Slack and share them to a channel.
170
173
  * Returns the file IDs of uploaded files.