UNPKG

@botonic/core

Version:

Runtime and APIs for Botonic bots: actions, context, messaging, and integration hooks used by the **current** framework line.

61 lines (60 loc) 2.94 kB
import type { UserExtraData } from '@botonic/shared'; import type { HubtypeApiService } from '../../services/hubtype-api-service'; import { BotServerMessage } from '../bot-server-message'; import { BotonicContextInput } from './botonic-context-input'; import type { BotonicContextSession, BotonicSessionUpdate } from './botonic-context-session'; import type { BotonicContextSecrets, BotonicContextSettings } from './botonic-context-settings'; import type { ActionResponse, ResolvedPlugins, SendMessagesOptions, TypingMode } from './types'; /** Result of creating input/session from raw lambda request (used by BotonicContextFactory). */ export interface BotonicContextType<TExtraData extends UserExtraData = UserExtraData> { input: BotonicContextInput; session: BotonicContextSession<TExtraData>; settings: BotonicContextSettings; secrets: BotonicContextSecrets; } /** Options for handoff to human agent. */ export interface HandoffOptions { queue?: string; on_finish?: string; agent_email?: string; agent_id?: string; case_info?: string; note?: string; shadowing?: boolean; auto_idle_message?: string; force_assign_if_not_available?: boolean; auto_assign_on_waiting?: boolean; case_extra_data?: Record<string, unknown>; bot_event?: { format_version: number; flow_id: string; flow_name: string; flow_node_id: string; flow_node_content_id: string; }; subscribe_helpdesk_events?: string[]; } /** Full execution context with input, session, and hubtype service methods. */ export declare class BotonicContext<TPlugins extends ResolvedPlugins = ResolvedPlugins, TExtraData extends UserExtraData = UserExtraData> implements BotonicContextType<TExtraData> { private readonly hubtypeService; input: BotonicContextInput; session: BotonicContextSession<TExtraData>; readonly settings: BotonicContextSettings; readonly secrets: BotonicContextSecrets; defaultDelay: number; defaultTyping: number; defaultTypingMode: TypingMode; params: Record<string, string>; plugins: TPlugins; response?: ActionResponse; constructor(hubtypeService: HubtypeApiService, base: BotonicContextType<TExtraData>, plugins: TPlugins, defaultTyping: number, defaultDelay: number, defaultTypingMode: TypingMode, response?: ActionResponse); /** * Session user setters notify via sync callback; `updateBotSession` is async. * Attach `.catch` so fetch/network failures are logged instead of unhandled rejections. */ private bindSessionUpdateCallback; sendMessages: (messages: BotServerMessage[], options?: SendMessagesOptions) => Promise<unknown>; doHandoff: (handoffOptions?: HandoffOptions) => Promise<unknown>; getBotSession: () => Promise<import("@botonic/shared").BotonicSession<UserExtraData>>; updateBotSession: (updates: BotonicSessionUpdate<TExtraData>) => Promise<void>; }