Skip to content

Commit c247ffe

Browse files
authored
Merge pull request #12 from thesysdev/zk/feat/conv-startersv2
Add welcome message and conversation starters features to the chat widget configuration in README and types.
2 parents a22daec + 467f05c commit c247ffe

5 files changed

Lines changed: 127 additions & 17 deletions

File tree

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ An embeddable chat widget that lets your AI chatbots render rich, interactive UI
1616
- 🔌 **Multi-Provider** - LangGraph, n8n, Make.com, or custom webhooks
1717
- 🌊 **Streaming Support** - Real-time streaming responses from your backend
1818
- 📐 **Multiple Layouts** - Full-page, side panel, or bottom tray form factors
19+
- 👋 **Welcome Message** - Customizable greeting when starting a new conversation
20+
- 💡 **Conversation Starters** - Pre-defined prompts to help users get started
1921

2022
## Quick Start
2123

@@ -120,6 +122,22 @@ const chat = createChat({
120122
formFactor: "full-page", // 'full-page', 'side-panel', or 'bottom-tray'
121123
enableDebugLogging: false, // Enable console debug logging
122124

125+
// Optional: Welcome message shown when thread is empty
126+
welcomeMessage: {
127+
title: "Hi, I'm Assistant",
128+
description: "I can help you with your questions.",
129+
image: { url: "https://example.com/logo.png" },
130+
},
131+
132+
// Optional: Conversation starters
133+
conversationStarters: {
134+
variant: "short", // 'short' for pill buttons, 'long' for list items
135+
options: [
136+
{ displayText: "Help me get started", prompt: "Help me get started" },
137+
{ displayText: "What can you do?", prompt: "What can you do?" },
138+
],
139+
},
140+
123141
// Optional: Callbacks
124142
onSessionStart: (sessionId) => {
125143
console.log("Session started:", sessionId);
@@ -331,6 +349,62 @@ Controls chat history persistence:
331349
- `'localstorage'` - Messages are saved to browser localStorage, persist across sessions
332350
- `'langgraph'` - Uses LangGraph's server-side thread management (requires `langgraph` provider)
333351

352+
### welcomeMessage (optional)
353+
354+
```typescript
355+
welcomeMessage?: {
356+
title?: string; // Main heading text
357+
description?: string; // Subheading/description text
358+
image?: { url: string }; // Optional logo/image
359+
} | React.ComponentType; // Or provide a custom component
360+
```
361+
362+
Displayed when the thread is empty to greet users.
363+
364+
**Example:**
365+
366+
```javascript
367+
createChat({
368+
n8n: { webhookUrl: "YOUR_WEBHOOK_URL" },
369+
welcomeMessage: {
370+
title: "Hi, I'm Assistant",
371+
description: "I can help you with your questions.",
372+
image: { url: "/logo.png" },
373+
},
374+
});
375+
```
376+
377+
### conversationStarters (optional)
378+
379+
```typescript
380+
conversationStarters?: {
381+
variant?: 'short' | 'long'; // 'short' = pill buttons, 'long' = list items
382+
options: Array<{
383+
displayText: string; // Text shown on the button
384+
prompt: string; // Message sent when clicked
385+
icon?: React.ReactNode; // Optional icon
386+
}>;
387+
}
388+
```
389+
390+
Clickable prompts shown when the thread is empty to help users begin a conversation.
391+
392+
**Example:**
393+
394+
```javascript
395+
createChat({
396+
n8n: { webhookUrl: "YOUR_WEBHOOK_URL" },
397+
conversationStarters: {
398+
variant: "short",
399+
options: [
400+
{ displayText: "Help me get started", prompt: "Help me get started" },
401+
{ displayText: "What can you do?", prompt: "What can you do?" },
402+
{ displayText: "Show me examples", prompt: "Show me some examples" },
403+
],
404+
},
405+
});
406+
```
407+
334408
### formFactor (optional)
335409

336410
```typescript

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "genui-widget",
3-
"version": "0.6.3",
3+
"version": "0.7.3",
44
"type": "module",
55
"description": "An embeddable chat widget that lets your AI chatbots render rich, interactive UI like buttons, forms, charts, cards and more instead of plain text. Works out of the box with LangGraph/LangChain and n8n.",
66
"main": "./dist/genui-widget.umd.js",
@@ -23,9 +23,9 @@
2323
"lint": "eslint src"
2424
},
2525
"dependencies": {
26-
"@crayonai/react-ui": "^0.9.9",
26+
"@crayonai/react-ui": "^0.9.13",
2727
"@crayonai/stream": "^0.6.4",
28-
"@thesysai/genui-sdk": "^0.7.14"
28+
"@thesysai/genui-sdk": "^0.7.16"
2929
},
3030
"peerDependencies": {
3131
"react": "^18.0.0 || ^19.0.0",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ function ChatWithPersistence({
289289
theme: config.theme,
290290
agentName: config.agentName || "Assistant",
291291
logoUrl: config.logoUrl,
292+
welcomeMessage: config.welcomeMessage,
293+
conversationStarters: config.conversationStarters,
292294
formFactor,
293295
};
294296

src/types.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import type {
2+
WelcomeMessageConfig,
3+
ConversationStartersConfig,
4+
} from "@thesysai/genui-sdk";
5+
16
/**
27
* Storage type for persisting chat data
38
*/
@@ -113,6 +118,35 @@ export interface ChatConfig {
113118
*/
114119
logoUrl?: string;
115120

121+
/**
122+
* Welcome message shown when the thread is empty.
123+
* Can be a config object with title, description, and image,
124+
* or a custom React component.
125+
*
126+
* @example
127+
* welcomeMessage: {
128+
* title: "Hi, I'm Assistant",
129+
* description: "I can help you with your questions.",
130+
* image: { url: "/logo.png" },
131+
* }
132+
*/
133+
welcomeMessage?: WelcomeMessageConfig;
134+
135+
/**
136+
* Conversation starters shown when the thread is empty.
137+
* Clickable prompts that help users begin a conversation.
138+
*
139+
* @example
140+
* conversationStarters: {
141+
* variant: "short", // "short" for pill buttons, "long" for list items
142+
* options: [
143+
* { displayText: "Help me get started", prompt: "Help me get started" },
144+
* { displayText: "What can you do?", prompt: "What can you do?" },
145+
* ],
146+
* }
147+
*/
148+
conversationStarters?: ConversationStartersConfig;
149+
116150
/**
117151
* Form factor for the chat widget layout
118152
* - "full-page": Takes up the entire viewport (default)

0 commit comments

Comments
 (0)