@onedeskpro/chatbot-types 0.2.0 → 0.3.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
@@ -20,7 +20,7 @@ npm install --save-dev @onedeskpro/chatbot-types
20
20
  | `ChatbotEventMap` | Event names mapped to payloads, including `state-change`, `ticket-status`, and `human-requested`. |
21
21
  | `ChatbotTicketMode` | Who owns the conversation (`'ai' \| 'waiting' \| 'human' \| 'closed'`). |
22
22
  | `TicketStatusData` | Mode plus optional `conversationId` and `agentName`. Shared by the human-request and ticket-status endpoints and the `ticket:status` socket event. |
23
- | `ChatbotBlockReason` | Why a bot is not ready (`'no-prompt' \| 'no-collections' \| 'no-directories' \| 'no-agent' \| null`). |
23
+ | `ChatbotBlockReason` | Why a bot is not ready, or `null`: `'no-prompt'`, `'no-collections'`, `'ai-unavailable'`, `'no-credits'`, `'no-agent'`, `'server-unavailable'`, or the legacy `'no-directories'`. |
24
24
  | `SdkConfigResponse` | Remote agent configuration and readiness. |
25
25
  | `IdentifyRequest` / `IdentifyResponseData` | Identify endpoint request and response bodies. |
26
26
  | `VisitorVerifyResponse` | Result of verifying a stored visitor token. |
package/dist/index.d.cts CHANGED
@@ -39,10 +39,38 @@ interface VisitorVerifyResponse {
39
39
  valid: boolean;
40
40
  name: string | null;
41
41
  }
42
+ /** A file attached to a message, as stored by the API and echoed in `message:receive`. */
43
+ interface ChatAttachment {
44
+ /** MIME type, e.g. `image/png`. */
45
+ type: string;
46
+ /** Public URL of the stored file. Local previews use a `blob:` URL until the upload lands. */
47
+ url: string;
48
+ fileName: string;
49
+ /** Size in bytes. */
50
+ size: number;
51
+ durationSeconds?: number;
52
+ /** Up to 64 loudness peaks (0–100) for drawing a voice note. */
53
+ waveform?: number[];
54
+ }
55
+ /** How a chat message is stored: plain text, files, or a recorded voice note. */
56
+ type ChatMessageKind = 'text' | 'media' | 'voice';
57
+ /** A finished recording to send with `sendVoice`, as `VoiceRecorder` produces it. */
58
+ interface VoiceRecording {
59
+ blob: Blob;
60
+ /** MIME type of `blob`; defaults to `blob.type`. */
61
+ mimeType?: string;
62
+ durationSeconds: number;
63
+ }
42
64
  interface ChatRequest {
65
+ /** Visitor text; may be empty when `attachments` carry the message. */
43
66
  chatInput: string;
44
67
  visitorToken: string;
68
+ /** Defaults to `media` when attachments are present, otherwise `text`. */
69
+ messageType?: ChatMessageKind;
70
+ attachments?: ChatAttachment[];
45
71
  }
72
+ /** `POST /sdk/upload` answers with the attachment to send back in `POST /sdk/chat`. */
73
+ type UploadAttachmentResponseData = ChatAttachment;
46
74
  /** Widget / bridge episode mode for AI vs human takeover. */
47
75
  type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
48
76
  interface ChatResponseData {
@@ -61,10 +89,24 @@ interface ChatMessage {
61
89
  sessionId: string;
62
90
  message: {
63
91
  type: 'human' | 'ai' | 'agent';
92
+ /** Text, or the caption of a media message (may be empty when `attachments` is set). */
64
93
  content: string;
94
+ attachments?: ChatAttachment[];
65
95
  };
96
+ /** `true` while the visitor's files are still uploading; cleared once the message is sent. */
97
+ pending?: boolean;
66
98
  }
67
- type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'no-agent' | null;
99
+ /**
100
+ * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
101
+ * while this is set.
102
+ * - `no-prompt`, `no-collections`: the agent is not set up yet (from the API).
103
+ * - `ai-unavailable`: the platform's AI models are not configured (from the API).
104
+ * - `no-credits`: the workspace has used its AI token budget (from the API).
105
+ * - `no-agent`: no agent is assigned to the Website channel.
106
+ * - `server-unavailable`: the API could not be reached; the SDK retries a few times.
107
+ * - `no-directories`: legacy name for `no-collections`.
108
+ */
109
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'ai-unavailable' | 'no-credits' | 'no-agent' | 'server-unavailable' | null;
68
110
  interface SdkConfigResponse {
69
111
  agentId: string;
70
112
  agentName: string;
@@ -104,4 +146,4 @@ interface ChatbotState {
104
146
  mode: ChatbotTicketMode;
105
147
  }
106
148
 
107
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
149
+ export type { ApiError, ApiResponse, ChatAttachment, ChatMessage, ChatMessageKind, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, UploadAttachmentResponseData, VisitorVerifyResponse, VoiceRecording };
package/dist/index.d.ts CHANGED
@@ -39,10 +39,38 @@ interface VisitorVerifyResponse {
39
39
  valid: boolean;
40
40
  name: string | null;
41
41
  }
42
+ /** A file attached to a message, as stored by the API and echoed in `message:receive`. */
43
+ interface ChatAttachment {
44
+ /** MIME type, e.g. `image/png`. */
45
+ type: string;
46
+ /** Public URL of the stored file. Local previews use a `blob:` URL until the upload lands. */
47
+ url: string;
48
+ fileName: string;
49
+ /** Size in bytes. */
50
+ size: number;
51
+ durationSeconds?: number;
52
+ /** Up to 64 loudness peaks (0–100) for drawing a voice note. */
53
+ waveform?: number[];
54
+ }
55
+ /** How a chat message is stored: plain text, files, or a recorded voice note. */
56
+ type ChatMessageKind = 'text' | 'media' | 'voice';
57
+ /** A finished recording to send with `sendVoice`, as `VoiceRecorder` produces it. */
58
+ interface VoiceRecording {
59
+ blob: Blob;
60
+ /** MIME type of `blob`; defaults to `blob.type`. */
61
+ mimeType?: string;
62
+ durationSeconds: number;
63
+ }
42
64
  interface ChatRequest {
65
+ /** Visitor text; may be empty when `attachments` carry the message. */
43
66
  chatInput: string;
44
67
  visitorToken: string;
68
+ /** Defaults to `media` when attachments are present, otherwise `text`. */
69
+ messageType?: ChatMessageKind;
70
+ attachments?: ChatAttachment[];
45
71
  }
72
+ /** `POST /sdk/upload` answers with the attachment to send back in `POST /sdk/chat`. */
73
+ type UploadAttachmentResponseData = ChatAttachment;
46
74
  /** Widget / bridge episode mode for AI vs human takeover. */
47
75
  type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
48
76
  interface ChatResponseData {
@@ -61,10 +89,24 @@ interface ChatMessage {
61
89
  sessionId: string;
62
90
  message: {
63
91
  type: 'human' | 'ai' | 'agent';
92
+ /** Text, or the caption of a media message (may be empty when `attachments` is set). */
64
93
  content: string;
94
+ attachments?: ChatAttachment[];
65
95
  };
96
+ /** `true` while the visitor's files are still uploading; cleared once the message is sent. */
97
+ pending?: boolean;
66
98
  }
67
- type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'no-agent' | null;
99
+ /**
100
+ * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
101
+ * while this is set.
102
+ * - `no-prompt`, `no-collections`: the agent is not set up yet (from the API).
103
+ * - `ai-unavailable`: the platform's AI models are not configured (from the API).
104
+ * - `no-credits`: the workspace has used its AI token budget (from the API).
105
+ * - `no-agent`: no agent is assigned to the Website channel.
106
+ * - `server-unavailable`: the API could not be reached; the SDK retries a few times.
107
+ * - `no-directories`: legacy name for `no-collections`.
108
+ */
109
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'ai-unavailable' | 'no-credits' | 'no-agent' | 'server-unavailable' | null;
68
110
  interface SdkConfigResponse {
69
111
  agentId: string;
70
112
  agentName: string;
@@ -104,4 +146,4 @@ interface ChatbotState {
104
146
  mode: ChatbotTicketMode;
105
147
  }
106
148
 
107
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
149
+ export type { ApiError, ApiResponse, ChatAttachment, ChatMessage, ChatMessageKind, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, UploadAttachmentResponseData, VisitorVerifyResponse, VoiceRecording };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onedeskpro/chatbot-types",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared TypeScript types for the Onedesk Pro Chatbot SDK",
5
5
  "license": "MIT",
6
6
  "author": "Typetech IT <support@onedeskpro.com>",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "devDependencies": {
48
- "tsup": "^8.5.1",
48
+ "tsup": "^9.0.0",
49
49
  "typescript": "^6"
50
50
  },
51
51
  "scripts": {