Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (web-api / types): Add support for assistant.threads.* API #2033

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filmaj These are used in the implementation for Bolt, but figured they should go in now. Let me know if you prefer these to be separate!

type: "assistant_thread_started";
assistant_thread: {
user_id: string;
context: {
channel_id: string;
team_id: string;
enterprise_id: string;
misscoded marked this conversation as resolved.
Show resolved Hide resolved
};
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;
misscoded marked this conversation as resolved.
Show resolved Hide resolved
};
channel_id: string;
thread_ts: string;
};
event_ts: string;
}
7 changes: 7 additions & 0 deletions packages/types/src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ 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 +90,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 +130,8 @@ export type SlackEvent =
| AppRequestedEvent
| AppUninstalledTeamEvent
| AppUninstalledEvent
| AssistantThreadContextChangedEvent
| AssistantThreadStartedEvent
| CallRejectedEvent
| ChannelArchiveEvent
| ChannelCreatedEvent
Expand Down
26 changes: 26 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ import type {
AdminWorkflowsPermissionsLookupArguments,
AdminWorkflowsSearchArguments,
AdminWorkflowsUnpublishArguments,
AssistantThreadsSetStatusArguments,
AssistantThreadsSetSuggestedPromptsArguments,
AssistantThreadsSetTitleArguments,
AppsConnectionsOpenArguments,
AppsEventAuthorizationsListArguments,
AppsManifestCreateArguments,
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,26 @@ 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
26 changes: 26 additions & 0 deletions packages/web-api/src/types/request/assistant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { TokenOverridable } from './common';

// https://api.slack.com/methods/assistant.threads.setStatus
export interface AssistantThreadsSetStatusArguments extends TokenOverridable {
channel_id: string;
status: string;
thread_ts: string;
}

// https://api.slack.com/methods/assistant.threads.setSuggestedPrompts
export interface AssistantThreadsSetSuggestedPromptsArguments extends TokenOverridable {
channel_id: string;
prompts: {
misscoded marked this conversation as resolved.
Show resolved Hide resolved
title: string;
message: string;
}[];
thread_ts: string;
title?: string;
}

// https://api.slack.com/methods/assistant.threads.setTitle
export interface AssistantThreadsSetTitleArguments extends TokenOverridable {
channel_id: string;
thread_ts: string;
title: string;
}
1 change: 1 addition & 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,7 @@ 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
102 changes: 51 additions & 51 deletions packages/web-api/src/types/response/AdminAppsActivitiesListResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand All @@ -8,80 +7,81 @@
// //
/////////////////////////////////////////////////////////////////////////////////////////

import type { WebAPICallResult } from '../../WebClient';
import { WebAPICallResult } from '../../WebClient';
misscoded marked this conversation as resolved.
Show resolved Hide resolved
export type AdminAppsActivitiesListResponse = WebAPICallResult & {
activities?: Activity[];
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
activities?: Activity[];
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
response_metadata?: ResponseMetadata;
};

export interface Activity {
app_id?: string;
component_id?: string;
app_id?: string;
component_id?: string;
component_type?: string;
created?: number;
enterprise_id?: string;
event_type?: string;
level?: string;
payload?: Payload;
source?: string;
team_id?: string;
trace_id?: string;
created?: number;
enterprise_id?: string;
event_type?: string;
level?: string;
payload?: Payload;
source?: string;
team_id?: string;
trace_id?: string;
}

export interface Payload {
action?: string;
actor?: string;
billing_reason?: string[];
bot_user_id?: string;
bundle_size_kb?: number;
channel_id?: string;
current_step?: number;
datastore_name?: string;
details?: string;
error?: string;
exec_outcome?: string;
action?: string;
actor?: string;
billing_reason?: string[];
bot_user_id?: string;
bundle_size_kb?: number;
channel_id?: string;
current_step?: number;
datastore_name?: string;
details?: string;
error?: string;
exec_outcome?: string;
function_execution_id?: string;
function_id?: string;
function_name?: string;
function_type?: string;
inputs?: Inputs;
is_billing_excluded?: boolean;
log?: string;
request_type?: string;
team_id?: string;
total_steps?: number;
trigger?: Trigger;
type?: string;
user_id?: string;
workflow_name?: string;
function_id?: string;
function_name?: string;
function_type?: string;
inputs?: Inputs;
is_billing_excluded?: boolean;
log?: string;
request_type?: string;
team_id?: string;
total_steps?: number;
trigger?: Trigger;
type?: string;
user_id?: string;
workflow_name?: string;
}

export type Inputs = {};
export interface Inputs {
}

export interface Trigger {
config?: Config;
id?: string;
config?: Config;
id?: string;
trip_information?: TripInformation;
type?: string;
type?: string;
}

export interface Config {
description?: string;
event_type?: string;
name?: string;
schema?: Inputs;
event_type?: string;
name?: string;
schema?: Inputs;
}

export interface TripInformation {
channel_id?: string;
list_id?: string;
list_id?: string;
message_ts?: string;
reaction?: string;
user_id?: string;
reaction?: string;
user_id?: string;
}

export interface ResponseMetadata {
Expand Down
11 changes: 5 additions & 6 deletions packages/web-api/src/types/response/AdminAppsApproveResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/////////////////////////////////////////////////////////////////////////////////////////
// //
// !!! DO NOT EDIT THIS FILE !!! //
Expand All @@ -8,11 +7,11 @@
// //
/////////////////////////////////////////////////////////////////////////////////////////

import type { WebAPICallResult } from '../../WebClient';
import { WebAPICallResult } from '../../WebClient';
export type AdminAppsApproveResponse = WebAPICallResult & {
error?: string;
needed?: string;
ok?: boolean;
error?: string;
needed?: string;
ok?: boolean;
provided?: string;
warning?: string;
warning?: string;
};
Loading