@opencx/widget 3.0.100 → 4.0.17
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 +3 -73
- package/dist-embed/script.js +151 -194
- package/dist-embed/script.js.map +1 -1
- package/package.json +11 -173
- package/dist/designs.cjs +0 -79
- package/dist/designs.cjs.map +0 -1
- package/dist/designs.d.ts +0 -2
- package/dist/designs.js +0 -17770
- package/dist/designs.js.map +0 -1
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/is-exhaustive-9o43S91P.cjs +0 -2
- package/dist/is-exhaustive-9o43S91P.cjs.map +0 -1
- package/dist/is-exhaustive-DGJzQK69.js +0 -7
- package/dist/is-exhaustive-DGJzQK69.js.map +0 -1
- package/dist/react.cjs +0 -2
- package/dist/react.cjs.map +0 -1
- package/dist/react.d.ts +0 -2
- package/dist/react.js +0 -34
- package/dist/react.js.map +0 -1
- package/dist/src/designs/react/WidgetPopoverAnchor.d.ts +0 -2
- package/dist/src/designs/react/WidgetPopoverContent.d.ts +0 -3
- package/dist/src/designs/react/WidgetPopoverTrigger.d.ts +0 -3
- package/dist/src/designs/react/components/AgentOrBotAvatar.d.ts +0 -6
- package/dist/src/designs/react/components/AttachmentPreview.d.ts +0 -7
- package/dist/src/designs/react/components/BotOrAgentMessage.d.ts +0 -7
- package/dist/src/designs/react/components/BotOrAgentMessageGroup.d.ts +0 -7
- package/dist/src/designs/react/components/Header.d.ts +0 -3
- package/dist/src/designs/react/components/MightSolveUserIssueSuggestedReplies.d.ts +0 -2
- package/dist/src/designs/react/components/PoweredByOpen.d.ts +0 -4
- package/dist/src/designs/react/components/SuggestedReplyButton.d.ts +0 -5
- package/dist/src/designs/react/components/UserMessage.d.ts +0 -8
- package/dist/src/designs/react/components/UserMessageGroup.d.ts +0 -5
- package/dist/src/designs/react/components/VoteButtons.d.ts +0 -8
- package/dist/src/designs/react/components/custom-components/BotOrAgentTextResponse.component.d.ts +0 -16
- package/dist/src/designs/react/components/custom-components/Fallback.component.d.ts +0 -6
- package/dist/src/designs/react/components/custom-components/Handoff.component.d.ts +0 -3
- package/dist/src/designs/react/components/custom-components/Loading.component.d.ts +0 -6
- package/dist/src/designs/react/components/lib/DynamicIcon.d.ts +0 -6
- package/dist/src/designs/react/components/lib/LoadingSpinner.d.ts +0 -4
- package/dist/src/designs/react/components/lib/MotionDiv.d.ts +0 -19
- package/dist/src/designs/react/components/lib/avatar.d.ts +0 -6
- package/dist/src/designs/react/components/lib/button.d.ts +0 -11
- package/dist/src/designs/react/components/lib/dialog.d.ts +0 -24
- package/dist/src/designs/react/components/lib/dropdown-menu.d.ts +0 -27
- package/dist/src/designs/react/components/lib/input.d.ts +0 -4
- package/dist/src/designs/react/components/lib/popover.d.ts +0 -8
- package/dist/src/designs/react/components/lib/skeleton.d.ts +0 -3
- package/dist/src/designs/react/components/lib/switch.d.ts +0 -4
- package/dist/src/designs/react/components/lib/tooltip.d.ts +0 -10
- package/dist/src/designs/react/components/lib/utils/cn.d.ts +0 -2
- package/dist/src/designs/react/components/lib/widget-portal.d.ts +0 -9
- package/dist/src/designs/react/components/lib/wobble.d.ts +0 -26
- package/dist/src/designs/react/components/markdown.d.ts +0 -3
- package/dist/src/designs/react/components/svg/ChatBubbleSvg.d.ts +0 -5
- package/dist/src/designs/react/components/svg/OpenLogoSvg.d.ts +0 -4
- package/dist/src/designs/react/hooks/useCanvas.d.ts +0 -3
- package/dist/src/designs/react/hooks/useIsSmallScreen.d.ts +0 -3
- package/dist/src/designs/react/hooks/useLocale.d.ts +0 -6
- package/dist/src/designs/react/hooks/useSetWidgetSize.d.ts +0 -8
- package/dist/src/designs/react/hooks/useTheme.d.ts +0 -62
- package/dist/src/designs/react/hooks/useWidgetContentHeight.d.ts +0 -3
- package/dist/src/designs/react/index.d.ts +0 -9
- package/dist/src/designs/react/screens/chat/ChatCanvas.d.ts +0 -2
- package/dist/src/designs/react/screens/chat/ChatFooter.d.ts +0 -2
- package/dist/src/designs/react/screens/chat/ChatMain.d.ts +0 -2
- package/dist/src/designs/react/screens/chat/index.d.ts +0 -2
- package/dist/src/designs/react/screens/index.d.ts +0 -2
- package/dist/src/designs/react/screens/sessions/index.d.ts +0 -2
- package/dist/src/designs/react/screens/welcome/index.d.ts +0 -2
- package/dist/src/designs/react/utils/data-component.d.ts +0 -7
- package/dist/src/designs/react/utils/group-messages-by-type.d.ts +0 -5
- package/dist/src/designs/translation/ar.locale.d.ts +0 -2
- package/dist/src/designs/translation/de.locale.d.ts +0 -2
- package/dist/src/designs/translation/en.locale.d.ts +0 -2
- package/dist/src/designs/translation/es.locale.d.ts +0 -2
- package/dist/src/designs/translation/fr.locale.d.ts +0 -2
- package/dist/src/designs/translation/index.d.ts +0 -16
- package/dist/src/designs/translation/nl.locale.d.ts +0 -2
- package/dist/src/designs/translation/pt.locale.d.ts +0 -2
- package/dist/src/designs/translation/tr.locale.d.ts +0 -2
- package/dist/src/designs/translation/translation.types.d.ts +0 -4
- package/dist/src/embedded/index.d.ts +0 -11
- package/dist/src/headless/core/__tests__/api-caller.mock.d.ts +0 -1
- package/dist/src/headless/core/__tests__/context/contact/auth/auto-create-unverified-anonymous.spec.d.ts +0 -0
- package/dist/src/headless/core/__tests__/context/contact/auth/auto-create-unverified-with-user-data-provided-by-org.spec.d.ts +0 -0
- package/dist/src/headless/core/__tests__/context/contact/auth/manually-create-unverified-with-user-data-provided-by-user.spec.d.ts +0 -0
- package/dist/src/headless/core/__tests__/context/contact/auth/with-secure-token.spec.d.ts +0 -0
- package/dist/src/headless/core/__tests__/context/contact/should-collect-data.spec.d.ts +0 -0
- package/dist/src/headless/core/__tests__/test-utils.d.ts +0 -419
- package/dist/src/headless/core/__tests__/utils/Poller.spec.d.ts +0 -1
- package/dist/src/headless/core/__tests__/utils/PrimitiveState.spec.d.ts +0 -1
- package/dist/src/headless/core/__tests__/utils/uuid.spec.d.ts +0 -1
- package/dist/src/headless/core/api/api-caller.d.ts +0 -437
- package/dist/src/headless/core/api/client.d.ts +0 -12
- package/dist/src/headless/core/api/schema.d.ts +0 -928
- package/dist/src/headless/core/context/active-session-polling.ctx.d.ts +0 -25
- package/dist/src/headless/core/context/contact.ctx.d.ts +0 -30
- package/dist/src/headless/core/context/message.ctx.d.ts +0 -38
- package/dist/src/headless/core/context/router.ctx.d.ts +0 -33
- package/dist/src/headless/core/context/session.ctx.d.ts +0 -119
- package/dist/src/headless/core/context/storage.ctx.d.ts +0 -15
- package/dist/src/headless/core/context/widget.ctx.d.ts +0 -27
- package/dist/src/headless/core/index.d.ts +0 -15
- package/dist/src/headless/core/types/agent-or-bot.d.ts +0 -6
- package/dist/src/headless/core/types/component-name.d.ts +0 -1
- package/dist/src/headless/core/types/dtos.d.ts +0 -12
- package/dist/src/headless/core/types/external-storage.d.ts +0 -5
- package/dist/src/headless/core/types/helpers.d.ts +0 -2
- package/dist/src/headless/core/types/icons.d.ts +0 -3
- package/dist/src/headless/core/types/json-value.d.ts +0 -7
- package/dist/src/headless/core/types/messages.d.ts +0 -55
- package/dist/src/headless/core/types/widget-config.d.ts +0 -400
- package/dist/src/headless/core/utils/Poller.d.ts +0 -12
- package/dist/src/headless/core/utils/PrimitiveState.d.ts +0 -13
- package/dist/src/headless/core/utils/is-exhaustive.d.ts +0 -1
- package/dist/src/headless/core/utils/run-catching.d.ts +0 -13
- package/dist/src/headless/core/utils/uuid.d.ts +0 -1
- package/dist/src/headless/react/ComponentRegistry.d.ts +0 -10
- package/dist/src/headless/react/WidgetProvider.d.ts +0 -25
- package/dist/src/headless/react/hooks/useConfig.d.ts +0 -1
- package/dist/src/headless/react/hooks/useContact.d.ts +0 -12
- package/dist/src/headless/react/hooks/useDocumentDir.d.ts +0 -3
- package/dist/src/headless/react/hooks/useIsAwaitingBotReply.d.ts +0 -3
- package/dist/src/headless/react/hooks/useMessages.d.ts +0 -14
- package/dist/src/headless/react/hooks/useModes.d.ts +0 -15
- package/dist/src/headless/react/hooks/usePreludeData.d.ts +0 -38
- package/dist/src/headless/react/hooks/usePrimitiveState.d.ts +0 -2
- package/dist/src/headless/react/hooks/useSessions.d.ts +0 -104
- package/dist/src/headless/react/hooks/useUploadFiles.d.ts +0 -21
- package/dist/src/headless/react/hooks/useVote.d.ts +0 -18
- package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +0 -7
- package/dist/src/headless/react/hooks/useWidgetTrigger.d.ts +0 -10
- package/dist/src/headless/react/index.d.ts +0 -14
- package/dist/src/headless/react/types/components.d.ts +0 -7
- package/dist/useModes-B1EFXU-e.cjs +0 -2
- package/dist/useModes-B1EFXU-e.cjs.map +0 -1
- package/dist/useModes-BCCAwNcR.js +0 -259
- package/dist/useModes-BCCAwNcR.js.map +0 -1
- package/dist/widget.ctx-B-jCTG4Y.js +0 -698
- package/dist/widget.ctx-B-jCTG4Y.js.map +0 -1
- package/dist/widget.ctx-XvIjOOOZ.cjs +0 -5
- package/dist/widget.ctx-XvIjOOOZ.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,75 +1,5 @@
|
|
|
1
|
-
# OpenCX Widget
|
|
1
|
+
# OpenCX Widget - Embed
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The default React widget. Embeddable in HTML.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<head>
|
|
9
|
-
<script src="https://unpkg.com/@opencx/widget@latest/dist-embed/script.js"></script>
|
|
10
|
-
<script>
|
|
11
|
-
const options = {
|
|
12
|
-
token: 'your-token-here',
|
|
13
|
-
};
|
|
14
|
-
window.addEventListener('DOMContentLoaded', () => {
|
|
15
|
-
initOpenScript(options);
|
|
16
|
-
});
|
|
17
|
-
</script>
|
|
18
|
-
</head>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### Default React Widget
|
|
22
|
-
|
|
23
|
-
Install the package:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm add @opencx/widget
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Render the widget:
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
import { Widget } from '@opencx/widget/designs';
|
|
33
|
-
|
|
34
|
-
function YourComponent() {
|
|
35
|
-
return (
|
|
36
|
-
<Widget
|
|
37
|
-
options={{
|
|
38
|
-
token: 'your-token-here',
|
|
39
|
-
}}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Framework-Agnostic Headless Widget
|
|
46
|
-
|
|
47
|
-
The core package exports the widget engine that can be used with any framework:
|
|
48
|
-
|
|
49
|
-
- Check the [`React` adapter](https://github.com/openchatai/widget/tree/main/src/headless/react) on how to attach the widget engine to a framework.
|
|
50
|
-
- Check the [default `React` widget](https://github.com/openchatai/widget/tree/main/src/designs/react) on how to use the engine; collecting user data, navigating between screens, sending messages, handling loading states, etc.
|
|
51
|
-
|
|
52
|
-
## Widget Options
|
|
53
|
-
|
|
54
|
-
- [Available options](https://github.com/openchatai/widget/tree/main/src/headless/core/types/widget-config.ts)
|
|
55
|
-
- [Usage example](https://github.com/openchatai/widget/tree/main/index.tsx)
|
|
56
|
-
|
|
57
|
-
## Authentication
|
|
58
|
-
|
|
59
|
-
The widget supports a variety of ways to authenticate, or not, your users:
|
|
60
|
-
|
|
61
|
-
1. **Completely anonymous**: Leave `WidgetConfig.collectUserData` and `WidgetConfig.user` empty or explicitly `undefined`
|
|
62
|
-
2. **Manually collect user data**: Pass `WidgetConfig.collectUserData` as `true`
|
|
63
|
-
- Users will have to input a `name` and an `email` to enter the chat.
|
|
64
|
-
- A contact will be created with the inputted email. But the session will be considered `unverified`, since the user can input any `email`.
|
|
65
|
-
- The user will be saved in `localStorage` and they won't have to input a `name` and `email` on future visits.
|
|
66
|
-
3. **Programmatically pass user data**: Populate `WidgetConfig.user.data` with a `name` and `email`
|
|
67
|
-
- The session will still be considered `unverified`, because malicious users can still intercept outgoing browser requests and tamper with the user data
|
|
68
|
-
- If `WidgetConfig.collectUserData` is `true` and `WidgetConfig.user.data.email` was also passed, the `email` will take precedence and `collectUserData` will be ignored.
|
|
69
|
-
4. **Secure authentication**: Get a `token` for your user by letting your backend hit a request to `api.open.cx/widget/authenticate-user` ([API reference](https://docs.open.cx/api-reference/widget/authenticate-contact)) and pass the token in `WidgetConfig.user.token`
|
|
70
|
-
- The session will be `verified`, so your human agents can share private data with the user (in case the session was handed-over to humans)
|
|
71
|
-
- `customData` in the authentication request will be saved, since contacts have no way to tamper with them
|
|
72
|
-
|
|
73
|
-
## Workspace Management
|
|
74
|
-
|
|
75
|
-
If you support multiple workspaces per user or contact, you can pass the user's workspace id in `WidgetConfig.user.externalId`. This way, sessions will be scoped by that external id.
|
|
5
|
+
For more information, check [the documentation](https://docs.open.cx/widget/getting-started)
|