Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
d849bbe
feat(slack): Enhance DM and file handling with new upload functionali…
yuriassuncx Sep 13, 2025
7610493
refactor(slack): Remove unused file download and info actions
yuriassuncx Sep 13, 2025
9648018
refactor(slack): Reorder and optimize SCOPES in constants.ts
yuriassuncx Sep 13, 2025
9479dcb
fix: improve openDmChannel function suggested by coderabbitai
yuriassuncx Sep 13, 2025
eb6f357
feat(slack): add pagination support to channel and DM history retrieval
yuriassuncx Sep 13, 2025
9b7395b
feat(slack): enhance file upload and message posting with improved re…
yuriassuncx Sep 13, 2025
92b49f1
feat(slack): add titles to various actions for improved clarity and d…
yuriassuncx Sep 13, 2025
f52a5c4
fix: improvements suggested by coderabbitai
yuriassuncx Sep 13, 2025
433be8f
feat(slack): enhance Slack API response handling with improved data s…
yuriassuncx Sep 14, 2025
8d9e729
feat: new improvements suggested by coderabbit
yuriassuncx Sep 14, 2025
5d770cd
feat(slack): implement new file upload V2 API and update documentatio…
yuriassuncx Sep 14, 2025
c3b02d6
Merge branch 'feat/slack-improvements' of https://github.com/yuriassu…
yuriassuncx Sep 14, 2025
e33e51a
refactor(slack): update response handling to use new data structure i…
yuriassuncx Sep 14, 2025
fa3635c
feat: new improvements added by coderabbit
yuriassuncx Sep 15, 2025
c4d719f
refactor(slack): update UploadFileResponse to expose a safe subset of…
yuriassuncx Sep 15, 2025
6dd38c4
feat: new improvements to upload action
yuriassuncx Sep 15, 2025
e7d4e16
fix: new improvements added to file action by coderrabit
yuriassuncx Sep 15, 2025
3f5072d
fix: remove unnecessary closing braces in uploadFile function
yuriassuncx Sep 15, 2025
85f7de7
fix: adjust default channel limit to 100 for consistency in Slack API…
yuriassuncx Sep 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion slack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ A Deco app for integrating with Slack using OAuth 2.0 authentication. This app a
- 📋 **Channel Operations** - List and interact with workspace channels
- 👥 **User Management** - Get user information and profiles
- 🎯 **Reactions** - Add emoji reactions to messages
- 🔄 **Automatic Token Refresh** - Handles token expiration automatically
- � **File Upload V2** - Upload files using the new Slack API (files.upload sunset Nov 12, 2025)
- �🔄 **Automatic Token Refresh** - Handles token expiration automatically

## ⚠️ IMPORTANT: File Upload API Migration

**The Slack `files.upload` API will be sunset on November 12, 2025.** This app now includes:

- ✅ **New V2 Upload API** - Using `files.getUploadURLExternal` + `files.completeUploadExternal`
- ⚠️ **Legacy API Support** - With deprecation warnings (will be removed)
- 📖 **Migration Guide** - See [UPLOAD_MIGRATION.md](./UPLOAD_MIGRATION.md) for details

**Action Required**: Update your file upload code to use `uploadFileV2()` method before November 12, 2025.

## Setup Instructions

Expand Down Expand Up @@ -78,6 +89,22 @@ After OAuth setup, the app will automatically:
### Reactions
- `addReaction(channelId, timestamp, reaction)` - Add emoji reaction

### File Upload
- `uploadFileV2(options)` - Upload files using new V2 API (recommended)
- `uploadFile(options)` - Upload files using legacy API (deprecated, shows warning)

**New V2 Upload Example:**
```typescript
const response = await slack.uploadFileV2({
channels: "C1234567890", // Optional
file: fileBlob, // Supports Uint8Array, Blob, File, base64, data URL
filename: "document.pdf",
title: "Important Document",
thread_ts: "1234567890.123456", // Optional - upload to thread
initial_comment: "Here's the document"
});
```

## Migration from Bot Token

If you're migrating from the previous bot token approach:
Expand Down
1 change: 1 addition & 0 deletions slack/actions/deco-chat/channels/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { AppContext, SlackWebhookPayload } from "../../../mod.ts";

/**
* @name DECO_CHAT_CHANNELS_INVOKE
* @title Deco Chat Channel Invoke
* @description This action is triggered when slack sends a webhook event
*/
export default async function invoke(
Expand Down
1 change: 1 addition & 0 deletions slack/actions/deco-chat/channels/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AppContext } from "../../../mod.ts";

/**
* @name DECO_CHAT_CHANNELS_JOIN
* @title Deco Chat Channel Join
* @description This action is triggered when channel is selected
*/
export default async function join(
Expand Down
1 change: 1 addition & 0 deletions slack/actions/deco-chat/channels/leave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { AppContext } from "../../../mod.ts";

/**
* @name DECO_CHAT_CHANNELS_LEAVE
* @title Deco Chat Channel Leave
* @description This action is triggered when slack integration is left
*/
export default async function leave(
Expand Down
53 changes: 31 additions & 22 deletions slack/actions/dms/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,58 @@ export interface SendDmProps {
blocks?: unknown[];
}

export interface SendDmResponse {
success: boolean;
message: string;
channelId?: string;
ts?: string;
messageData?: {
ok: boolean;
channel: string;
ts: string;
warning?: string;
response_metadata?: {
warnings?: string[];
};
};
}

/**
* @name DMS_SEND
* @title Send DM
* @description Sends a direct message to a user
* @action send-dm
*/
export default async function sendDm(
props: SendDmProps,
_req: Request,
ctx: AppContext,
): Promise<
{ success: boolean; message: string; channelId?: string; ts?: string }
> {
): Promise<SendDmResponse> {
try {
// Open a DM channel with the user
const channelResponse = await ctx.slack.openDmChannel(props.userId);

if (!channelResponse.ok) {
return {
success: false,
message: `Failed to open DM channel: ${
channelResponse.error || "Unknown error"
}`,
};
}

const channelId = channelResponse.data.channel.id;

// Send the message to the DM channel
const messageResponse = await ctx.slack.postMessage(channelId, props.text, {
// Send message directly to the user ID (Slack automatically opens DM channel)
const messageResponse = await ctx.slack.postMessage(props.userId, props.text, {
blocks: props.blocks,
});

if (!messageResponse.ok) {
return {
success: false,
message: "Failed to send DM: Unknown error",
message: `Failed to send DM: ${messageResponse.error || "Unknown error"}`,
};
}

return {
success: true,
message: "DM sent successfully",
channelId,
ts: messageResponse.ts,
channelId: messageResponse.data.channel,
ts: messageResponse.data.ts,
messageData: {
ok: messageResponse.ok,
channel: messageResponse.data.channel,
ts: messageResponse.data.ts,
warning: messageResponse.data.warning,
response_metadata: messageResponse.response_metadata,
},
};
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
Expand Down
72 changes: 0 additions & 72 deletions slack/actions/files/download.ts

This file was deleted.

43 changes: 0 additions & 43 deletions slack/actions/files/info.ts

This file was deleted.

Loading
Loading