@coristen/widget 0.1.8 → 0.1.9

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/README.md CHANGED
@@ -15,9 +15,9 @@ export default function App() {
15
15
  }
16
16
  ```
17
17
 
18
- Public websites use `apiKey`; visitors are remembered in that browser. For an
19
- authenticated app, use an identity route instead so conversations follow the
20
- signed-in customer:
18
+ Public websites use `apiKey`. The widget remembers visitors in that browser. For
19
+ an authenticated app, use an identity route. This keeps conversations connected
20
+ to the signed-in customer.
21
21
 
22
22
  ```tsx
23
23
  <CoristenWidget identity="/api/coristen/identity" />
@@ -34,6 +34,33 @@ export const { GET } = coristenIdentity(async (request) => {
34
34
  })
35
35
  ```
36
36
 
37
- Set `CORISTEN_KEY` on the server when using identity mode. Identity mode renders
38
- only for a verified signed-in customer; it never falls back to anonymous access.
39
- Use `apiUrl="http://localhost:3000"` while developing Coristen locally.
37
+ Set `CORISTEN_KEY` on the server when you use identity mode. Identity mode renders
38
+ only for a verified signed-in customer. It does not permit anonymous access.
39
+
40
+ ## Welcome screen
41
+
42
+ After a visitor enters an email address, a new chat shows the agent avatar, workspace
43
+ welcome message, and a maximum of three questions. Coristen generates these questions
44
+ when it indexes or refreshes knowledge documents. Refresh existing sources to generate
45
+ questions. If document questions are not available, the widget shows general questions.
46
+ When a visitor selects a question, the widget sends its message immediately.
47
+
48
+ Override the message and suggestion list for your installation:
49
+
50
+ ```tsx
51
+ <CoristenWidget
52
+ apiKey="coristen_pk_..."
53
+ welcome={{
54
+ message: "How can I help you today?",
55
+ suggestions: [
56
+ { title: "Shipping", message: "What shipping options do you offer?" },
57
+ { title: "Returns", message: "How do I return or exchange an item?" },
58
+ ],
59
+ }}
60
+ />
61
+ ```
62
+
63
+ Omit `suggestions` to use the automatic list. Pass `[]` to hide the suggestions.
64
+ The exported `WidgetWelcome` and `WidgetSuggestion` types describe this API. The
65
+ props update with your application state. A suggestion message can contain a maximum
66
+ of 2,000 characters.
package/dist/api.d.ts CHANGED
@@ -1,3 +1,11 @@
1
+ export type WidgetSuggestion = {
2
+ title: string;
3
+ message: string;
4
+ };
5
+ export type WidgetWelcome = {
6
+ message?: string;
7
+ suggestions?: WidgetSuggestion[];
8
+ };
1
9
  export type ChatMessage = {
2
10
  _id: string;
3
11
  _creationTime: number;
@@ -27,6 +35,7 @@ export type ChatAttachment = {
27
35
  };
28
36
  export type WidgetSettings = {
29
37
  name: string;
38
+ logoUrl?: string | null;
30
39
  agentName: string;
31
40
  agentImageUrl: string | null;
32
41
  brandColor: string;
@@ -47,6 +56,10 @@ export type WidgetSettings = {
47
56
  allowedAttachmentTypes: string[];
48
57
  };
49
58
  export declare const widgetApi: {
59
+ welcomeSuggestions: import("convex/server").FunctionReference<"query", "public", {
60
+ workspaceId: string;
61
+ sessionToken: string;
62
+ }, WidgetSuggestion[], string | undefined>;
50
63
  workspace: import("convex/server").FunctionReference<"query", "public", {
51
64
  workspaceId: string;
52
65
  }, WidgetSettings | null, string | undefined>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import type { WidgetSettings } from "./api";
1
+ import type { WidgetSettings, WidgetWelcome } from "./api";
2
2
  type CoristenWidgetOptions = {
3
3
  apiUrl?: string;
4
4
  defaultOpen?: boolean;
5
+ defaultEmail?: string;
6
+ welcome?: WidgetWelcome;
5
7
  fontSize?: string;
6
8
  appearance?: WidgetAppearance;
7
9
  onReady?: () => void;
@@ -14,9 +16,10 @@ export type CoristenWidgetProps = CoristenWidgetOptions & ({
14
16
  identity: string;
15
17
  apiKey?: never;
16
18
  });
17
- export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "showPoweredBy">>;
18
- export declare function CoristenWidget({ identity, apiKey, apiUrl, defaultOpen, fontSize, appearance, onReady, onError, }: CoristenWidgetProps): import("react").JSX.Element | null;
19
+ export type WidgetAppearance = Partial<Pick<WidgetSettings, "brandColor" | "logoUrl" | "position" | "theme" | "tintedGrayscale" | "accentEnabled" | "accentHeader" | "accentSendIcon" | "radius" | "bubbleIcon" | "bubbleColor" | "showPoweredBy">>;
20
+ export declare function CoristenWidget({ identity, apiKey, apiUrl, defaultOpen, defaultEmail, welcome, fontSize, appearance, onReady, onError, }: CoristenWidgetProps): import("react").JSX.Element | null;
19
21
  export type { WidgetSettings } from "./api";
22
+ export type { WidgetWelcome, WidgetSuggestion } from "./api";
20
23
  export declare const coristenWidget: {
21
24
  open(): void;
22
25
  close(): void;