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): Add support for assistant.* API #2042

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
74 changes: 74 additions & 0 deletions packages/web-api/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ import {
AppsConnectionsOpenResponse,
AppsEventAuthorizationsListResponse,
AppsUninstallResponse,
AssistantThreadsSetStatusResponse,
AssistantThreadsSetSuggestedPromptsResponse,
AssistantThreadsSetTitleResponse,
AuthRevokeResponse,
AuthTeamsListResponse,
AuthTestResponse,
Expand Down Expand Up @@ -538,6 +541,35 @@ export abstract class Methods extends EventEmitter<WebClientEvent> {
uninstall: bindApiCall<AppsUninstallArguments, AppsUninstallResponse>(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}.
*/
Comment on lines +546 to +549
Copy link
Member

Choose a reason for hiding this comment

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

These are wonderful docs to have 🙏 ✨

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 auth = {
revoke: bindApiCall<AuthRevokeArguments, AuthRevokeResponse>(this, 'auth.revoke'),
teams: {
Expand Down Expand Up @@ -1404,6 +1436,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.*`
*/
Expand Down
18 changes: 18 additions & 0 deletions packages/web-api/src/response/AssistantThreadsSetStatusResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -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;
};
18 changes: 18 additions & 0 deletions packages/web-api/src/response/AssistantThreadsSetTitleResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
};
3 changes: 3 additions & 0 deletions packages/web-api/src/response/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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';
Expand Down
Loading