Skip to content

Commit 571bc3a

Browse files
authored
feat (web-api / types): Add support for assistant.threads.* API (#2033)
1 parent 072abd1 commit 571bc3a

File tree

313 files changed

+1244
-1243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+1244
-1243
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export interface AssistantThreadStartedEvent {
2+
type: 'assistant_thread_started';
3+
assistant_thread: {
4+
user_id: string;
5+
context: {
6+
channel_id?: string;
7+
team_id?: string;
8+
enterprise_id?: string | null;
9+
};
10+
channel_id: string;
11+
thread_ts: string;
12+
};
13+
event_ts: string;
14+
}
15+
16+
export interface AssistantThreadContextChangedEvent {
17+
type: 'assistant_thread_context_changed';
18+
assistant_thread: {
19+
user_id: string;
20+
context: {
21+
channel_id?: string;
22+
team_id?: string;
23+
enterprise_id?: string | null;
24+
};
25+
channel_id: string;
26+
thread_ts: string;
27+
};
28+
event_ts: string;
29+
}

packages/types/src/events/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {
88
AppUninstalledEvent,
99
AppUninstalledTeamEvent,
1010
} from './app';
11+
import type { AssistantThreadContextChangedEvent, AssistantThreadStartedEvent } from './assistant';
1112
import type { CallRejectedEvent } from './call';
1213
import type {
1314
ChannelArchiveEvent,
@@ -86,6 +87,7 @@ import type { TokensRevokedEvent } from './token';
8687
import type { UserChangeEvent, UserHuddleChangedEvent, UserProfileChangedEvent, UserStatusChangedEvent } from './user';
8788

8889
export * from './app';
90+
export * from './assistant';
8991
export * from './call';
9092
export * from './channel';
9193
export * from './dnd';
@@ -125,6 +127,8 @@ export type SlackEvent =
125127
| AppRequestedEvent
126128
| AppUninstalledTeamEvent
127129
| AppUninstalledEvent
130+
| AssistantThreadContextChangedEvent
131+
| AssistantThreadStartedEvent
128132
| CallRejectedEvent
129133
| ChannelArchiveEvent
130134
| ChannelCreatedEvent

packages/web-api/package.json

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,10 @@
44
"description": "Official library for using the Slack Platform's Web API",
55
"author": "Slack Technologies, LLC",
66
"license": "MIT",
7-
"keywords": [
8-
"slack",
9-
"web-api",
10-
"bot",
11-
"client",
12-
"http",
13-
"api",
14-
"proxy",
15-
"rate-limiting",
16-
"pagination"
17-
],
7+
"keywords": ["slack", "web-api", "bot", "client", "http", "api", "proxy", "rate-limiting", "pagination"],
188
"main": "dist/index.js",
199
"types": "./dist/index.d.ts",
20-
"files": [
21-
"dist/**/*"
22-
],
10+
"files": ["dist/**/*"],
2311
"engines": {
2412
"node": ">= 18",
2513
"npm": ">= 8.6.0"

packages/web-api/src/methods.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ import type {
108108
AppsManifestUpdateArguments,
109109
AppsManifestValidateArguments,
110110
AppsUninstallArguments,
111+
AssistantThreadsSetStatusArguments,
112+
AssistantThreadsSetSuggestedPromptsArguments,
113+
AssistantThreadsSetTitleArguments,
111114
AuthRevokeArguments,
112115
AuthTeamsListArguments,
113116
AuthTestArguments,
@@ -357,6 +360,9 @@ import type {
357360
AppsManifestUpdateResponse,
358361
AppsManifestValidateResponse,
359362
AppsUninstallResponse,
363+
AssistantThreadsSetStatusResponse,
364+
AssistantThreadsSetSuggestedPromptsResponse,
365+
AssistantThreadsSetTitleResponse,
360366
AuthRevokeResponse,
361367
AuthTeamsListResponse,
362368
AuthTestResponse,
@@ -1332,6 +1338,35 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
13321338
test: bindApiCallWithOptionalArgument<APITestArguments, ApiTestResponse>(this, 'api.test'),
13331339
};
13341340

1341+
public readonly assistant = {
1342+
threads: {
1343+
/**
1344+
* @description Set loading status to indicate that the app is building a response.
1345+
* @see {@link https://api.slack.com/methods/assistant.threads.setStatus `assistant.threads.setStatus` API reference}.
1346+
*/
1347+
setStatus: bindApiCall<AssistantThreadsSetStatusArguments, AssistantThreadsSetStatusResponse>(
1348+
this,
1349+
'assistant.threads.setStatus',
1350+
),
1351+
/**
1352+
* @description Set suggested prompts for the user. Can suggest up to four prompts.
1353+
* @see {@link https://api.slack.com/methods/assistant.threads.setSuggestedPrompts `assistant.threads.setSuggestedPrompts` API reference}.
1354+
*/
1355+
setSuggestedPrompts: bindApiCall<
1356+
AssistantThreadsSetSuggestedPromptsArguments,
1357+
AssistantThreadsSetSuggestedPromptsResponse
1358+
>(this, 'assistant.threads.setSuggestedPrompts'),
1359+
/**
1360+
* @description Set the title of the thread. This is shown when a user views the app's chat history.
1361+
* @see {@link https://api.slack.com/methods/assistant.threads.setTitle `assistant.threads.setTitle` API reference}.
1362+
*/
1363+
setTitle: bindApiCall<AssistantThreadsSetTitleArguments, AssistantThreadsSetTitleResponse>(
1364+
this,
1365+
'assistant.threads.setTitle',
1366+
),
1367+
},
1368+
};
1369+
13351370
public readonly apps = {
13361371
connections: {
13371372
/**
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { TokenOverridable } from './common';
2+
3+
// https://api.slack.com/methods/assistant.threads.setStatus
4+
export interface AssistantThreadsSetStatusArguments extends TokenOverridable {
5+
/** @description Channel ID containing the assistant thread. */
6+
channel_id: string;
7+
/** @description Status of the assistant (e.g. 'is thinking...') */
8+
status: string;
9+
/** @description Message timestamp of the thread. */
10+
thread_ts: string;
11+
}
12+
13+
// https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
14+
export interface AssistantThreadsSetSuggestedPromptsArguments extends TokenOverridable {
15+
/** @description Channel ID containing the assistant thread. */
16+
channel_id: string;
17+
/** @description Prompt suggestions that appear when opening assistant thread. */
18+
prompts: [AssistantPrompt, ...AssistantPrompt[]];
19+
/** @description Message timestamp of the thread. */
20+
thread_ts: string;
21+
/** @description Title for the prompts. */
22+
title?: string;
23+
}
24+
25+
interface AssistantPrompt {
26+
/** @description Title of the prompt. */
27+
title: string;
28+
/** @description Message of the prompt. */
29+
message: string;
30+
}
31+
32+
// https://api.slack.com/methods/assistant.threads.setTitle
33+
export interface AssistantThreadsSetTitleArguments extends TokenOverridable {
34+
/** @description Channel ID containing the assistant thread. */
35+
channel_id: string;
36+
/** @description Message timestamp of the thread. */
37+
thread_ts: string;
38+
/** @description Title of the thread. */
39+
title: string;
40+
}

packages/web-api/src/types/request/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ export type {
162162
AppsUninstallArguments,
163163
} from './apps';
164164
export type { APITestArguments } from './api';
165+
export type {
166+
AssistantThreadsSetStatusArguments,
167+
AssistantThreadsSetSuggestedPromptsArguments,
168+
AssistantThreadsSetTitleArguments,
169+
} from './assistant';
165170
export type { AdminAnalyticsGetFileArguments } from './admin/analytics';
166171
export type {
167172
AdminAppsActivitiesListArguments,

packages/web-api/src/types/response/AdminAppsActivitiesListResponse.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
/////////////////////////////////////////////////////////////////////////////////////////
32
// //
43
// !!! DO NOT EDIT THIS FILE !!! //

packages/web-api/src/types/response/AdminAppsApproveResponse.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
/////////////////////////////////////////////////////////////////////////////////////////
32
// //
43
// !!! DO NOT EDIT THIS FILE !!! //

packages/web-api/src/types/response/AdminAppsApprovedListResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
/////////////////////////////////////////////////////////////////////////////////////////
32
// //
43
// !!! DO NOT EDIT THIS FILE !!! //
@@ -35,6 +34,7 @@ export interface App {
3534
icons?: Icons;
3635
id?: string;
3736
is_app_directory_approved?: boolean;
37+
is_granular_bot_app?: boolean;
3838
is_internal?: boolean;
3939
name?: string;
4040
privacy_policy_url?: string;

packages/web-api/src/types/response/AdminAppsClearResolutionResponse.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable */
21
/////////////////////////////////////////////////////////////////////////////////////////
32
// //
43
// !!! DO NOT EDIT THIS FILE !!! //

0 commit comments

Comments
 (0)