@xcelsior/ui-chat 2.0.2 → 2.0.4
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/.storybook/preview.tsx +2 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +49 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/components/Chat.tsx +35 -74
- package/src/components/ChatWidget.tsx +0 -1
- package/src/hooks/useMessages.ts +22 -1
- package/src/hooks/useWebSocket.ts +18 -1
- package/storybook-static/assets/Chat.stories-BkbpOOSG.js +830 -0
- package/storybook-static/assets/{Color-YHDXOIA2-BMnd3YrF.js → Color-YHDXOIA2-CSuNIR0a.js} +1 -1
- package/storybook-static/assets/{DocsRenderer-CFRXHY34-i_W8iCu9.js → DocsRenderer-CFRXHY34-dpuOKTQp.js} +3 -3
- package/storybook-static/assets/{MessageItem-DAaKZ9s9.js → MessageItem-Dlb6dSKL.js} +9 -9
- package/storybook-static/assets/MessageItem.stories-CsxqSqu-.js +422 -0
- package/storybook-static/assets/{entry-preview-oDnntGcx.js → entry-preview-C_-WO6GJ.js} +1 -1
- package/storybook-static/assets/{iframe-CGBtu2Se.js → iframe-BXTccXxS.js} +2 -2
- package/storybook-static/assets/preview-B8y-wc-n.css +1 -0
- package/storybook-static/assets/preview-CC4t7T7W.js +1 -0
- package/storybook-static/assets/{preview-BRpahs9B.js → preview-Cyx3pE7Q.js} +2 -2
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.json +1 -1
- package/storybook-static/project.json +1 -1
- package/tsconfig.json +4 -0
- package/storybook-static/assets/Chat.stories-J_Yp51wU.js +0 -803
- package/storybook-static/assets/MessageItem.stories-Ckr1_scc.js +0 -255
- package/storybook-static/assets/ToastContext-Bty1K7ya.js +0 -1
- package/storybook-static/assets/preview-DUOvJmsz.js +0 -1
- package/storybook-static/assets/preview-DcGwT3kv.css +0 -1
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./jsx-runtime-Cf8x2fCZ.js";import{M as a}from"./MessageItem-DAaKZ9s9.js";import"./index-yBjzXJbu.js";import"./BrandIcons-Cjy5INAp.js";import"./index--qcDGAq6.js";import"./en-US-BukEqXxE.js";const Oe={title:"Components/MessageItem",component:a,parameters:{layout:"padded"},tags:["autodocs"]},s={name:"John Doe",email:"john@example.com",type:"customer",status:"online"},e={id:"1",conversationId:"conv-1",senderId:"user@example.com",senderType:"customer",content:"Hello, I need help with my account.",messageType:"text",createdAt:new Date().toISOString(),status:"sent"},o={args:{message:{...e,senderId:s.email,content:"Hello, I need help with my account."},currentUser:s,showAvatar:!0,showTimestamp:!0}},n={args:{message:{...e,senderId:"agent@example.com",senderType:"agent",content:"Hi! I'd be happy to help you with your account. What issue are you experiencing?"},currentUser:s,showAvatar:!0,showTimestamp:!0}},m={args:{message:{...e,senderId:"ai-assistant",senderType:"bot",content:`Hello! I'm the Xcelsior assistant. Based on our knowledge base, here are some common solutions:
|
|
2
|
-
|
|
3
|
-
1. Reset your password
|
|
4
|
-
2. Verify your email
|
|
5
|
-
3. Contact support
|
|
6
|
-
|
|
7
|
-
Which would you like help with?`,confidence:.85,metadata:{isAI:!0,kbUsed:!0}},currentUser:s,showAvatar:!0,showTimestamp:!0}},i={args:{message:{...e,senderId:"ai-assistant",senderType:"bot",content:"I'm not entirely sure about this, but let me check with my team. In the meantime, you might want to visit our help center.",confidence:.3,metadata:{isAI:!0,kbUsed:!1}},currentUser:s,showAvatar:!0,showTimestamp:!0}},c={args:{message:{...e,senderId:"ai-assistant",senderType:"bot",content:"You can reset your password by going to Settings > Security > Change Password.",feedback:"good",confidence:.9,metadata:{isAI:!0,kbUsed:!0}},currentUser:s,showAvatar:!0,showTimestamp:!0}},d={args:{message:{...e,senderId:"ai-assistant",senderType:"bot",content:"Your subscription expires on March 15th.",feedback:"wrong",confidence:.6,metadata:{isAI:!0,kbUsed:!0}},currentUser:s,showAvatar:!0,showTimestamp:!0}},p={args:{message:{...e,senderId:"ai-assistant",senderType:"bot",content:`## Getting Started
|
|
8
|
-
|
|
9
|
-
Here's how you can reset your password:
|
|
10
|
-
|
|
11
|
-
1. Go to the login page
|
|
12
|
-
2. Click on **"Forgot Password"**
|
|
13
|
-
3. Enter your email address
|
|
14
|
-
4. Check your inbox for the reset link
|
|
15
|
-
|
|
16
|
-
*Note: The link expires in 24 hours.*
|
|
17
|
-
|
|
18
|
-
For more help, visit our [support page](https://xcelsior.co/support).`,metadata:{isAI:!0,kbUsed:!0}},currentUser:s,showAvatar:!0,showTimestamp:!0}},u={args:{message:{...e,senderId:"system",senderType:"system",content:"Agent John joined the conversation",messageType:"system"},currentUser:s,showAvatar:!0,showTimestamp:!0}},g={args:{message:{...e,senderId:"system",senderType:"system",content:"Connecting you with a team member who can help further...",messageType:"system"},currentUser:s,showAvatar:!0,showTimestamp:!0}},h={args:{message:{...e,senderId:"system",senderType:"system",content:"Sarah from our team is here to help!",messageType:"system"},currentUser:s,showAvatar:!0,showTimestamp:!0}},l={args:{message:{...e,content:"https://picsum.photos/400/300",messageType:"image"},currentUser:s,showAvatar:!0,showTimestamp:!0}},y={args:{message:{...e,content:"https://example.com/document.pdf",messageType:"file",metadata:{fileName:"Technical Documentation.pdf"}},currentUser:s,showAvatar:!0,showTimestamp:!0}},w={render:r=>t.jsxs("div",{className:"flex flex-col gap-2 max-w-2xl p-4 bg-gray-950 rounded-lg",children:[t.jsx(a,{...r,message:{...e,id:"1",senderId:s.email,senderType:"customer",content:"Hi, I need help with pricing for a custom web app."}}),t.jsx(a,{...r,message:{...e,id:"2",senderId:"ai-assistant",senderType:"bot",content:"Hello! I'd be happy to help with pricing. At Xcelsior, we offer custom quotes based on your project requirements. Could you tell me more about what you're looking for?",confidence:.8,metadata:{isAI:!0,kbUsed:!0},createdAt:new Date(Date.now()-6e4).toISOString()}}),t.jsx(a,{...r,message:{...e,id:"3",senderId:s.email,senderType:"customer",content:"I want to talk to a real person about this. Can you connect me with your sales team?",createdAt:new Date(Date.now()-3e4).toISOString()}}),t.jsx(a,{...r,message:{...e,id:"4",senderId:"system",senderType:"system",content:"Connecting you with a team member who can help further...",messageType:"system",createdAt:new Date(Date.now()-25e3).toISOString()}}),t.jsx(a,{...r,message:{...e,id:"5",senderId:"sarah@xcelsior.co",senderType:"agent",content:"Hi there! I'm Sarah from our sales team. I'd love to discuss your custom web app project. Can you share a bit about the features you need and your timeline?",createdAt:new Date().toISOString()}})]}),args:{currentUser:s,showAvatar:!0,showTimestamp:!0}};var b,I,T,f,A;o.parameters={...o.parameters,docs:{...(b=o.parameters)==null?void 0:b.docs,source:{originalSource:`{
|
|
19
|
-
args: {
|
|
20
|
-
message: {
|
|
21
|
-
...baseMessage,
|
|
22
|
-
senderId: currentUser.email,
|
|
23
|
-
content: 'Hello, I need help with my account.'
|
|
24
|
-
},
|
|
25
|
-
currentUser,
|
|
26
|
-
showAvatar: true,
|
|
27
|
-
showTimestamp: true
|
|
28
|
-
}
|
|
29
|
-
}`,...(T=(I=o.parameters)==null?void 0:I.docs)==null?void 0:T.source},description:{story:"Customer message (own message)",...(A=(f=o.parameters)==null?void 0:f.docs)==null?void 0:A.description}}};var M,k,S,v,x;n.parameters={...n.parameters,docs:{...(M=n.parameters)==null?void 0:M.docs,source:{originalSource:`{
|
|
30
|
-
args: {
|
|
31
|
-
message: {
|
|
32
|
-
...baseMessage,
|
|
33
|
-
senderId: 'agent@example.com',
|
|
34
|
-
senderType: 'agent',
|
|
35
|
-
content: "Hi! I'd be happy to help you with your account. What issue are you experiencing?"
|
|
36
|
-
},
|
|
37
|
-
currentUser,
|
|
38
|
-
showAvatar: true,
|
|
39
|
-
showTimestamp: true
|
|
40
|
-
}
|
|
41
|
-
}`,...(S=(k=n.parameters)==null?void 0:k.docs)==null?void 0:S.source},description:{story:"Human agent message",...(x=(v=n.parameters)==null?void 0:v.docs)==null?void 0:x.description}}};var U,C,D,B,F;m.parameters={...m.parameters,docs:{...(U=m.parameters)==null?void 0:U.docs,source:{originalSource:`{
|
|
42
|
-
args: {
|
|
43
|
-
message: {
|
|
44
|
-
...baseMessage,
|
|
45
|
-
senderId: 'ai-assistant',
|
|
46
|
-
senderType: 'bot',
|
|
47
|
-
content: "Hello! I'm the Xcelsior assistant. Based on our knowledge base, here are some common solutions:\\n\\n1. Reset your password\\n2. Verify your email\\n3. Contact support\\n\\nWhich would you like help with?",
|
|
48
|
-
confidence: 0.85,
|
|
49
|
-
metadata: {
|
|
50
|
-
isAI: true,
|
|
51
|
-
kbUsed: true
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
currentUser,
|
|
55
|
-
showAvatar: true,
|
|
56
|
-
showTimestamp: true
|
|
57
|
-
}
|
|
58
|
-
}`,...(D=(C=m.parameters)==null?void 0:C.docs)==null?void 0:D.source},description:{story:"Bot message (AI assistant) — new senderType",...(F=(B=m.parameters)==null?void 0:B.docs)==null?void 0:F.description}}};var H,j,O,N,W;i.parameters={...i.parameters,docs:{...(H=i.parameters)==null?void 0:H.docs,source:{originalSource:`{
|
|
59
|
-
args: {
|
|
60
|
-
message: {
|
|
61
|
-
...baseMessage,
|
|
62
|
-
senderId: 'ai-assistant',
|
|
63
|
-
senderType: 'bot',
|
|
64
|
-
content: "I'm not entirely sure about this, but let me check with my team. In the meantime, you might want to visit our help center.",
|
|
65
|
-
confidence: 0.3,
|
|
66
|
-
metadata: {
|
|
67
|
-
isAI: true,
|
|
68
|
-
kbUsed: false
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
currentUser,
|
|
72
|
-
showAvatar: true,
|
|
73
|
-
showTimestamp: true
|
|
74
|
-
}
|
|
75
|
-
}`,...(O=(j=i.parameters)==null?void 0:j.docs)==null?void 0:O.source},description:{story:"Bot message with low confidence",...(W=(N=i.parameters)==null?void 0:N.docs)==null?void 0:W.description}}};var E,G,q,P,X;c.parameters={...c.parameters,docs:{...(E=c.parameters)==null?void 0:E.docs,source:{originalSource:`{
|
|
76
|
-
args: {
|
|
77
|
-
message: {
|
|
78
|
-
...baseMessage,
|
|
79
|
-
senderId: 'ai-assistant',
|
|
80
|
-
senderType: 'bot',
|
|
81
|
-
content: "You can reset your password by going to Settings > Security > Change Password.",
|
|
82
|
-
feedback: 'good',
|
|
83
|
-
confidence: 0.9,
|
|
84
|
-
metadata: {
|
|
85
|
-
isAI: true,
|
|
86
|
-
kbUsed: true
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
currentUser,
|
|
90
|
-
showAvatar: true,
|
|
91
|
-
showTimestamp: true
|
|
92
|
-
}
|
|
93
|
-
}`,...(q=(G=c.parameters)==null?void 0:G.docs)==null?void 0:q.source},description:{story:"Bot message with feedback (rated good)",...(X=(P=c.parameters)==null?void 0:P.docs)==null?void 0:X.description}}};var Y,J,R,L,V;d.parameters={...d.parameters,docs:{...(Y=d.parameters)==null?void 0:Y.docs,source:{originalSource:`{
|
|
94
|
-
args: {
|
|
95
|
-
message: {
|
|
96
|
-
...baseMessage,
|
|
97
|
-
senderId: 'ai-assistant',
|
|
98
|
-
senderType: 'bot',
|
|
99
|
-
content: "Your subscription expires on March 15th.",
|
|
100
|
-
feedback: 'wrong',
|
|
101
|
-
confidence: 0.6,
|
|
102
|
-
metadata: {
|
|
103
|
-
isAI: true,
|
|
104
|
-
kbUsed: true
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
currentUser,
|
|
108
|
-
showAvatar: true,
|
|
109
|
-
showTimestamp: true
|
|
110
|
-
}
|
|
111
|
-
}`,...(R=(J=d.parameters)==null?void 0:J.docs)==null?void 0:R.source},description:{story:"Bot message with feedback (rated wrong)",...(V=(L=d.parameters)==null?void 0:L.docs)==null?void 0:V.description}}};var _,z,K,Q,Z;p.parameters={...p.parameters,docs:{...(_=p.parameters)==null?void 0:_.docs,source:{originalSource:`{
|
|
112
|
-
args: {
|
|
113
|
-
message: {
|
|
114
|
-
...baseMessage,
|
|
115
|
-
senderId: 'ai-assistant',
|
|
116
|
-
senderType: 'bot',
|
|
117
|
-
content: \`## Getting Started
|
|
118
|
-
|
|
119
|
-
Here's how you can reset your password:
|
|
120
|
-
|
|
121
|
-
1. Go to the login page
|
|
122
|
-
2. Click on **"Forgot Password"**
|
|
123
|
-
3. Enter your email address
|
|
124
|
-
4. Check your inbox for the reset link
|
|
125
|
-
|
|
126
|
-
*Note: The link expires in 24 hours.*
|
|
127
|
-
|
|
128
|
-
For more help, visit our [support page](https://xcelsior.co/support).\`,
|
|
129
|
-
metadata: {
|
|
130
|
-
isAI: true,
|
|
131
|
-
kbUsed: true
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
currentUser,
|
|
135
|
-
showAvatar: true,
|
|
136
|
-
showTimestamp: true
|
|
137
|
-
}
|
|
138
|
-
}`,...(K=(z=p.parameters)==null?void 0:z.docs)==null?void 0:K.source},description:{story:"AI message with markdown formatting",...(Z=(Q=p.parameters)==null?void 0:Q.docs)==null?void 0:Z.description}}};var $,ee,se,te,ae;u.parameters={...u.parameters,docs:{...($=u.parameters)==null?void 0:$.docs,source:{originalSource:`{
|
|
139
|
-
args: {
|
|
140
|
-
message: {
|
|
141
|
-
...baseMessage,
|
|
142
|
-
senderId: 'system',
|
|
143
|
-
senderType: 'system',
|
|
144
|
-
content: 'Agent John joined the conversation',
|
|
145
|
-
messageType: 'system'
|
|
146
|
-
},
|
|
147
|
-
currentUser,
|
|
148
|
-
showAvatar: true,
|
|
149
|
-
showTimestamp: true
|
|
150
|
-
}
|
|
151
|
-
}`,...(se=(ee=u.parameters)==null?void 0:ee.docs)==null?void 0:se.source},description:{story:"System message — generic",...(ae=(te=u.parameters)==null?void 0:te.docs)==null?void 0:ae.description}}};var re,oe,ne,me,ie;g.parameters={...g.parameters,docs:{...(re=g.parameters)==null?void 0:re.docs,source:{originalSource:`{
|
|
152
|
-
args: {
|
|
153
|
-
message: {
|
|
154
|
-
...baseMessage,
|
|
155
|
-
senderId: 'system',
|
|
156
|
-
senderType: 'system',
|
|
157
|
-
content: 'Connecting you with a team member who can help further...',
|
|
158
|
-
messageType: 'system'
|
|
159
|
-
},
|
|
160
|
-
currentUser,
|
|
161
|
-
showAvatar: true,
|
|
162
|
-
showTimestamp: true
|
|
163
|
-
}
|
|
164
|
-
}`,...(ne=(oe=g.parameters)==null?void 0:oe.docs)==null?void 0:ne.source},description:{story:"System message — escalation notice",...(ie=(me=g.parameters)==null?void 0:me.docs)==null?void 0:ie.description}}};var ce,de,pe,ue,ge;h.parameters={...h.parameters,docs:{...(ce=h.parameters)==null?void 0:ce.docs,source:{originalSource:`{
|
|
165
|
-
args: {
|
|
166
|
-
message: {
|
|
167
|
-
...baseMessage,
|
|
168
|
-
senderId: 'system',
|
|
169
|
-
senderType: 'system',
|
|
170
|
-
content: 'Sarah from our team is here to help!',
|
|
171
|
-
messageType: 'system'
|
|
172
|
-
},
|
|
173
|
-
currentUser,
|
|
174
|
-
showAvatar: true,
|
|
175
|
-
showTimestamp: true
|
|
176
|
-
}
|
|
177
|
-
}`,...(pe=(de=h.parameters)==null?void 0:de.docs)==null?void 0:pe.source},description:{story:"System message — agent took over",...(ge=(ue=h.parameters)==null?void 0:ue.docs)==null?void 0:ge.description}}};var he,le,ye,we,be;l.parameters={...l.parameters,docs:{...(he=l.parameters)==null?void 0:he.docs,source:{originalSource:`{
|
|
178
|
-
args: {
|
|
179
|
-
message: {
|
|
180
|
-
...baseMessage,
|
|
181
|
-
content: 'https://picsum.photos/400/300',
|
|
182
|
-
messageType: 'image'
|
|
183
|
-
},
|
|
184
|
-
currentUser,
|
|
185
|
-
showAvatar: true,
|
|
186
|
-
showTimestamp: true
|
|
187
|
-
}
|
|
188
|
-
}`,...(ye=(le=l.parameters)==null?void 0:le.docs)==null?void 0:ye.source},description:{story:"Image message",...(be=(we=l.parameters)==null?void 0:we.docs)==null?void 0:be.description}}};var Ie,Te,fe,Ae,Me;y.parameters={...y.parameters,docs:{...(Ie=y.parameters)==null?void 0:Ie.docs,source:{originalSource:`{
|
|
189
|
-
args: {
|
|
190
|
-
message: {
|
|
191
|
-
...baseMessage,
|
|
192
|
-
content: 'https://example.com/document.pdf',
|
|
193
|
-
messageType: 'file',
|
|
194
|
-
metadata: {
|
|
195
|
-
fileName: 'Technical Documentation.pdf'
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
currentUser,
|
|
199
|
-
showAvatar: true,
|
|
200
|
-
showTimestamp: true
|
|
201
|
-
}
|
|
202
|
-
}`,...(fe=(Te=y.parameters)==null?void 0:Te.docs)==null?void 0:fe.source},description:{story:"File message",...(Me=(Ae=y.parameters)==null?void 0:Ae.docs)==null?void 0:Me.description}}};var ke,Se,ve,xe,Ue;w.parameters={...w.parameters,docs:{...(ke=w.parameters)==null?void 0:ke.docs,source:{originalSource:`{
|
|
203
|
-
render: args => <div className="flex flex-col gap-2 max-w-2xl p-4 bg-gray-950 rounded-lg">
|
|
204
|
-
<MessageItem {...args} message={{
|
|
205
|
-
...baseMessage,
|
|
206
|
-
id: '1',
|
|
207
|
-
senderId: currentUser.email,
|
|
208
|
-
senderType: 'customer',
|
|
209
|
-
content: 'Hi, I need help with pricing for a custom web app.'
|
|
210
|
-
}} />
|
|
211
|
-
<MessageItem {...args} message={{
|
|
212
|
-
...baseMessage,
|
|
213
|
-
id: '2',
|
|
214
|
-
senderId: 'ai-assistant',
|
|
215
|
-
senderType: 'bot',
|
|
216
|
-
content: "Hello! I'd be happy to help with pricing. At Xcelsior, we offer custom quotes based on your project requirements. Could you tell me more about what you're looking for?",
|
|
217
|
-
confidence: 0.8,
|
|
218
|
-
metadata: {
|
|
219
|
-
isAI: true,
|
|
220
|
-
kbUsed: true
|
|
221
|
-
},
|
|
222
|
-
createdAt: new Date(Date.now() - 60000).toISOString()
|
|
223
|
-
}} />
|
|
224
|
-
<MessageItem {...args} message={{
|
|
225
|
-
...baseMessage,
|
|
226
|
-
id: '3',
|
|
227
|
-
senderId: currentUser.email,
|
|
228
|
-
senderType: 'customer',
|
|
229
|
-
content: 'I want to talk to a real person about this. Can you connect me with your sales team?',
|
|
230
|
-
createdAt: new Date(Date.now() - 30000).toISOString()
|
|
231
|
-
}} />
|
|
232
|
-
<MessageItem {...args} message={{
|
|
233
|
-
...baseMessage,
|
|
234
|
-
id: '4',
|
|
235
|
-
senderId: 'system',
|
|
236
|
-
senderType: 'system',
|
|
237
|
-
content: 'Connecting you with a team member who can help further...',
|
|
238
|
-
messageType: 'system',
|
|
239
|
-
createdAt: new Date(Date.now() - 25000).toISOString()
|
|
240
|
-
}} />
|
|
241
|
-
<MessageItem {...args} message={{
|
|
242
|
-
...baseMessage,
|
|
243
|
-
id: '5',
|
|
244
|
-
senderId: 'sarah@xcelsior.co',
|
|
245
|
-
senderType: 'agent',
|
|
246
|
-
content: "Hi there! I'm Sarah from our sales team. I'd love to discuss your custom web app project. Can you share a bit about the features you need and your timeline?",
|
|
247
|
-
createdAt: new Date().toISOString()
|
|
248
|
-
}} />
|
|
249
|
-
</div>,
|
|
250
|
-
args: {
|
|
251
|
-
currentUser,
|
|
252
|
-
showAvatar: true,
|
|
253
|
-
showTimestamp: true
|
|
254
|
-
}
|
|
255
|
-
}`,...(ve=(Se=w.parameters)==null?void 0:Se.docs)==null?void 0:ve.source},description:{story:"Full conversation flow: customer → bot → escalation → agent",...(Ue=(xe=w.parameters)==null?void 0:xe.docs)==null?void 0:Ue.description}}};const Ne=["CustomerMessage","AgentMessage","BotMessage","BotMessageLowConfidence","BotMessageFeedbackGood","BotMessageFeedbackWrong","BotMessageWithMarkdown","SystemMessage","EscalationNotice","AgentTookOver","ImageMessage","FileMessage","FullConversationFlow"];export{n as AgentMessage,h as AgentTookOver,m as BotMessage,c as BotMessageFeedbackGood,d as BotMessageFeedbackWrong,i as BotMessageLowConfidence,p as BotMessageWithMarkdown,o as CustomerMessage,g as EscalationNotice,y as FileMessage,w as FullConversationFlow,l as ImageMessage,u as SystemMessage,Ne as __namedExportsOrder,Oe as default};
|