@wakflo/react 0.0.0-stage → 0.1.0

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
@@ -1,3 +1,91 @@
1
- # Temporary Holding Version
1
+ # @wakflo/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Wakflo website chat for React. `<WakfloChat />` is the ready chat bubble:
4
+ your bot answers, and when it can't help or the visitor asks for a person, the
5
+ chat lands on your team's Conversations page and whoever takes it answers in
6
+ the same bubble, live. `useWakfloChat` is the same chat without a UI, for
7
+ teams that want to draw their own.
8
+
9
+ Built on [`@wakflo/client`](https://www.npmjs.com/package/@wakflo/client).
10
+ Works with React 18 and 19.
11
+
12
+ ## Install
13
+
14
+ ```sh
15
+ npm install @wakflo/react
16
+ ```
17
+
18
+ ## The bubble
19
+
20
+ Add your site to the chat's allowed sites in Wakflo, copy the publishable key,
21
+ and then:
22
+
23
+ ```tsx
24
+ import { WakfloChat } from "@wakflo/react";
25
+ import "@wakflo/react/styles.css";
26
+
27
+ <WakfloChat
28
+ publishableKey="pk_live_…"
29
+ suggestions={["What does it cost?", "Do you have an API?"]}
30
+ />
31
+ ```
32
+
33
+ It reads its title, greeting, suggestions and theme from the chat's settings
34
+ in Wakflo. Props override them:
35
+
36
+ | Prop | |
37
+ |---|---|
38
+ | `publishableKey` | Required. |
39
+ | `baseUrl` | Where the Wakflo API lives. Defaults to `https://api.wakflo.com`; set it for staging, a self-hosted API, or a proxy path on your own domain. `apiUrl` is the old name and still works. |
40
+ | `title`, `greeting`, `suggestions` | The bubble's name, its first message, and the questions offered until the first message. |
41
+ | `theme` | `light`, `dark` or `system`. |
42
+ | `accent` | Any css colour. |
43
+ | `position` | `bottom-right` (the default) or `bottom-left`. |
44
+ | `defaultOpen` | Start open. |
45
+ | `placeholder` | The message box's placeholder. |
46
+ | `renderTool` | `(call, respond) => ReactNode` for frontend tools you add yourself. Return `undefined` to leave a call to the bubble. |
47
+ | `className` | Added to the root. |
48
+
49
+ ⌘J (Ctrl+J elsewhere) opens and closes it, and Escape closes it. Below 480px
50
+ wide the open panel takes the whole screen.
51
+
52
+ The bubble draws the `contact_form` tool itself, as a form built from the
53
+ tool call's fields, and declines tools nothing draws so a run never hangs.
54
+
55
+ ### Styling
56
+
57
+ Everything is scoped under `.wakflo-chat` and coloured by custom properties,
58
+ so it needs no Tailwind and doesn't touch the rest of your page. Override any
59
+ of them:
60
+
61
+ ```css
62
+ .wakflo-chat {
63
+ --wakflo-accent: #4f46e5;
64
+ --wakflo-on-accent: #fff;
65
+ --wakflo-font: Inter, sans-serif;
66
+ --wakflo-offset: 24px;
67
+ }
68
+ ```
69
+
70
+ The others are `--wakflo-bg`, `--wakflo-fg`, `--wakflo-muted`,
71
+ `--wakflo-muted-fg`, `--wakflo-border`, `--wakflo-accent-ink`,
72
+ `--wakflo-danger`, `--wakflo-shadow`, `--wakflo-mono`, `--wakflo-width`,
73
+ `--wakflo-height` and `--wakflo-z`.
74
+
75
+ ## Your own UI
76
+
77
+ ```tsx
78
+ const { messages, send, status, handover, toolCall, respond } = useWakfloChat({
79
+ publishableKey: "pk_live_…",
80
+ });
81
+ ```
82
+
83
+ The hook also returns `config`, `conversation`, `typing`, `pendingTool` (the
84
+ same as `toolCall`), `notices`, `connection`, `error`, `setEmail`, `reset`,
85
+ `open` and `setOpen`, and the underlying `chat` and `client`.
86
+ `respond(callId, result, error?)` answers one call of the pending frontend
87
+ tool run; the answers go to the server together once every call has one.
88
+
89
+ ## License
90
+
91
+ MIT