@ensembleapp/client-sdk 0.0.19 → 0.0.20

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/dist/index.d.ts CHANGED
@@ -245,8 +245,12 @@ interface ChatWidgetFeedbackOptions {
245
245
  interface ChatWidgetConfig extends UseChatConfig {
246
246
  /** Title for the Chat window */
247
247
  title?: string;
248
- /** Introductory message displayed at the start of the chat for brand new threads */
249
- introMessage?: string;
248
+ /** Initial assistant message displayed at the start of the chat (if history is empty).
249
+ * Skipped if initialUserMessage is provided. */
250
+ initialAssistantMessage?: string;
251
+ /** Initial user message to send automatically when the chat loads (if history is empty).
252
+ * Use this to kick-start the conversation without requiring user input. */
253
+ initialUserMessage?: string;
250
254
  /** Placeholder text for the input box */
251
255
  inputPlaceholder?: string;
252
256
  className?: string;
@@ -257,7 +261,7 @@ interface ChatWidgetConfig extends UseChatConfig {
257
261
  /** Feedback options for assistant messages. Enabled by default. */
258
262
  feedback?: ChatWidgetFeedbackOptions;
259
263
  }
260
- declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title, introMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, feedback, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
264
+ declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title, initialAssistantMessage, initialUserMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, feedback, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
261
265
 
262
266
  interface PopupAnchorConfig {
263
267
  enabled?: boolean;
package/dist/index.js CHANGED
@@ -24422,7 +24422,8 @@ function ChatWidget({
24422
24422
  onFinish,
24423
24423
  onMessage,
24424
24424
  title,
24425
- introMessage,
24425
+ initialAssistantMessage,
24426
+ initialUserMessage,
24426
24427
  inputPlaceholder,
24427
24428
  className,
24428
24429
  styles: styleProps,
@@ -24532,14 +24533,21 @@ function ChatWidget({
24532
24533
  };
24533
24534
  }, [voice]);
24534
24535
  useEffect4(() => {
24535
- if (introMessage && messages.length === 0) {
24536
+ if (initialAssistantMessage && !initialUserMessage && messages.length === 0) {
24536
24537
  setMessages([{
24537
24538
  id: "welcome-message",
24538
24539
  role: "assistant",
24539
- parts: [{ type: "text", text: introMessage }]
24540
+ parts: [{ type: "text", text: initialAssistantMessage }]
24540
24541
  }]);
24541
24542
  }
24542
- }, [introMessage, messages.length, setMessages]);
24543
+ }, [initialAssistantMessage, initialUserMessage, messages.length, setMessages]);
24544
+ const initialMessageSentRef = useRef3(false);
24545
+ useEffect4(() => {
24546
+ if (initialUserMessage && !initialMessageSentRef.current && status === "ready" && messages.length === 0) {
24547
+ initialMessageSentRef.current = true;
24548
+ sendMessage({ text: initialUserMessage });
24549
+ }
24550
+ }, [initialUserMessage, status, messages.length, sendMessage]);
24543
24551
  const handleScroll = useCallback4(() => {
24544
24552
  if (!scrollContainerRef.current) return;
24545
24553
  const { scrollTop, scrollHeight, clientHeight } = scrollContainerRef.current;
@@ -24908,7 +24916,7 @@ function VendorCards({ payload, enriched }) {
24908
24916
  };
24909
24917
  return /* @__PURE__ */ jsx8("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: payload.vendors.map((v, index) => {
24910
24918
  const data = vendorData[v.vendor_id];
24911
- const name17 = data?.names?.find((n) => n.type === "org")?.value ?? "";
24919
+ const name17 = data?.names?.[0]?.value ?? "Unknown";
24912
24920
  const address = data?.location?.address;
24913
24921
  const distanceEntry = distances.find((d) => d.destinationIndex === index);
24914
24922
  const distance = distanceEntry && distanceEntry.distanceMeters ? formatDistance(distanceEntry.distanceMeters) : void 0;