From e69a76d30c377c460d2340c0a4099181cbc4748a Mon Sep 17 00:00:00 2001 From: Alissa Renz Date: Fri, 27 Sep 2024 20:07:52 +0000 Subject: [PATCH] feat (web-api): Add support for assistant.* API (#2042) --- packages/web-api/src/methods.ts | 74 +++++++++++++++++++ .../AssistantThreadsSetStatusResponse.ts | 18 +++++ ...stantThreadsSetSuggestedPromptsResponse.ts | 18 +++++ .../AssistantThreadsSetTitleResponse.ts | 18 +++++ packages/web-api/src/response/index.ts | 3 + 5 files changed, 131 insertions(+) create mode 100644 packages/web-api/src/response/AssistantThreadsSetStatusResponse.ts create mode 100644 packages/web-api/src/response/AssistantThreadsSetSuggestedPromptsResponse.ts create mode 100644 packages/web-api/src/response/AssistantThreadsSetTitleResponse.ts diff --git a/packages/web-api/src/methods.ts b/packages/web-api/src/methods.ts index 1ac6b5844..fcc4f418c 100644 --- a/packages/web-api/src/methods.ts +++ b/packages/web-api/src/methods.ts @@ -90,6 +90,9 @@ import { AppsManifestUpdateResponse, AppsManifestValidateResponse, AppsUninstallResponse, + AssistantThreadsSetStatusResponse, + AssistantThreadsSetSuggestedPromptsResponse, + AssistantThreadsSetTitleResponse, AuthRevokeResponse, AuthTeamsListResponse, AuthTestResponse, @@ -553,6 +556,35 @@ export abstract class Methods extends EventEmitter { uninstall: bindApiCall(this, 'apps.uninstall'), }; + 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( + 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( + this, + 'assistant.threads.setTitle', + ), + }, + }; + public readonly auth = { revoke: bindApiCall(this, 'auth.revoke'), teams: { @@ -1456,6 +1488,48 @@ export interface AppsUninstallArguments extends WebAPICallOptions { client_secret: string; } +/* + * `assistant.*` + */ +// https://api.slack.com/methods/assistant.threads.setStatus +export interface AssistantThreadsSetStatusArguments extends WebAPICallOptions, 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 WebAPICallOptions, 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 WebAPICallOptions, 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; +} + /* * `auth.*` */ diff --git a/packages/web-api/src/response/AssistantThreadsSetStatusResponse.ts b/packages/web-api/src/response/AssistantThreadsSetStatusResponse.ts new file mode 100644 index 000000000..50ecc38b3 --- /dev/null +++ b/packages/web-api/src/response/AssistantThreadsSetStatusResponse.ts @@ -0,0 +1,18 @@ +/* eslint-disable */ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import { WebAPICallResult } from '../WebClient'; +export type AssistantThreadsSetStatusResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/response/AssistantThreadsSetSuggestedPromptsResponse.ts b/packages/web-api/src/response/AssistantThreadsSetSuggestedPromptsResponse.ts new file mode 100644 index 000000000..6f5b46ea2 --- /dev/null +++ b/packages/web-api/src/response/AssistantThreadsSetSuggestedPromptsResponse.ts @@ -0,0 +1,18 @@ +/* eslint-disable */ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import { WebAPICallResult } from '../WebClient'; +export type AssistantThreadsSetSuggestedPromptsResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/response/AssistantThreadsSetTitleResponse.ts b/packages/web-api/src/response/AssistantThreadsSetTitleResponse.ts new file mode 100644 index 000000000..1e4125ef8 --- /dev/null +++ b/packages/web-api/src/response/AssistantThreadsSetTitleResponse.ts @@ -0,0 +1,18 @@ +/* eslint-disable */ +///////////////////////////////////////////////////////////////////////////////////////// +// // +// !!! DO NOT EDIT THIS FILE !!! // +// // +// This file is auto-generated by scripts/generate-web-api-types.sh in the repository. // +// Please refer to the script code to learn how to update the source data. // +// // +///////////////////////////////////////////////////////////////////////////////////////// + +import { WebAPICallResult } from '../WebClient'; +export type AssistantThreadsSetTitleResponse = WebAPICallResult & { + error?: string; + needed?: string; + ok?: boolean; + provided?: string; + warning?: string; +}; diff --git a/packages/web-api/src/response/index.ts b/packages/web-api/src/response/index.ts index 5035d08a9..6f70c54f6 100644 --- a/packages/web-api/src/response/index.ts +++ b/packages/web-api/src/response/index.ts @@ -111,6 +111,9 @@ export { AppsPermissionsScopesListResponse } from './AppsPermissionsScopesListRe export { AppsPermissionsUsersListResponse } from './AppsPermissionsUsersListResponse'; export { AppsPermissionsUsersRequestResponse } from './AppsPermissionsUsersRequestResponse'; export { AppsUninstallResponse } from './AppsUninstallResponse'; +export { AssistantThreadsSetStatusResponse } from './AssistantThreadsSetStatusResponse'; +export { AssistantThreadsSetSuggestedPromptsResponse } from './AssistantThreadsSetSuggestedPromptsResponse'; +export { AssistantThreadsSetTitleResponse } from './AssistantThreadsSetTitleResponse'; export { AuthRevokeResponse } from './AuthRevokeResponse'; export { AuthTeamsListResponse } from './AuthTeamsListResponse'; export { AuthTestResponse } from './AuthTestResponse';