@onedeskpro/chatbot-core 0.2.1 → 0.3.1
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 +6 -2
- package/dist/index.cjs +254 -23
- package/dist/index.d.cts +110 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.iife.js +254 -23
- package/dist/index.js +1332 -477
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -97,6 +97,8 @@ The IIFE build exposes a `window.OnedeskProChatbot` global:
|
|
|
97
97
|
| `init(options)` | Mounts the widget and loads remote config. Returns a promise. |
|
|
98
98
|
| `submitIdentify({ name, phone, email? })` | Identifies the visitor and unlocks the chat. Returns a promise. |
|
|
99
99
|
| `sendMessage(text)` | Sends a message and, in `ai` mode, appends the reply. Returns a promise that rejects if the visitor has not identified. |
|
|
100
|
+
| `sendAttachments(files, text?)` | Sends up to 10 files (10 MB each) as one media message, with `text` as the caption. Each file is uploaded through the API first; the message sits in `messages` with `pending: true` and local previews until then. Rejects if the visitor has not identified; a file over the limits sets `error` instead. |
|
|
101
|
+
| `sendVoice(recording)` | Sends a voice note. `recording` is `{ blob, mimeType?, durationSeconds }`, as `VoiceRecorder` produces; it is re-encoded as mono WAV with a waveform where Web Audio allows, uploaded, and stored as a `voice` message. Rejects if the visitor has not identified. |
|
|
100
102
|
| `requestHuman()` | Escalates the conversation to a human agent. Does nothing unless the mode is `ai` and a conversation has started. Returns a promise. |
|
|
101
103
|
| `open()` / `close()` / `toggle()` | Control widget visibility. |
|
|
102
104
|
| `resetSession()` | Clears a `closed` conversation so the visitor can start a new one. Does nothing in any other mode. |
|
|
@@ -130,7 +132,7 @@ The IIFE build exposes a `window.OnedeskProChatbot` global:
|
|
|
130
132
|
| `isReady` | `boolean` | The server answered and the agent can reply; the widget is on the page. |
|
|
131
133
|
| `needsIdentify` | `boolean` | The visitor has not identified yet. |
|
|
132
134
|
| `blockReason` | `ChatbotBlockReason` | Why the agent cannot answer, or `null`. See [When the widget appears](#when-the-widget-appears). |
|
|
133
|
-
| `messages` | `ChatMessage[]` | The conversation so far. `message.type` is `'human'`, `'ai'`, or `'agent'`. |
|
|
135
|
+
| `messages` | `ChatMessage[]` | The conversation so far. `message.type` is `'human'`, `'ai'`, or `'agent'`. A media message carries `message.attachments` (`type`, `url`, `fileName`, `size`) and `pending: true` while its files upload. |
|
|
134
136
|
| `visitorToken` | `string \| null` | The identified visitor's token. |
|
|
135
137
|
| `visitorName` | `string \| null` | The identified visitor's name. |
|
|
136
138
|
| `mode` | `ChatbotTicketMode` | `'ai'`, `'waiting'`, `'human'`, or `'closed'`. |
|
|
@@ -158,7 +160,9 @@ off(); // unsubscribe
|
|
|
158
160
|
|
|
159
161
|
## Also exported
|
|
160
162
|
|
|
161
|
-
`ApiClient`, `SdkSocket`, `resolveSdkSocketUrl`, `EventEmitter`, `SessionManager`, `isChatbotRequestError`, `DEFAULT_API_BASE_URL`, `DEFAULT_REQUEST_TIMEOUT_MS`, the `ChatbotRequestError` and `
|
|
163
|
+
`ApiClient`, `SdkSocket`, `resolveSdkSocketUrl`, `EventEmitter`, `SessionManager`, `VoiceRecorder`, `isChatbotRequestError`, `DEFAULT_API_BASE_URL`, `DEFAULT_REQUEST_TIMEOUT_MS`, `SDK_UPLOAD_MAX_BYTES`, `SDK_CHAT_MAX_ATTACHMENTS`, `VOICE_MAX_DURATION_SECONDS`, the `ChatbotRequestError`, `SdkSocketConnectOptions`, `VoiceRecorderSnapshot` and `VoiceRecorderState` types, and every type from `@onedeskpro/chatbot-types`.
|
|
164
|
+
|
|
165
|
+
`VoiceRecorder` records with `MediaRecorder` for custom UIs: `new VoiceRecorder(onChange)`, then `start()`, `stop()` (resolves with the recording to pass to `sendVoice`), `cancel()`, and `destroy()`. `onChange` receives `{ state, elapsedSeconds, level, result }`. Recording stops on its own at `VOICE_MAX_DURATION_SECONDS` (5 minutes).
|
|
162
166
|
|
|
163
167
|
`SessionManager` is deprecated. It is now the visitor token store and is kept only so existing imports keep resolving.
|
|
164
168
|
|