UNPKG

bottender

Version:

A framework for building conversational user interfaces.

72 lines 2.67 kB
/// <reference types="node" /> import { EventEmitter } from 'events'; import { JsonObject } from 'type-fest'; import { SlackOAuthClient } from 'messaging-api-slack'; import Session from '../session/Session'; import { Connector } from '../bot/Connector'; import { RequestContext } from '../types'; import SlackContext from './SlackContext'; import SlackEvent from './SlackEvent'; import { SlackRawEvent, SlackRequestBody } from './SlackTypes'; declare type CommonConnectorOptions = { skipLegacyProfile?: boolean; verificationToken?: string; signingSecret?: string; includeBotMessages?: boolean; }; declare type ConnectorOptionsWithoutClient = { accessToken: string; origin?: string; } & CommonConnectorOptions; declare type ConnectorOptionsWithClient = { client: SlackOAuthClient; } & CommonConnectorOptions; export declare type SlackConnectorOptions = ConnectorOptionsWithoutClient | ConnectorOptionsWithClient; export default class SlackConnector implements Connector<SlackRequestBody, SlackOAuthClient> { _client: SlackOAuthClient; _verificationToken: string; _signingSecret: string; _skipLegacyProfile: boolean; _includeBotMessages: boolean; constructor(options: SlackConnectorOptions); _getRawEventFromRequest(body: SlackRequestBody): SlackRawEvent; _isBotEventRequest(body: SlackRequestBody): boolean; get platform(): 'slack'; get client(): SlackOAuthClient; _getChannelId(rawEvent: any): string | null; _getUserId(rawEvent: SlackRawEvent): string | null; getUniqueSessionKey(body: SlackRequestBody): string | null; updateSession(session: Session, body: SlackRequestBody): Promise<void>; mapRequestToEvents(body: SlackRequestBody): SlackEvent[]; createContext(params: { event: SlackEvent; session: Session | null; initialState?: JsonObject | null; requestContext?: RequestContext; emitter?: EventEmitter | null; }): SlackContext; verifySignature(tokenFromBody: string): boolean; verifySignatureBySigningSecret({ rawBody, signature, timestamp, }: { rawBody: string; signature: string; timestamp: string; }): boolean; preprocess({ method, headers, body, rawBody, }: { method: string; headers: Record<string, string>; query: Record<string, string>; rawBody: string; body: Record<string, any>; }): { shouldNext: boolean; response?: undefined; } | { shouldNext: boolean; response: { status: number; body: any; }; }; } export {}; //# sourceMappingURL=SlackConnector.d.ts.map