Skip to content

Commit

Permalink
feat (web-api / types): Add support for assistant.threads.* API (#2033)
Browse files Browse the repository at this point in the history
  • Loading branch information
misscoded authored Sep 17, 2024
1 parent 072abd1 commit 571bc3a
Show file tree
Hide file tree
Showing 313 changed files with 1,244 additions and 1,243 deletions.
29 changes: 29 additions & 0 deletions packages/types/src/events/assistant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface AssistantThreadStartedEvent {
type: 'assistant_thread_started';
assistant_thread: {
user_id: string;
context: {
channel_id?: string;
team_id?: string;
enterprise_id?: string | null;
};
channel_id: string;
thread_ts: string;
};
event_ts: string;
}

export interface AssistantThreadContextChangedEvent {
type: 'assistant_thread_context_changed';
assistant_thread: {
user_id: string;
context: {
channel_id?: string;
team_id?: string;
enterprise_id?: string | null;
};
channel_id: string;
thread_ts: string;
};
event_ts: string;
}
4 changes: 4 additions & 0 deletions packages/types/src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
AppUninstalledEvent,
AppUninstalledTeamEvent,
} from './app';
import type { AssistantThreadContextChangedEvent, AssistantThreadStartedEvent } from './assistant';
import type { CallRejectedEvent } from './call';
import type {
ChannelArchiveEvent,
Expand Down Expand Up @@ -86,6 +87,7 @@ import type { TokensRevokedEvent } from './token';
import type { UserChangeEvent, UserHuddleChangedEvent, UserProfileChangedEvent, UserStatusChangedEvent } from './user';

export * from './app';
export * from './assistant';
export * from './call';
export * from './channel';
export * from './dnd';
Expand Down Expand Up @@ -125,6 +127,8 @@ export type SlackEvent =
| AppRequestedEvent
| AppUninstalledTeamEvent
| AppUninstalledEvent
| AssistantThreadContextChangedEvent
| AssistantThreadStartedEvent
| CallRejectedEvent
| ChannelArchiveEvent
| ChannelCreatedEvent
Expand Down
16 changes: 2 additions & 14 deletions packages/web-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@
"description": "Official library for using the Slack Platform's Web API",
"author": "Slack Technologies, LLC",
"license": "MIT",
"keywords": [
"slack",
"web-api",
"bot",
"client",
"http",
"api",
"proxy",
"rate-limiting",
"pagination"
],
"keywords": ["slack", "web-api", "bot", "client", "http", "api", "proxy", "rate-limiting", "pagination"],
"main": "dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**/*"
],
"files": ["dist/**/*"],
"engines": {
"node": ">= 18",
"npm": ">= 8.6.0"
Expand Down
35 changes: 35 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ import type {
AppsManifestUpdateArguments,
AppsManifestValidateArguments,
AppsUninstallArguments,
AssistantThreadsSetStatusArguments,
AssistantThreadsSetSuggestedPromptsArguments,
AssistantThreadsSetTitleArguments,
AuthRevokeArguments,
AuthTeamsListArguments,
AuthTestArguments,
Expand Down Expand Up @@ -357,6 +360,9 @@ import type {
AppsManifestUpdateResponse,
AppsManifestValidateResponse,
AppsUninstallResponse,
AssistantThreadsSetStatusResponse,
AssistantThreadsSetSuggestedPromptsResponse,
AssistantThreadsSetTitleResponse,
AuthRevokeResponse,
AuthTeamsListResponse,
AuthTestResponse,
Expand Down Expand Up @@ -1332,6 +1338,35 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
test: bindApiCallWithOptionalArgument<APITestArguments, ApiTestResponse>(this, 'api.test'),
};

public readonly assistant = {
threads: {
/**
* @description Set loading status to indicate that the app is building a response.
* @see {@link https://api.slack.com/methods/assistant.threads.setStatus `assistant.threads.setStatus` API reference}.
*/
setStatus: bindApiCall<AssistantThreadsSetStatusArguments, AssistantThreadsSetStatusResponse>(
this,
'assistant.threads.setStatus',
),
/**
* @description Set suggested prompts for the user. Can suggest up to four prompts.
* @see {@link https://api.slack.com/methods/assistant.threads.setSuggestedPrompts `assistant.threads.setSuggestedPrompts` API reference}.
*/
setSuggestedPrompts: bindApiCall<
AssistantThreadsSetSuggestedPromptsArguments,
AssistantThreadsSetSuggestedPromptsResponse
>(this, 'assistant.threads.setSuggestedPrompts'),
/**
* @description Set the title of the thread. This is shown when a user views the app's chat history.
* @see {@link https://api.slack.com/methods/assistant.threads.setTitle `assistant.threads.setTitle` API reference}.
*/
setTitle: bindApiCall<AssistantThreadsSetTitleArguments, AssistantThreadsSetTitleResponse>(
this,
'assistant.threads.setTitle',
),
},
};

public readonly apps = {
connections: {
/**
Expand Down
40 changes: 40 additions & 0 deletions packages/web-api/src/types/request/assistant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { TokenOverridable } from './common';

// https://api.slack.com/methods/assistant.threads.setStatus
export interface AssistantThreadsSetStatusArguments extends TokenOverridable {
/** @description Channel ID containing the assistant thread. */
channel_id: string;
/** @description Status of the assistant (e.g. 'is thinking...') */
status: string;
/** @description Message timestamp of the thread. */
thread_ts: string;
}

// https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
export interface AssistantThreadsSetSuggestedPromptsArguments extends TokenOverridable {
/** @description Channel ID containing the assistant thread. */
channel_id: string;
/** @description Prompt suggestions that appear when opening assistant thread. */
prompts: [AssistantPrompt, ...AssistantPrompt[]];
/** @description Message timestamp of the thread. */
thread_ts: string;
/** @description Title for the prompts. */
title?: string;
}

interface AssistantPrompt {
/** @description Title of the prompt. */
title: string;
/** @description Message of the prompt. */
message: string;
}

// https://api.slack.com/methods/assistant.threads.setTitle
export interface AssistantThreadsSetTitleArguments extends TokenOverridable {
/** @description Channel ID containing the assistant thread. */
channel_id: string;
/** @description Message timestamp of the thread. */
thread_ts: string;
/** @description Title of the thread. */
title: string;
}
5 changes: 5 additions & 0 deletions packages/web-api/src/types/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export type {
AppsUninstallArguments,
} from './apps';
export type { APITestArguments } from './api';
export type {
AssistantThreadsSetStatusArguments,
AssistantThreadsSetSuggestedPromptsArguments,
AssistantThreadsSetTitleArguments,
} from './assistant';
export type { AdminAnalyticsGetFileArguments } from './admin/analytics';
export type {
AdminAppsActivitiesListArguments,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down Expand Up @@ -35,6 +34,7 @@ export interface App {
icons?: Icons;
id?: string;
is_app_directory_approved?: boolean;
is_granular_bot_app?: boolean;
is_internal?: boolean;
name?: string;
privacy_policy_url?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down Expand Up @@ -40,6 +39,7 @@ export interface App {
icons?: Icons;
id?: string;
is_app_directory_approved?: boolean;
is_granular_bot_app?: boolean;
is_internal?: boolean;
name?: string;
privacy_policy_url?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down Expand Up @@ -41,6 +40,7 @@ export interface App {
icons?: Icons;
id?: string;
is_app_directory_approved?: boolean;
is_granular_bot_app?: boolean;
is_internal?: boolean;
name?: string;
privacy_policy_url?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand Down
Loading

0 comments on commit 571bc3a

Please sign in to comment.