ordify-chat-widget 1.0.24 → 1.0.26
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/CHANGELOG.md +0 -11
- package/README.md +77 -0
- package/dist/components/Conversation.d.ts +2 -1
- package/dist/components/Conversation.d.ts.map +1 -1
- package/dist/components/EmbeddedChat.d.ts.map +1 -1
- package/dist/components/FloatingChat.d.ts.map +1 -1
- package/dist/components/InlineChat.d.ts.map +1 -1
- package/dist/components/styled/ChatComponents.d.ts +1 -3
- package/dist/components/styled/ChatComponents.d.ts.map +1 -1
- package/dist/hooks/useOrdifyChat.d.ts.map +1 -1
- package/dist/hooks/useOrdifyConfig.d.ts +3 -0
- package/dist/hooks/useOrdifyConfig.d.ts.map +1 -1
- package/dist/index.cjs.js +86 -179
- package/dist/index.esm.js +1265 -1696
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/api.d.ts +1 -1
- package/dist/utils/api.d.ts.map +1 -1
- package/package.json +4 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,17 +5,6 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.0.20] - 2025-01-27
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
- **BREAKING**: Moved `styled-components` from dependencies to peerDependencies to prevent React context conflicts
|
|
12
|
-
- Fixed `ReactCurrentOwner` error that occurred when multiple styled-components instances were present
|
|
13
|
-
- Added `@types/styled-components` and `babel-plugin-styled-components` to devDependencies for development
|
|
14
|
-
|
|
15
|
-
### Changed
|
|
16
|
-
- Applications using this widget must now install `styled-components` as a direct dependency
|
|
17
|
-
- This ensures only one styled-components instance exists, preventing React context conflicts
|
|
18
|
-
|
|
19
8
|
## [1.0.0] - 2024-01-16
|
|
20
9
|
|
|
21
10
|
### Added
|
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ function App() {
|
|
|
108
108
|
| `width` | string | "320px" | Chat width |
|
|
109
109
|
| `onSessionCreated` | function | - | **Optional** - Callback when a new session is created with session ID |
|
|
110
110
|
| `initialMessage` | string | - | **Optional** - Message to automatically send when chat loads |
|
|
111
|
+
| `initialContext` | string | - | **Optional** - Hidden system context sent to backend (user ID, page info, etc.) |
|
|
111
112
|
|
|
112
113
|
## 🎯 Advanced Features
|
|
113
114
|
|
|
@@ -125,6 +126,48 @@ The `initialMessage` prop allows you to automatically send a message when the ch
|
|
|
125
126
|
- **Onboarding**: Guide new users with initial instructions
|
|
126
127
|
- **A/B testing**: Test different conversation starters
|
|
127
128
|
|
|
129
|
+
### System Context (initialContext)
|
|
130
|
+
The `initialContext` prop allows you to send hidden system information to your AI agent without displaying it to users. This is perfect for:
|
|
131
|
+
- **User identification**: Send user ID, email, or subscription tier
|
|
132
|
+
- **Page context**: Include current page URL, product ID, or section
|
|
133
|
+
- **Session data**: Pass cart items, preferences, or previous interactions
|
|
134
|
+
- **Analytics**: Include tracking data, campaign sources, or A/B test groups
|
|
135
|
+
|
|
136
|
+
**Key Features**:
|
|
137
|
+
- **Hidden from users**: Context is sent to backend but never displayed in chat
|
|
138
|
+
- **Flexible scenarios**: Works with or without `initialMessage`
|
|
139
|
+
- **Backward compatible**: Existing usage without `initialContext` continues to work
|
|
140
|
+
|
|
141
|
+
**Usage Scenarios**:
|
|
142
|
+
|
|
143
|
+
1. **Both message and context**:
|
|
144
|
+
```tsx
|
|
145
|
+
<OrdifyChat
|
|
146
|
+
agentId="your-agent-id"
|
|
147
|
+
apiKey="your-api-key"
|
|
148
|
+
initialMessage="Help me with the Library page"
|
|
149
|
+
initialContext={`user_id: ${userId}, page: /library, tier: premium`}
|
|
150
|
+
/>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
2. **Context only** (auto-adds "Hi" greeting):
|
|
154
|
+
```tsx
|
|
155
|
+
<OrdifyChat
|
|
156
|
+
agentId="your-agent-id"
|
|
157
|
+
apiKey="your-api-key"
|
|
158
|
+
initialContext={`user_id: ${userId}, page: /checkout, cart_items: 3`}
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
3. **Message only** (backward compatible):
|
|
163
|
+
```tsx
|
|
164
|
+
<OrdifyChat
|
|
165
|
+
agentId="your-agent-id"
|
|
166
|
+
apiKey="your-api-key"
|
|
167
|
+
initialMessage="Hello!"
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
128
171
|
### Theme-Aware Defaults
|
|
129
172
|
|
|
130
173
|
When no `primaryColor` is specified, the header automatically adapts:
|
|
@@ -239,6 +282,40 @@ export function ChatWithInitialMessage() {
|
|
|
239
282
|
}
|
|
240
283
|
```
|
|
241
284
|
|
|
285
|
+
#### System Context Integration
|
|
286
|
+
```tsx
|
|
287
|
+
// components/ChatWithContext.tsx
|
|
288
|
+
import { OrdifyChat } from 'ordify-chat-widget'
|
|
289
|
+
import { useUser } from './hooks/useUser'
|
|
290
|
+
import { useRouter } from 'next/router'
|
|
291
|
+
|
|
292
|
+
export function ChatWithContext() {
|
|
293
|
+
const { user } = useUser()
|
|
294
|
+
const router = useRouter()
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<OrdifyChat
|
|
298
|
+
agentId="your-agent-id"
|
|
299
|
+
apiKey="your-api-key"
|
|
300
|
+
apiBaseUrl="https://r.ordify.ai"
|
|
301
|
+
mode="floating"
|
|
302
|
+
buttonText="Need Help?"
|
|
303
|
+
initialMessage={`Hi! I'm ${user?.name || 'a visitor'}, help me with this page.`}
|
|
304
|
+
initialContext={`user_id: ${user?.id}, email: ${user?.email}, page: ${router.pathname}, tier: ${user?.subscriptionTier || 'free'}`}
|
|
305
|
+
onSessionCreated={(sessionId) => {
|
|
306
|
+
console.log('Session created with context:', sessionId)
|
|
307
|
+
// Analytics tracking with user context
|
|
308
|
+
analytics.track('chat_session_started', {
|
|
309
|
+
sessionId,
|
|
310
|
+
userId: user?.id,
|
|
311
|
+
page: router.pathname
|
|
312
|
+
})
|
|
313
|
+
}}
|
|
314
|
+
/>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
242
319
|
#### Landing Page Integration
|
|
243
320
|
```tsx
|
|
244
321
|
// pages/index.tsx
|
|
@@ -3,6 +3,7 @@ import { default as React } from 'react';
|
|
|
3
3
|
interface ConversationProps {
|
|
4
4
|
className?: string;
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
+
style?: React.CSSProperties;
|
|
6
7
|
}
|
|
7
8
|
interface ConversationContentProps {
|
|
8
9
|
className?: string;
|
|
@@ -11,7 +12,7 @@ interface ConversationContentProps {
|
|
|
11
12
|
interface ConversationScrollButtonProps {
|
|
12
13
|
className?: string;
|
|
13
14
|
}
|
|
14
|
-
export declare function Conversation({ className, children }: ConversationProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function Conversation({ className, children, style }: ConversationProps): import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
export declare function ConversationContent({ className, children }: ConversationContentProps): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export declare function ConversationScrollButton({ className }: ConversationScrollButtonProps): false | import("react/jsx-runtime").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Conversation.d.ts","sourceRoot":"","sources":["../../src/components/Conversation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Conversation.d.ts","sourceRoot":"","sources":["../../src/components/Conversation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B;AAED,UAAU,wBAAwB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED,UAAU,6BAA6B;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAuDD,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,iBAAiB,2CAY7E;AAED,wBAAgB,mBAAmB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,wBAAwB,2CAMpF;AAED,wBAAgB,wBAAwB,CAAC,EAAE,SAAS,EAAE,EAAE,6BAA6B,mDAkBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedChat.d.ts","sourceRoot":"","sources":["../../src/components/EmbeddedChat.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAe3D,UAAU,iBAAiB;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"EmbeddedChat.d.ts","sourceRoot":"","sources":["../../src/components/EmbeddedChat.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAe3D,UAAU,iBAAiB;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,iBAAiB,2CAgH/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingChat.d.ts","sourceRoot":"","sources":["../../src/components/FloatingChat.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FloatingChat.d.ts","sourceRoot":"","sources":["../../src/components/FloatingChat.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAiB3D,UAAU,iBAAiB;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,iBAAiB,2CAiK/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineChat.d.ts","sourceRoot":"","sources":["../../src/components/InlineChat.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAe3D,UAAU,eAAe;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"InlineChat.d.ts","sourceRoot":"","sources":["../../src/components/InlineChat.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAe3D,UAAU,eAAe;IACvB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,eAAe,2CAmG3D"}
|
|
@@ -5,9 +5,7 @@ export declare const ChatMessage: import('styled-components/dist/types').IStyled
|
|
|
5
5
|
export declare const ChatInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
6
|
export declare const ProfessionalInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, never>> & string;
|
|
7
7
|
export declare const SendButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
8
|
-
export declare const FloatingButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components
|
|
9
|
-
$position: string;
|
|
10
|
-
}>> & string;
|
|
8
|
+
export declare const FloatingButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
11
9
|
export declare const ChatWindow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
12
10
|
$position: string;
|
|
13
11
|
}>> & string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatComponents.d.ts","sourceRoot":"","sources":["../../../src/components/styled/ChatComponents.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,6NAgBtB,CAAA;AAGD,eAAO,MAAM,WAAW;aAAyB,OAAO;YA8BvD,CAAA;AAGD,eAAO,MAAM,SAAS,6NAYrB,CAAA;AAGD,eAAO,MAAM,iBAAiB,+OA4C7B,CAAA;AAGD,eAAO,MAAM,UAAU,yOAgCtB,CAAA;AAGD,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"ChatComponents.d.ts","sourceRoot":"","sources":["../../../src/components/styled/ChatComponents.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,6NAgBtB,CAAA;AAGD,eAAO,MAAM,WAAW;aAAyB,OAAO;YA8BvD,CAAA;AAGD,eAAO,MAAM,SAAS,6NAYrB,CAAA;AAGD,eAAO,MAAM,iBAAiB,+OA4C7B,CAAA;AAGD,eAAO,MAAM,UAAU,yOAgCtB,CAAA;AAGD,eAAO,MAAM,cAAc,yOAgC1B,CAAA;AAGD,eAAO,MAAM,UAAU;eAA2B,MAAM;YAiCvD,CAAA;AAGD,eAAO,MAAM,UAAU;mBAA+B,MAAM;YAqB3D,CAAA;AAGD,eAAO,MAAM,WAAW,yOAqBvB,CAAA;AAGD,eAAO,MAAM,YAAY,6NAuCxB,CAAA;AAGD,eAAO,MAAM,WAAW,6NA+BvB,CAAA;AAGD,eAAO,MAAM,SAAS;aAAyB,OAAO;YAQrD,CAAA;AAGD,eAAO,MAAM,YAAY,6NAUxB,CAAA;AAGD,eAAO,MAAM,YAAY;eAA2B,MAAM;YAwBzD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrdifyChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdifyChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAKpE,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useOrdifyChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdifyChat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAKpE,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,mBAAmB,CA6JvE"}
|
|
@@ -13,10 +13,13 @@ export declare function useOrdifyConfig(config: OrdifyConfig): {
|
|
|
13
13
|
buttonStyle: import('react').CSSProperties;
|
|
14
14
|
chatWindowStyle: import('react').CSSProperties;
|
|
15
15
|
showHeader: boolean;
|
|
16
|
+
buttonText: string | undefined;
|
|
17
|
+
chatName: string | undefined;
|
|
16
18
|
onMessage: ((message: import('../types').Message) => void) | undefined;
|
|
17
19
|
onError: ((error: Error) => void) | undefined;
|
|
18
20
|
onClose: (() => void) | undefined;
|
|
19
21
|
onSessionCreated: ((sessionId: string) => void) | undefined;
|
|
20
22
|
initialMessage: string | undefined;
|
|
23
|
+
initialContext: string | undefined;
|
|
21
24
|
};
|
|
22
25
|
//# sourceMappingURL=useOrdifyConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOrdifyConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdifyConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY
|
|
1
|
+
{"version":3,"file":"useOrdifyConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useOrdifyConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;EAsCnD"}
|