/** * Slack Integration * * Provides Slack bot adapters for building AI-powered Slack bots. */ export interface SlackConfig { /** Slack Bot Token (xoxb-...) */ botToken: string; /** Slack App Token for Socket Mode (xapp-...) */ appToken?: string; /** Slack Signing Secret for webhook verification */ signingSecret?: string; /** Enable Socket Mode (default: false, uses webhooks) */ socketMode?: boolean; } export interface SlackMessage { /** Channel ID */ channel: string; /** User ID */ user: string; /** Message text */ text: string; /** Thread timestamp (for replies) */ threadTs?: string; /** Message timestamp */ ts: string; /** Bot ID (if from a bot) */ botId?: string; } export interface SlackResponse { /** Response text */ text: string; /** Blocks for rich formatting */ blocks?: any[]; /** Thread timestamp (to reply in thread) */ threadTs?: string; /** Unfurl links */ unfurlLinks?: boolean; /** Unfurl media */ unfurlMedia?: boolean; } export interface SlackEventHandler { /** Handle a message event */ onMessage: (message: SlackMessage) => Promise; /** Handle an app mention event */ onAppMention?: (message: SlackMessage) => Promise; /** Handle a reaction added event */ onReactionAdded?: (event: any) => Promise; } /** * Create a Slack bot adapter. * * @example Basic usage * ```typescript * import { createSlackBot } from 'praisonai/integrations/slack'; * import { Agent } from 'praisonai'; * * const agent = new Agent({ instructions: 'You are a helpful Slack bot' }); * * const bot = createSlackBot({ * botToken: process.env.SLACK_BOT_TOKEN!, * signingSecret: process.env.SLACK_SIGNING_SECRET! * }); * * bot.onMessage(async (message) => { * const response = await agent.chat(message.text); * return { text: response, threadTs: message.ts }; * }); * * // Start webhook server * bot.listen(3000); * ``` * * @example With Socket Mode * ```typescript * const bot = createSlackBot({ * botToken: process.env.SLACK_BOT_TOKEN!, * appToken: process.env.SLACK_APP_TOKEN!, * socketMode: true * }); * * bot.onMessage(async (message) => { * return { text: 'Hello!' }; * }); * * await bot.start(); * ``` */ export declare function createSlackBot(config: SlackConfig): SlackBot; export declare class SlackBot { private config; private messageHandler?; private mentionHandler?; private reactionHandler?; private boltApp; constructor(config: SlackConfig); /** * Set the message handler. */ onMessage(handler: (message: SlackMessage) => Promise): this; /** * Set the app mention handler. */ onAppMention(handler: (message: SlackMessage) => Promise): this; /** * Set the reaction handler. */ onReactionAdded(handler: (event: any) => Promise): this; /** * Initialize the Bolt app (lazy load). */ private initBolt; /** * Start the bot (Socket Mode). */ start(): Promise; /** * Start webhook server. */ listen(port?: number): Promise; /** * Stop the bot. */ stop(): Promise; /** * Send a message to a channel. */ sendMessage(channel: string, text: string, options?: Partial): Promise; /** * Get an Express middleware for webhook handling. */ getExpressMiddleware(): any; } /** * Verify Slack request signature. */ export declare function verifySlackSignature(signingSecret: string, signature: string, timestamp: string, body: string): boolean; /** * Parse Slack message text to extract mentions and links. */ export declare function parseSlackMessage(text: string): { mentions: string[]; links: string[]; cleanText: string; };