@a.izzuddin/ai-chat 0.2.7 → 0.2.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
@@ -13,7 +13,7 @@ A modern, customizable chat widget built with Lit web components. Features a cle
13
13
  - 🎯 **TypeScript Support** - Full type safety
14
14
  - 📝 **List Formatting** - Automatic rendering of bulleted and numbered lists
15
15
  - 💡 **Suggested Questions** - Clickable follow-up questions for better UX
16
- - 🔗 **Related FAQs** - Display related FAQ references
16
+ <!-- - 🔗 **Related FAQs** - Display related FAQ references (commented out) -->
17
17
  - 👋 **Customizable Welcome Message** - Set custom greeting with optional subtitle
18
18
 
19
19
  ## Quick Start
@@ -117,21 +117,28 @@ import '@a.izzuddin/ai-chat';
117
117
  session-id="user-123"
118
118
  title="AI Assistant"
119
119
  bot-avatar-url="/path/to/avatar.png"
120
+ widget-icon-url="/path/to/widget-icon.png"
120
121
  background-image-url="/path/to/background.png">
121
122
  </ai-chat>
122
123
  ```
123
124
 
125
+ **Note:** The `widget-icon-url` sets a custom icon for the floating widget button (only applies in widget mode).
126
+
124
127
  #### Custom Welcome Message
128
+ The welcome message appears as the first assistant message in the chat instead of a large empty state.
129
+
125
130
  ```html
126
131
  <ai-chat
127
132
  api-url="https://api.example.com"
128
133
  session-id="user-123"
129
134
  title="AI Assistant"
130
- welcome-message="Hello! How may I assist you?"
131
- welcome-subtitle="Ask me anything about our services">
135
+ welcome-message="Hai, bagaimana saya boleh bantu?"
136
+ welcome-subtitle="Sila tanya tentang permohonan atau apa-apa berkaitan MySTI">
132
137
  </ai-chat>
133
138
  ```
134
139
 
140
+ The welcome message and subtitle will be combined and displayed as a regular chat message from the assistant.
141
+
135
142
  ### Dark Mode
136
143
  ```html
137
144
  <ai-chat
@@ -158,9 +165,10 @@ import '@a.izzuddin/ai-chat';
158
165
  | `user-message-bg` | string | '#D6E4FF' | User message background |
159
166
  | `bot-message-bg` | string | '#F5F5F5' | Bot message background |
160
167
  | `bot-avatar-url` | string | '' | Custom bot avatar image |
168
+ | `widget-icon-url` | string | '' | Custom widget button icon (widget mode only) |
161
169
  | `background-image-url` | string | '' | Chat background image |
162
- | `welcome-message` | string | 'How can I help you today?' | Initial welcome message shown when chat is empty |
163
- | `welcome-subtitle` | string | '' | Optional subtitle text shown below welcome message |
170
+ | `welcome-message` | string | 'How can I help you today?' | Initial message from assistant (appears as first chat message) |
171
+ | `welcome-subtitle` | string | '' | Optional subtitle added to welcome message |
164
172
 
165
173
  ## API Integration
166
174
 
@@ -178,12 +186,6 @@ Expected response format:
178
186
  ```json
179
187
  {
180
188
  "response": "string",
181
- "faq_used": [
182
- {
183
- "no.": "1",
184
- "question": "What is MySTI?"
185
- }
186
- ],
187
189
  "suggested_follow_ups": [
188
190
  "What are the main objectives of the program?",
189
191
  "How can companies apply?",
@@ -192,13 +194,26 @@ Expected response format:
192
194
  }
193
195
  ```
194
196
 
197
+ <!-- FAQ functionality - commented out for now
198
+ {
199
+ "response": "string",
200
+ "faq_used": [
201
+ {
202
+ "no.": "1",
203
+ "question": "What is MySTI?"
204
+ }
205
+ ],
206
+ "suggested_follow_ups": [...]
207
+ }
208
+ -->
209
+
195
210
  **Supported field variations:**
196
- - `faq_used` or `faqs_used` for related FAQs
211
+ <!-- - `faq_used` or `faqs_used` for related FAQs (commented out) -->
197
212
  - `suggested_follow_ups` or `suggested_questions` for clickable follow-up questions
198
213
 
199
214
  ### Response Behavior
200
215
 
201
- - **Related FAQs** - Displayed as non-clickable text references
216
+ <!-- - **Related FAQs** - Displayed as non-clickable text references (commented out) -->
202
217
  - **Suggested Questions** - Displayed as clickable buttons that send the question when clicked
203
218
  - **List Formatting** - Messages support automatic list rendering:
204
219
  - Unordered lists: Lines starting with `-`, `*`, or `•`
@@ -69,18 +69,7 @@
69
69
  {
70
70
  "kind": "javascript-module",
71
71
  "path": "dist/index.js",
72
- "declarations": [
73
- {
74
- "kind": "variable",
75
- "name": "faqs",
76
- "default": "void 0"
77
- },
78
- {
79
- "kind": "variable",
80
- "name": "suggestedQuestions",
81
- "default": "void 0"
82
- }
83
- ],
72
+ "declarations": [],
84
73
  "exports": []
85
74
  },
86
75
  {
@@ -221,14 +210,6 @@
221
210
  "name": "Message",
222
211
  "module": "./components/ai-chat"
223
212
  }
224
- },
225
- {
226
- "kind": "js",
227
- "name": "FAQ",
228
- "declaration": {
229
- "name": "FAQ",
230
- "module": "./components/ai-chat"
231
- }
232
213
  }
233
214
  ]
234
215
  },
@@ -534,6 +515,34 @@
534
515
  }
535
516
  ]
536
517
  },
518
+ {
519
+ "kind": "javascript-module",
520
+ "path": "src/components/AIChat.tsx",
521
+ "declarations": [
522
+ {
523
+ "kind": "function",
524
+ "name": "AIChat",
525
+ "parameters": [
526
+ {
527
+ "name": "{\n apiUrl,\n sessionId = \"default-session\",\n title = \"My AI Agent\",\n initialMessages = [],\n className,\n onMessageSent,\n onResponseReceived,\n onError,\n}",
528
+ "type": {
529
+ "text": "AIChatProps"
530
+ }
531
+ }
532
+ ]
533
+ }
534
+ ],
535
+ "exports": [
536
+ {
537
+ "kind": "js",
538
+ "name": "AIChat",
539
+ "declaration": {
540
+ "name": "AIChat",
541
+ "module": "src/components/AIChat.tsx"
542
+ }
543
+ }
544
+ ]
545
+ },
537
546
  {
538
547
  "kind": "javascript-module",
539
548
  "path": "src/components/ai-chat.ts",
@@ -614,6 +623,16 @@
614
623
  "default": "''",
615
624
  "attribute": "bot-avatar-url"
616
625
  },
626
+ {
627
+ "kind": "field",
628
+ "name": "widgetIconUrl",
629
+ "privacy": "public",
630
+ "type": {
631
+ "text": "string"
632
+ },
633
+ "default": "''",
634
+ "attribute": "widget-icon-url"
635
+ },
617
636
  {
618
637
  "kind": "field",
619
638
  "name": "backgroundImageUrl",
@@ -741,17 +760,20 @@
741
760
  "default": "false"
742
761
  },
743
762
  {
744
- "kind": "field",
745
- "name": "messagesEndRef",
746
- "type": {
747
- "text": "HTMLDivElement | undefined"
748
- },
763
+ "kind": "method",
764
+ "name": "toggleWidget",
749
765
  "privacy": "private"
750
766
  },
751
767
  {
752
768
  "kind": "method",
753
- "name": "toggleWidget",
754
- "privacy": "private"
769
+ "name": "clearChat",
770
+ "privacy": "public",
771
+ "return": {
772
+ "type": {
773
+ "text": "void"
774
+ }
775
+ },
776
+ "description": "Clear all chat messages and reset to welcome message"
755
777
  },
756
778
  {
757
779
  "kind": "method",
@@ -778,6 +800,46 @@
778
800
  }
779
801
  ]
780
802
  },
803
+ {
804
+ "kind": "method",
805
+ "name": "getStorageKey",
806
+ "privacy": "private",
807
+ "return": {
808
+ "type": {
809
+ "text": "string"
810
+ }
811
+ }
812
+ },
813
+ {
814
+ "kind": "method",
815
+ "name": "saveMessagesToStorage",
816
+ "privacy": "private",
817
+ "return": {
818
+ "type": {
819
+ "text": "void"
820
+ }
821
+ }
822
+ },
823
+ {
824
+ "kind": "method",
825
+ "name": "loadMessagesFromStorage",
826
+ "privacy": "private",
827
+ "return": {
828
+ "type": {
829
+ "text": "Message[] | null"
830
+ }
831
+ }
832
+ },
833
+ {
834
+ "kind": "method",
835
+ "name": "clearMessagesFromStorage",
836
+ "privacy": "private",
837
+ "return": {
838
+ "type": {
839
+ "text": "void"
840
+ }
841
+ }
842
+ },
781
843
  {
782
844
  "kind": "method",
783
845
  "name": "formatMessageContent",
@@ -926,6 +988,14 @@
926
988
  "default": "''",
927
989
  "fieldName": "botAvatarUrl"
928
990
  },
991
+ {
992
+ "name": "widget-icon-url",
993
+ "type": {
994
+ "text": "string"
995
+ },
996
+ "default": "''",
997
+ "fieldName": "widgetIconUrl"
998
+ },
929
999
  {
930
1000
  "name": "background-image-url",
931
1001
  "type": {
@@ -1025,34 +1095,6 @@
1025
1095
  }
1026
1096
  }
1027
1097
  ]
1028
- },
1029
- {
1030
- "kind": "javascript-module",
1031
- "path": "src/components/AIChat.tsx",
1032
- "declarations": [
1033
- {
1034
- "kind": "function",
1035
- "name": "AIChat",
1036
- "parameters": [
1037
- {
1038
- "name": "{\n apiUrl,\n sessionId = \"default-session\",\n title = \"My AI Agent\",\n initialMessages = [],\n className,\n onMessageSent,\n onResponseReceived,\n onError,\n}",
1039
- "type": {
1040
- "text": "AIChatProps"
1041
- }
1042
- }
1043
- ]
1044
- }
1045
- ],
1046
- "exports": [
1047
- {
1048
- "kind": "js",
1049
- "name": "AIChat",
1050
- "declaration": {
1051
- "name": "AIChat",
1052
- "module": "src/components/AIChat.tsx"
1053
- }
1054
- }
1055
- ]
1056
1098
  }
1057
1099
  ]
1058
1100
  }
package/dist/index.d.mts CHANGED
@@ -2,15 +2,11 @@ import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
3
  import { LitElement, PropertyValues } from 'lit';
4
4
 
5
- interface FAQ {
6
- "no.": string;
7
- question: string;
8
- }
9
5
  interface Message {
10
6
  id: string;
11
7
  role: 'user' | 'assistant';
12
8
  content: string;
13
- faqs?: FAQ[];
9
+ faqs?: any[];
14
10
  suggestedQuestions?: string[];
15
11
  }
16
12
  /**
@@ -60,6 +56,7 @@ declare class AIChat extends LitElement {
60
56
  mode: 'fullscreen' | 'widget';
61
57
  initialMessages: Message[];
62
58
  botAvatarUrl: string;
59
+ widgetIconUrl: string;
63
60
  backgroundImageUrl: string;
64
61
  widgetWidth: string;
65
62
  widgetHeight: string;
@@ -73,7 +70,6 @@ declare class AIChat extends LitElement {
73
70
  private input;
74
71
  private isLoading;
75
72
  private isOpen;
76
- private messagesEndRef?;
77
73
  static properties: {
78
74
  apiUrl: {
79
75
  type: StringConstructor;
@@ -101,6 +97,10 @@ declare class AIChat extends LitElement {
101
97
  type: StringConstructor;
102
98
  attribute: string;
103
99
  };
100
+ widgetIconUrl: {
101
+ type: StringConstructor;
102
+ attribute: string;
103
+ };
104
104
  backgroundImageUrl: {
105
105
  type: StringConstructor;
106
106
  attribute: string;
@@ -140,7 +140,16 @@ declare class AIChat extends LitElement {
140
140
  };
141
141
  constructor();
142
142
  private toggleWidget;
143
+ /**
144
+ * Clear all chat messages and reset to welcome message
145
+ * @public
146
+ */
147
+ clearChat(): void;
143
148
  private lightenColor;
149
+ private getStorageKey;
150
+ private saveMessagesToStorage;
151
+ private loadMessagesFromStorage;
152
+ private clearMessagesFromStorage;
144
153
  private formatMessageContent;
145
154
  connectedCallback(): void;
146
155
  updated(changedProperties: PropertyValues): void;
@@ -157,4 +166,4 @@ declare global {
157
166
  }
158
167
  }
159
168
 
160
- export { AIChat, type FAQ, type Message };
169
+ export { AIChat, type Message };
package/dist/index.d.ts CHANGED
@@ -2,15 +2,11 @@ import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
3
  import { LitElement, PropertyValues } from 'lit';
4
4
 
5
- interface FAQ {
6
- "no.": string;
7
- question: string;
8
- }
9
5
  interface Message {
10
6
  id: string;
11
7
  role: 'user' | 'assistant';
12
8
  content: string;
13
- faqs?: FAQ[];
9
+ faqs?: any[];
14
10
  suggestedQuestions?: string[];
15
11
  }
16
12
  /**
@@ -60,6 +56,7 @@ declare class AIChat extends LitElement {
60
56
  mode: 'fullscreen' | 'widget';
61
57
  initialMessages: Message[];
62
58
  botAvatarUrl: string;
59
+ widgetIconUrl: string;
63
60
  backgroundImageUrl: string;
64
61
  widgetWidth: string;
65
62
  widgetHeight: string;
@@ -73,7 +70,6 @@ declare class AIChat extends LitElement {
73
70
  private input;
74
71
  private isLoading;
75
72
  private isOpen;
76
- private messagesEndRef?;
77
73
  static properties: {
78
74
  apiUrl: {
79
75
  type: StringConstructor;
@@ -101,6 +97,10 @@ declare class AIChat extends LitElement {
101
97
  type: StringConstructor;
102
98
  attribute: string;
103
99
  };
100
+ widgetIconUrl: {
101
+ type: StringConstructor;
102
+ attribute: string;
103
+ };
104
104
  backgroundImageUrl: {
105
105
  type: StringConstructor;
106
106
  attribute: string;
@@ -140,7 +140,16 @@ declare class AIChat extends LitElement {
140
140
  };
141
141
  constructor();
142
142
  private toggleWidget;
143
+ /**
144
+ * Clear all chat messages and reset to welcome message
145
+ * @public
146
+ */
147
+ clearChat(): void;
143
148
  private lightenColor;
149
+ private getStorageKey;
150
+ private saveMessagesToStorage;
151
+ private loadMessagesFromStorage;
152
+ private clearMessagesFromStorage;
144
153
  private formatMessageContent;
145
154
  connectedCallback(): void;
146
155
  updated(changedProperties: PropertyValues): void;
@@ -157,4 +166,4 @@ declare global {
157
166
  }
158
167
  }
159
168
 
160
- export { AIChat, type FAQ, type Message };
169
+ export { AIChat, type Message };