@botpress/webchat 2.1.13 → 2.1.15
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/.turbo/turbo-build.log +5 -5
- package/dist/client/PushpinClient/index.d.ts +2 -2
- package/dist/client/types.d.ts +6 -7
- package/dist/index.js +2008 -1984
- package/dist/index.umd.cjs +41 -41
- package/dist/schemas/init.d.ts +22 -0
- package/dist/stores/webchatStore.d.ts +2 -0
- package/package.json +1 -1
- package/readme.md +56 -0
package/dist/schemas/init.d.ts
CHANGED
|
@@ -2,10 +2,16 @@
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export declare const statePropsSchema: z.ZodEnum<["opened", "closed", "initial"]>;
|
|
4
4
|
export declare const userPropsSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodOptional<z.ZodString>;
|
|
6
|
+
pictureUrl: z.ZodOptional<z.ZodString>;
|
|
5
7
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
6
8
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
pictureUrl?: string | undefined;
|
|
7
11
|
data?: Record<string, unknown> | undefined;
|
|
8
12
|
}, {
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
pictureUrl?: string | undefined;
|
|
9
15
|
data?: Record<string, unknown> | undefined;
|
|
10
16
|
}>;
|
|
11
17
|
export declare const clientModePropsSchema: z.ZodEnum<["messaging", "pushpin"]>;
|
|
@@ -3728,10 +3734,16 @@ export declare const configPropsSchema: z.ZodObject<{
|
|
|
3728
3734
|
}>>>;
|
|
3729
3735
|
style: z.ZodCatch<z.ZodOptional<z.ZodString>>;
|
|
3730
3736
|
user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
3737
|
+
name: z.ZodOptional<z.ZodString>;
|
|
3738
|
+
pictureUrl: z.ZodOptional<z.ZodString>;
|
|
3731
3739
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3732
3740
|
}, "strip", z.ZodTypeAny, {
|
|
3741
|
+
name?: string | undefined;
|
|
3742
|
+
pictureUrl?: string | undefined;
|
|
3733
3743
|
data?: Record<string, unknown> | undefined;
|
|
3734
3744
|
}, {
|
|
3745
|
+
name?: string | undefined;
|
|
3746
|
+
pictureUrl?: string | undefined;
|
|
3735
3747
|
data?: Record<string, unknown> | undefined;
|
|
3736
3748
|
}>>>;
|
|
3737
3749
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -4185,6 +4197,8 @@ export declare const configPropsSchema: z.ZodObject<{
|
|
|
4185
4197
|
} | undefined;
|
|
4186
4198
|
style?: string | undefined;
|
|
4187
4199
|
user?: {
|
|
4200
|
+
name?: string | undefined;
|
|
4201
|
+
pictureUrl?: string | undefined;
|
|
4188
4202
|
data?: Record<string, unknown> | undefined;
|
|
4189
4203
|
} | undefined;
|
|
4190
4204
|
}, {
|
|
@@ -7912,10 +7926,16 @@ export declare const initPropsSchema: z.ZodObject<{
|
|
|
7912
7926
|
} | undefined;
|
|
7913
7927
|
}>>>;
|
|
7914
7928
|
user: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
7929
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7930
|
+
pictureUrl: z.ZodOptional<z.ZodString>;
|
|
7915
7931
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7916
7932
|
}, "strip", z.ZodTypeAny, {
|
|
7933
|
+
name?: string | undefined;
|
|
7934
|
+
pictureUrl?: string | undefined;
|
|
7917
7935
|
data?: Record<string, unknown> | undefined;
|
|
7918
7936
|
}, {
|
|
7937
|
+
name?: string | undefined;
|
|
7938
|
+
pictureUrl?: string | undefined;
|
|
7919
7939
|
data?: Record<string, unknown> | undefined;
|
|
7920
7940
|
}>>>;
|
|
7921
7941
|
clientId: z.ZodString;
|
|
@@ -8380,6 +8400,8 @@ export declare const initPropsSchema: z.ZodObject<{
|
|
|
8380
8400
|
} | undefined;
|
|
8381
8401
|
} | undefined;
|
|
8382
8402
|
user?: {
|
|
8403
|
+
name?: string | undefined;
|
|
8404
|
+
pictureUrl?: string | undefined;
|
|
8383
8405
|
data?: Record<string, unknown> | undefined;
|
|
8384
8406
|
} | undefined;
|
|
8385
8407
|
selector?: string | undefined;
|
|
@@ -16,6 +16,8 @@ export type WebchatProps = {
|
|
|
16
16
|
lastTypingHeartbeat: Date | null;
|
|
17
17
|
allowFileUpload: boolean;
|
|
18
18
|
userData: Record<string, unknown>;
|
|
19
|
+
userName?: string;
|
|
20
|
+
userPictureUrl?: string;
|
|
19
21
|
messageContainerRef: RefObject<HTMLDivElement>;
|
|
20
22
|
closeWindow?: () => void;
|
|
21
23
|
/**
|
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Webchat
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @botpress/webchat # for npm
|
|
7
|
+
yarn add @botpress/webchat # for yarn
|
|
8
|
+
pnpm add @botpress/webchat # for pnpm
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useEffect, useState } from 'react'
|
|
15
|
+
import { getClient, Webchat, WebchatProvider, WebchatClient, Configuration } from '@botpress/webchat'
|
|
16
|
+
|
|
17
|
+
// also known as the webhookId; You can copy it from the Botpress Dashboard
|
|
18
|
+
const clientId = '$CLIENT_ID'
|
|
19
|
+
|
|
20
|
+
const userData = { foo: 'bar' }
|
|
21
|
+
const configuration: Configuration = {
|
|
22
|
+
botAvatar: 'https://upload.wikimedia.org/wikipedia/commons/9/91/T-bone-raw-MCB.jpg',
|
|
23
|
+
botDescription: 'Hello, world!',
|
|
24
|
+
botName: 'Hello Bot',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
const [client, setClient] = useState<WebchatClient | null>(null)
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const client = getClient({ clientId })
|
|
32
|
+
setClient(client)
|
|
33
|
+
|
|
34
|
+
// You can listen on events sent by the Webchat backend like this:
|
|
35
|
+
client.on('*', (ev) => {
|
|
36
|
+
console.log('Event:', ev)
|
|
37
|
+
|
|
38
|
+
// You can also call the Webchat backend API like this:
|
|
39
|
+
client.getUser().then((user) => {
|
|
40
|
+
console.log('User:', user)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}, [])
|
|
44
|
+
|
|
45
|
+
if (!client) {
|
|
46
|
+
return <div>Loading...</div>
|
|
47
|
+
}
|
|
48
|
+
return (
|
|
49
|
+
<WebchatProvider theme={{}} client={client} configuration={configuration} userData={userData}>
|
|
50
|
+
<Webchat />
|
|
51
|
+
</WebchatProvider>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default App
|
|
56
|
+
```
|