@helpai/elements 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -3207,11 +3207,12 @@ type HookListener = (instance: ChatWidgetInstance, event: EventName, data: unkno
3207
3207
  /**
3208
3208
  * Host-element command bus.
3209
3209
  *
3210
- * The programmatic API (`chat.open()`, `.close()`, `.expand()`)
3211
- * dispatches `CustomEvent`s on the shadow host element. The App listens
3212
- * for those same events and routes them to its state handlers. That
3213
- * keeps the two modules decoupled — `index.ts` doesn't hold a ref to App
3214
- * state, App doesn't know about the public instance handle.
3210
+ * The programmatic API (`chat.open()`, `.close()`, `.ask()`, …) and the
3211
+ * `<web-ai-chat>` element's methods dispatch `CustomEvent`s on the shadow
3212
+ * host element. The App listens for those same events and routes them to
3213
+ * its state handlers. That keeps the two modules decoupled — `index.ts`
3214
+ * doesn't hold a ref to App state, App doesn't know about the public
3215
+ * instance handle.
3215
3216
  *
3216
3217
  * This module is the single source of truth for the event names + the
3217
3218
  * tiny helpers on both sides of the bridge.
@@ -3221,6 +3222,11 @@ interface OpenTarget {
3221
3222
  to: 'home' | 'chats' | 'help' | 'news';
3222
3223
  id?: string;
3223
3224
  }
3225
+ /** How `ask(text, options)` lands: in the composer for the visitor to send (default), or sent right away. */
3226
+ interface AskOptions {
3227
+ /** Send the text as the visitor's message instead of filling the composer with it. Default `false`. */
3228
+ send?: boolean;
3229
+ }
3224
3230
  /**
3225
3231
  * Comprehensive logger for the widget runtime.
3226
3232
  *
@@ -3284,6 +3290,18 @@ export interface ChatWidgetInstance {
3284
3290
  * if no form with that id + a `manual` trigger exists.
3285
3291
  */
3286
3292
  openForm: (id: string) => void;
3293
+ /**
3294
+ * Open the chat with `text` in the composer, ready for the visitor to edit and send — for a site's own "Ask about
3295
+ * pricing" button. With `{ send: true }` it goes out as the visitor's message instead. Either way it waits until
3296
+ * the chat can take it (still connecting, a pre-chat form to answer; a send also waits for a reply still arriving).
3297
+ *
3298
+ * @example
3299
+ * ```ts
3300
+ * chat.ask('How do I book a session?'); // open the chat with the question in the composer
3301
+ * chat.ask('How do I book a session?', { send: true }); // open the chat and send it
3302
+ * ```
3303
+ */
3304
+ ask: (text: string, options?: AskOptions) => void;
3287
3305
  /**
3288
3306
  * Subscribe to a lifecycle event. Returns an `off` function. See
3289
3307
  * {@link EventMap} for the full set + payload shapes — currently
@@ -3427,4 +3445,4 @@ export declare const brand: {
3427
3445
  readonly domain: string;
3428
3446
  readonly siteUrl: string;
3429
3447
  };
3430
- export type { Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, Link, LogEntry, LogLevel, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial };
3448
+ export type { AskOptions, Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, Link, LogEntry, LogLevel, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial };