@onedeskpro/chatbot-types 0.1.0 → 0.2.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
@@ -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 (`'no-prompt' \| 'no-collections' \| 'no-directories' \| 'no-agent' \| null`). |
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,44 @@ 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
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'no-agent' | null;
46
68
  interface SdkConfigResponse {
47
69
  agentId: string;
48
70
  agentName: string;
@@ -63,15 +85,23 @@ type ChatbotEventMap = {
63
85
  error: Error;
64
86
  'session-reset': void;
65
87
  ready: void;
88
+ /** Fired after a successful `POST /sdk/human-request`. */
89
+ 'human-requested': void;
90
+ /** Fired when ticket mode changes via REST restore or `/sdk` socket push. */
91
+ 'ticket-status': TicketStatusData;
66
92
  };
67
93
  interface ChatbotState {
68
94
  isOpen: boolean;
69
95
  isLoading: boolean;
70
96
  isReady: boolean;
97
+ needsIdentify: boolean;
71
98
  blockReason: ChatbotBlockReason;
72
99
  messages: ChatMessage[];
73
- sessionId: string | null;
100
+ visitorToken: string | null;
101
+ visitorName: string | null;
74
102
  error: string | null;
103
+ /** Current ticket episode mode. */
104
+ mode: ChatbotTicketMode;
75
105
  }
76
106
 
77
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
107
+ 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,44 @@ 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
+ type ChatbotBlockReason = 'no-prompt' | 'no-collections' | 'no-directories' | 'no-agent' | null;
46
68
  interface SdkConfigResponse {
47
69
  agentId: string;
48
70
  agentName: string;
@@ -63,15 +85,23 @@ type ChatbotEventMap = {
63
85
  error: Error;
64
86
  'session-reset': void;
65
87
  ready: void;
88
+ /** Fired after a successful `POST /sdk/human-request`. */
89
+ 'human-requested': void;
90
+ /** Fired when ticket mode changes via REST restore or `/sdk` socket push. */
91
+ 'ticket-status': TicketStatusData;
66
92
  };
67
93
  interface ChatbotState {
68
94
  isOpen: boolean;
69
95
  isLoading: boolean;
70
96
  isReady: boolean;
97
+ needsIdentify: boolean;
71
98
  blockReason: ChatbotBlockReason;
72
99
  messages: ChatMessage[];
73
- sessionId: string | null;
100
+ visitorToken: string | null;
101
+ visitorName: string | null;
74
102
  error: string | null;
103
+ /** Current ticket episode mode. */
104
+ mode: ChatbotTicketMode;
75
105
  }
76
106
 
77
- export type { ApiError, ApiResponse, ChatMessage, ChatRequest, ChatResponseData, ChatbotBlockReason, ChatbotEventMap, ChatbotInitOptions, ChatbotState, SdkConfigResponse };
107
+ 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.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,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",