UNPKG

@botonic/core

Version:

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

31 lines 1.44 kB
import { BotonicContext } from './botonic-context'; import { BotonicContextInput } from './botonic-context-input'; import { BotonicContextSession } from './botonic-context-session'; import { BotonicContextSecrets, BotonicContextSettings, } from './botonic-context-settings'; /** * Factory that creates BotonicContext from raw lambda request. * Injects hubtypeService so the context has working sendMessages, doHandoff, etc. */ export class BotonicContextFactory { constructor(hubtypeService, plugins, defaultTyping, defaultDelay, defaultTypingMode = 'inBetweenTyping') { this.hubtypeService = hubtypeService; this.plugins = plugins; this.defaultTyping = defaultTyping; this.defaultDelay = defaultDelay; this.defaultTypingMode = defaultTypingMode; } /** Creates input, session, settings, and secrets from a {@link BotonicRequest}. */ static from(raw) { return { input: new BotonicContextInput(raw.input), session: new BotonicContextSession(raw.session), settings: new BotonicContextSettings(raw.settings), secrets: new BotonicContextSecrets(raw.secrets), }; } create(raw) { const base = BotonicContextFactory.from(raw); return new BotonicContext(this.hubtypeService, base, this.plugins, this.defaultTyping, this.defaultDelay, this.defaultTypingMode); } } //# sourceMappingURL=factory.js.map