Skip to content
Merged
Changes from all commits
Commits
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
82 changes: 25 additions & 57 deletions internal/site/lib/slack-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,9 @@
/**
* Creates a Slack manifest URL for app creation.
*/

export interface SlackManifest {
display_information: {
name: string;
description?: string;
};
features?: {
bot_user?: {
display_name: string;
always_online?: boolean;
};
app_home?: {
home_tab_enabled?: boolean;
messages_tab_enabled?: boolean;
messages_tab_read_only_enabled?: boolean;
};
assistant_view: {
assistant_description: string;
suggested_prompts: string[];
};
};
oauth_config: {
scopes: {
bot?: string[];
user?: string[];
};
};
settings?: {
event_subscriptions?: {
request_url: string;
bot_events?: string[];
};
interactivity?: {
is_enabled: boolean;
request_url: string;
};
org_deploy_enabled?: boolean;
socket_mode_enabled?: boolean;
token_rotation_enabled?: boolean;
};
}

/**
* Creates a URL to initialize Slack App creation with a manifest.
* @param manifest The Slack App manifest configuration
* @returns URL to create the Slack app with the provided manifest
*/
export function createSlackAppUrl(manifest: SlackManifest): string {
export function createSlackAppUrl(manifest: unknown): string {
const manifestJson = encodeURIComponent(JSON.stringify(manifest));
return `https://api.slack.com/apps?new_app=1&manifest_json=${manifestJson}`;
}
Expand All @@ -59,18 +14,15 @@ export function createSlackAppUrl(manifest: SlackManifest): string {
* @param webhookUrl The webhook URL for event subscriptions
* @returns A Slack manifest configured for the agent
*/
export function createAgentSlackManifest(
appName: string,
webhookUrl: string
): SlackManifest {
export function createAgentSlackManifest(appName: string, webhookUrl: string) {
return {
display_information: {
name: appName,
description: `Chat with ${appName}`,
description: "A Blink agent for Slack",
},
features: {
bot_user: {
display_name: appName,
display_name: appName.toString(),
always_online: true,
},
app_home: {
Expand All @@ -79,37 +31,53 @@ export function createAgentSlackManifest(
messages_tab_read_only_enabled: false,
},
assistant_view: {
assistant_description: `A helpful assistant powered by Blink`,
suggested_prompts: [],
assistant_description: "A helpful assistant powered by Blink",
},
},
oauth_config: {
scopes: {
bot: [
"app_mentions:read",
"assistant:write",
"reactions:write",
"reactions:read",
"channels:history",
"chat:write",
"groups:history",
"groups:read",
"files:read",
"im:history",
"im:read",
"im:write",
"mpim:history",
"mpim:read",
"users:read",
"links:read",
"commands",
],
},
},
settings: {
event_subscriptions: {
request_url: webhookUrl,
bot_events: [
"assistant_thread_context_changed",
"assistant_thread_started",
"app_mention",
"message.channels",
"message.groups",
"message.im",
"reaction_added",
"reaction_removed",
"assistant_thread_started",
"member_joined_channel",
],
},
interactivity: {
is_enabled: true,
request_url: webhookUrl,
},
token_rotation_enabled: false,
org_deploy_enabled: false,
socket_mode_enabled: false,
token_rotation_enabled: false,
},
};
}
Loading