import { SlackAppEnv } from "../app-env"; import { AssistantEventLazyHandler, AssistantUserMessageEventRequest, EventLazyHandler, AssistantBotMessageEventRequest } from "../handler/handler"; import { AssistantThreadContextChangedEvent, AssistantThreadStartedEvent } from "../request/payload/event"; import { AssistantThreadContextStore } from "./thread-context-store"; /** * Handler type for the `assistant_thread_started` event. * This handler is invoked when a user opens a new assistant thread in a DM with the app. * @template E - The Slack app environment type */ export type AssistantThreadStartedHandler = AssistantEventLazyHandler; /** * Handler type for the `assistant_thread_context_changed` event. * This handler is invoked when the context of an assistant thread is updated. * @template E - The Slack app environment type */ export type AssistantThreadContextChangedHandler = AssistantEventLazyHandler; /** * Handler type for user messages sent to the assistant thread. * This handler is invoked when a user sends a message (including file shares) in the assistant thread. * @template E - The Slack app environment type */ export type AssistantUserMessageHandler = (req: AssistantUserMessageEventRequest) => Promise; /** * Handler type for bot messages in the assistant thread. * This handler is invoked when the bot itself sends a message in the assistant thread. * @template E - The Slack app environment type */ export type AssistantBotMessageHandler = (req: AssistantBotMessageEventRequest) => Promise; /** * Configuration options for the Assistant class. * @template E - The Slack app environment type */ export interface AssistantOptions { threadContextStore?: AssistantThreadContextStore; threadStarted?: AssistantThreadStartedHandler; threadContextChanged?: AssistantThreadContextChangedHandler; userMessage?: AssistantUserMessageHandler; botMessage?: AssistantBotMessageHandler; } /** * A class that manages Slack AI Assistant functionality. * * The Assistant class provides a simplified interface for building AI-powered assistants * that respond to user messages in direct message threads. It handles the lifecycle events * of assistant threads including thread creation, context changes, and message handling. * * @template E - The Slack app environment type * @example * ```typescript * const assistant = new Assistant({ * threadStarted: async ({ context, say }) => { * await say({ text: "Hello! How can I help you?" }); * }, * userMessage: async ({ context, say, payload }) => { * await say({ text: `You said: ${payload.text}` }); * }, * }); * app.assistant(assistant); * ``` */ export declare class Assistant { /** Optional store for persisting assistant thread context data */ threadContextStore?: AssistantThreadContextStore; /** Internal handler for the assistant_thread_started event */ threadStartedHandler: EventLazyHandler<"assistant_thread_started", E>; /** Internal handler for the assistant_thread_context_changed event */ threadContextChangedHandler: EventLazyHandler<"assistant_thread_context_changed", E>; /** Internal handler for user messages in the assistant thread */ userMessageHandler: EventLazyHandler<"message", E>; /** Internal handler for bot messages in the assistant thread */ botMessageHandler: EventLazyHandler<"message", E>; /** * Creates a new Assistant instance with the specified options. * @param options - Configuration options for the assistant including event handlers */ constructor(options?: AssistantOptions); /** * Registers a handler for the `assistant_thread_started` event. * This event is triggered when a user opens a new assistant thread (DM) with the app. * @param handler - The handler function to execute when a new thread is started */ threadStarted(handler: AssistantThreadStartedHandler): void; /** * Registers a handler for the `assistant_thread_context_changed` event. * This event is triggered when the context of an assistant thread is updated, * typically when metadata about the conversation changes. * @param handler - The handler function to execute when thread context changes */ threadContextChanged(handler: AssistantThreadContextChangedHandler): void; /** * Registers a handler for user messages sent in the assistant thread. * This handler is invoked when a user sends a regular message or shares a file * in the assistant thread. * @param handler - The handler function to execute when a user sends a message */ userMessage(handler: AssistantUserMessageHandler): void; /** * Registers a handler for bot messages in the assistant thread. * This handler is invoked when the assistant bot itself sends a message, * which can be useful for tracking or processing bot responses. * @param handler - The handler function to execute when the bot sends a message */ botMessage(handler: AssistantBotMessageHandler): void; } //# sourceMappingURL=assistant.d.ts.map