@onedeskpro/chatbot-types 0.1.0 → 0.2.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 CHANGED
@@ -15,11 +15,15 @@ npm install --save-dev @onedeskpro/chatbot-types
15
15
  | Type | Purpose |
16
16
  | --- | --- |
17
17
  | `ChatbotInitOptions` | Options accepted by `ChatbotCore.init` and `ChatbotProvider`. |
18
- | `ChatbotState` | Snapshot of widget state. |
19
- | `ChatMessage` | A single human or AI message. |
20
- | `ChatbotEventMap` | Event names mapped to payloads, including `state-change`. |
21
- | `ChatbotBlockReason` | Why a bot is not ready (`'no-prompt' \| 'no-directories' \| null`). |
18
+ | `ChatbotState` | Snapshot of widget state, including `needsIdentify`, `visitorToken`, and `mode`. |
19
+ | `ChatMessage` | A single message. `message.type` is `'human'` (the visitor), `'ai'`, or `'agent'` (a human agent). |
20
+ | `ChatbotEventMap` | Event names mapped to payloads, including `state-change`, `ticket-status`, and `human-requested`. |
21
+ | `ChatbotTicketMode` | Who owns the conversation (`'ai' \| 'waiting' \| 'human' \| 'closed'`). |
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, or `null`: `'no-prompt'`, `'no-collections'`, `'ai-unavailable'`, `'no-credits'`, `'no-agent'`, `'server-unavailable'`, or the legacy `'no-directories'`. |
22
24
  | `SdkConfigResponse` | Remote agent configuration and readiness. |
25
+ | `IdentifyRequest` / `IdentifyResponseData` | Identify endpoint request and response bodies. |
26
+ | `VisitorVerifyResponse` | Result of verifying a stored visitor token. |
23
27
  | `ChatRequest` / `ChatResponseData` | Chat endpoint request and response bodies. |
24
28
  | `ApiResponse<T>` / `ApiError` | Onedesk Pro API envelopes. |
25
29
 
package/dist/index.d.cts CHANGED
@@ -8,6 +8,7 @@ interface ChatbotInitOptions {
8
8
  welcomeMessage?: string;
9
9
  placeholder?: string;
10
10
  autoOpen?: boolean;
11
+ /** @deprecated Visitor tokens replace client session ids. Ignored when present. */
11
12
  sessionId?: string;
12
13
  /** Abort an API request that has not responded in this many ms. Defaults to 30000. */
13
14
  requestTimeoutMs?: number;
@@ -26,23 +27,54 @@ interface ApiError {
26
27
  timestamp: string;
27
28
  path: string;
28
29
  }
30
+ interface IdentifyRequest {
31
+ name: string;
32
+ phone: string;
33
+ email?: string;
34
+ }
35
+ interface IdentifyResponseData {
36
+ visitorToken: string;
37
+ }
38
+ interface VisitorVerifyResponse {
39
+ valid: boolean;
40
+ name: string | null;
41
+ }
29
42
  interface ChatRequest {
30
43
  chatInput: string;
31
- sessionId?: string;
44
+ visitorToken: string;
32
45
  }
46
+ /** Widget / bridge episode mode for AI vs human takeover. */
47
+ type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
33
48
  interface ChatResponseData {
34
49
  text: string;
35
50
  sessionId: string;
51
+ mode: ChatbotTicketMode;
52
+ }
53
+ /** Shared shape for `POST /sdk/human-request`, `GET /sdk/ticket-status`, and `ticket:status`. */
54
+ interface TicketStatusData {
55
+ mode: ChatbotTicketMode;
56
+ conversationId?: string;
57
+ agentName?: string;
36
58
  }
37
59
  interface ChatMessage {
38
60
  id: number;
39
61
  sessionId: string;
40
62
  message: {
41
- type: 'human' | 'ai';
63
+ type: 'human' | 'ai' | 'agent';
42
64
  content: string;
43
65
  };
44
66
  }
45
- type ChatbotBlockReason = 'no-prompt' | 'no-directories' | null;
67
+ /**
68
+ * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
69
+ * while this is set.
70
+ * - `no-prompt`, `no-collections`: the agent is not set up yet (from the API).
71
+ * - `ai-unavailable`: the platform's AI models are not configured (from the API).
72
+ * - `no-credits`: the workspace has used its AI token budget (from the API).
73
+ * - `no-agent`: no agent is assigned to the Website channel.
74
+ * - `server-unavailable`: the API could not be reached; the SDK retries a few times.
75
+ * - `no-directories`: legacy name for `no-collections`.
76
+ */
77
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'ai-unavailable' | 'no-credits' | 'no-agent' | 'server-unavailable' | null;
46
78
  interface SdkConfigResponse {
47
79
  agentId: string;
48
80
  agentName: string;
@@ -63,15 +95,23 @@ type ChatbotEventMap = {
63
95
  error: Error;
64
96
  'session-reset': void;
65
97
  ready: void;
98
+ /** Fired after a successful `POST /sdk/human-request`. */
99
+ 'human-requested': void;
100
+ /** Fired when ticket mode changes via REST restore or `/sdk` socket push. */
101
+ 'ticket-status': TicketStatusData;
66
102
  };
67
103
  interface ChatbotState {
68
104
  isOpen: boolean;
69
105
  isLoading: boolean;
70
106
  isReady: boolean;
107
+ needsIdentify: boolean;
71
108
  blockReason: ChatbotBlockReason;
72
109
  messages: ChatMessage[];
73
- sessionId: string | null;
110
+ visitorToken: string | null;
111
+ visitorName: string | null;
74
112
  error: string | null;
113
+ /** Current ticket episode mode. */
114
+ mode: ChatbotTicketMode;
75
115
  }
76
116
 
77
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
117
+ export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ interface ChatbotInitOptions {
8
8
  welcomeMessage?: string;
9
9
  placeholder?: string;
10
10
  autoOpen?: boolean;
11
+ /** @deprecated Visitor tokens replace client session ids. Ignored when present. */
11
12
  sessionId?: string;
12
13
  /** Abort an API request that has not responded in this many ms. Defaults to 30000. */
13
14
  requestTimeoutMs?: number;
@@ -26,23 +27,54 @@ interface ApiError {
26
27
  timestamp: string;
27
28
  path: string;
28
29
  }
30
+ interface IdentifyRequest {
31
+ name: string;
32
+ phone: string;
33
+ email?: string;
34
+ }
35
+ interface IdentifyResponseData {
36
+ visitorToken: string;
37
+ }
38
+ interface VisitorVerifyResponse {
39
+ valid: boolean;
40
+ name: string | null;
41
+ }
29
42
  interface ChatRequest {
30
43
  chatInput: string;
31
- sessionId?: string;
44
+ visitorToken: string;
32
45
  }
46
+ /** Widget / bridge episode mode for AI vs human takeover. */
47
+ type ChatbotTicketMode = 'ai' | 'waiting' | 'human' | 'closed';
33
48
  interface ChatResponseData {
34
49
  text: string;
35
50
  sessionId: string;
51
+ mode: ChatbotTicketMode;
52
+ }
53
+ /** Shared shape for `POST /sdk/human-request`, `GET /sdk/ticket-status`, and `ticket:status`. */
54
+ interface TicketStatusData {
55
+ mode: ChatbotTicketMode;
56
+ conversationId?: string;
57
+ agentName?: string;
36
58
  }
37
59
  interface ChatMessage {
38
60
  id: number;
39
61
  sessionId: string;
40
62
  message: {
41
- type: 'human' | 'ai';
63
+ type: 'human' | 'ai' | 'agent';
42
64
  content: string;
43
65
  };
44
66
  }
45
- type ChatbotBlockReason = 'no-prompt' | 'no-directories' | null;
67
+ /**
68
+ * Why the chatbot cannot answer, or `null` when it can. The widget stays hidden
69
+ * while this is set.
70
+ * - `no-prompt`, `no-collections`: the agent is not set up yet (from the API).
71
+ * - `ai-unavailable`: the platform's AI models are not configured (from the API).
72
+ * - `no-credits`: the workspace has used its AI token budget (from the API).
73
+ * - `no-agent`: no agent is assigned to the Website channel.
74
+ * - `server-unavailable`: the API could not be reached; the SDK retries a few times.
75
+ * - `no-directories`: legacy name for `no-collections`.
76
+ */
77
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'ai-unavailable' | 'no-credits' | 'no-agent' | 'server-unavailable' | null;
46
78
  interface SdkConfigResponse {
47
79
  agentId: string;
48
80
  agentName: string;
@@ -63,15 +95,23 @@ type ChatbotEventMap = {
63
95
  error: Error;
64
96
  'session-reset': void;
65
97
  ready: void;
98
+ /** Fired after a successful `POST /sdk/human-request`. */
99
+ 'human-requested': void;
100
+ /** Fired when ticket mode changes via REST restore or `/sdk` socket push. */
101
+ 'ticket-status': TicketStatusData;
66
102
  };
67
103
  interface ChatbotState {
68
104
  isOpen: boolean;
69
105
  isLoading: boolean;
70
106
  isReady: boolean;
107
+ needsIdentify: boolean;
71
108
  blockReason: ChatbotBlockReason;
72
109
  messages: ChatMessage[];
73
- sessionId: string | null;
110
+ visitorToken: string | null;
111
+ visitorName: string | null;
74
112
  error: string | null;
113
+ /** Current ticket episode mode. */
114
+ mode: ChatbotTicketMode;
75
115
  }
76
116
 
77
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
117
+ export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, ChatbotTicketMode, IdentifyRequest, IdentifyResponseData, SdkConfigResponse, TicketStatusData, VisitorVerifyResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onedeskpro/chatbot-types",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
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,8 +45,8 @@
45
45
  "access": "public"
46
46
  },
47
47
  "devDependencies": {
48
- "tsup": "^8.0.0",
49
- "typescript": "^5.5.0"
48
+ "tsup": "^8.5.1",
49
+ "typescript": "^6"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsup",