@kortex-ai/hub-client 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kortex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,342 @@
1
+ # @kortex-ai/hub-client
2
+
3
+ Official TypeScript/JavaScript client for the Kortex Hub API. This package provides a type-safe, easy-to-use interface for interacting with Kortex's conversation management, messaging, and notification systems.
4
+
5
+ ## Features
6
+
7
+ - 🔒 **Type-safe** - Full TypeScript support with comprehensive type definitions
8
+ - ✅ **Validated** - Built-in request validation using Zod schemas
9
+ - 🚀 **Modern** - Works in Node.js, Deno, Bun, and browsers
10
+ - 📦 **Tree-shakeable** - ESM and CommonJS support
11
+ - 🎯 **Simple API** - Clean, intuitive methods for all endpoints
12
+ - 🛡️ **Never throws** - All methods return Result types for safe error handling
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ # Using pnpm
18
+ pnpm add @kortex-ai/hub-client
19
+
20
+ # Using npm
21
+ npm install @kortex-ai/hub-client
22
+
23
+ # Using yarn
24
+ yarn add @kortex-ai/hub-client
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```typescript
30
+ import { KortexClient } from '@kortex-ai/hub-client'
31
+
32
+ // Initialize the client
33
+ const client = new KortexClient({
34
+ apiToken: 'your-api-token',
35
+ baseUrl: 'https://kortex-dashboard.vercel.app', // Optional, this is the default
36
+ })
37
+
38
+ // Use the client with Result pattern (never throws)
39
+ const result = await client.sendMessage({
40
+ waId: '1234567890',
41
+ message: {
42
+ type: 'text',
43
+ content: {
44
+ text: 'Hello from the API!',
45
+ },
46
+ },
47
+ })
48
+
49
+ if (result.error) {
50
+ console.error('Error:', result.error.message)
51
+ } else {
52
+ console.log('Success:', result.data.message)
53
+ }
54
+ ```
55
+
56
+ ## API Reference
57
+
58
+ ### Client Configuration
59
+
60
+ ```typescript
61
+ interface KortexClientConfig {
62
+ /**
63
+ * API token for authentication (required)
64
+ */
65
+ apiToken: string
66
+
67
+ /**
68
+ * Base URL of the Kortex Hub API
69
+ * @default 'https://kortex-dashboard.vercel.app'
70
+ */
71
+ baseUrl?: string
72
+
73
+ /**
74
+ * Optional custom fetch implementation
75
+ */
76
+ fetch?: typeof fetch
77
+
78
+ /**
79
+ * Optional request timeout in milliseconds
80
+ * @default 30000 (30 seconds)
81
+ */
82
+ timeout?: number
83
+ }
84
+ ```
85
+
86
+ ### Methods
87
+
88
+ #### `assignTags(payload)`
89
+
90
+ Assign tags to a conversation.
91
+
92
+ ```typescript
93
+ await client.assignTags({
94
+ waId: '1234567890',
95
+ tags: ['important', 'customer-support'],
96
+ })
97
+ ```
98
+
99
+ **Parameters:**
100
+
101
+ - `waId` (string, required) - WhatsApp ID of the conversation
102
+ - `tags` (string[], required) - Array of tag names to assign
103
+
104
+ **Returns:** `Promise<Result<AssignTagsResponse, KortexAPIError>>`
105
+
106
+ ---
107
+
108
+ #### `sendNotification(payload)`
109
+
110
+ Send notifications through specified channels.
111
+
112
+ ```typescript
113
+ await client.sendNotification({
114
+ sendOptions: ['dashboard', 'email'],
115
+ notification: {
116
+ category: 'general',
117
+ title: 'New Update Available',
118
+ message: 'Version 2.0 is now available!',
119
+ link: 'https://example.com/updates',
120
+ },
121
+ })
122
+ ```
123
+
124
+ **Parameters:**
125
+
126
+ - `sendOptions` (Array<'dashboard' | 'email' | 'push'>, required) - Delivery channels
127
+ - `notification` (BareNotification, required) - Notification details
128
+
129
+ **Notification Types:**
130
+
131
+ - `general` - General notification with optional link
132
+ - `chat` - Chat-related notification with conversationId
133
+ - `spaces` - Spaces notification with spaceUrlPath
134
+
135
+ **Returns:** `Promise<Result<SendNotificationResponse, KortexAPIError>>`
136
+
137
+ ---
138
+
139
+ #### `sendMessage(payload)`
140
+
141
+ Send a message (text, note, or template) to a WhatsApp conversation.
142
+
143
+ ```typescript
144
+ // Send a text message
145
+ await client.sendMessage({
146
+ waId: '1234567890',
147
+ message: {
148
+ type: 'text',
149
+ content: {
150
+ text: 'Hello!',
151
+ },
152
+ },
153
+ clientName: 'John Doe', // Optional
154
+ })
155
+
156
+ // Send a template message
157
+ await client.sendMessage({
158
+ waId: '1234567890',
159
+ message: {
160
+ type: 'template',
161
+ content: {
162
+ name: 'welcome_message',
163
+ language: 'en',
164
+ body_variables: ['John', 'Acme Corp'],
165
+ },
166
+ },
167
+ })
168
+ ```
169
+
170
+ **Parameters:**
171
+
172
+ - `waId` (string, required) - WhatsApp ID
173
+ - `message` (object, required) - Message object with type and content
174
+ - `type`: `'text'` | `'note'` | `'template'`
175
+ - `content`: Varies by message type
176
+ - `clientName` (string, optional) - Client name for context
177
+
178
+ **Returns:** `Promise<Result<SendMessageResponse, KortexAPIError>>`
179
+
180
+ ---
181
+
182
+ #### `stopConversationAi(payload)`
183
+
184
+ Stop or start AI for a conversation.
185
+
186
+ ```typescript
187
+ // Stop AI
188
+ await client.stopConversationAi({
189
+ waId: '1234567890',
190
+ stopAi: true,
191
+ })
192
+
193
+ // Start AI
194
+ await client.stopConversationAi({
195
+ waId: '1234567890',
196
+ stopAi: false,
197
+ })
198
+ ```
199
+
200
+ **Parameters:**
201
+
202
+ - `waId` (string, required) - WhatsApp ID
203
+ - `stopAi` (boolean, required) - Whether to stop or start AI
204
+
205
+ **Returns:** `Promise<Result<StopConversationAiResponse, KortexAPIError>>`
206
+
207
+ ---
208
+
209
+ #### `upsertConversation(payload)`
210
+
211
+ Create or update a conversation.
212
+
213
+ ```typescript
214
+ const response = await client.upsertConversation({
215
+ waId: '1234567890',
216
+ clientName: 'John Doe',
217
+ })
218
+
219
+ console.log(response.data) // ConversationWithTags
220
+ ```
221
+
222
+ **Parameters:**
223
+
224
+ - `waId` (string, required) - WhatsApp ID
225
+ - `clientName` (string, required) - Client name
226
+
227
+ **Returns:** `Promise<Result<UpsertConversationResponse, KortexAPIError>>`
228
+
229
+ ## Error Handling
230
+
231
+ All client methods return a `Result` type that never throws. This provides safe, explicit error handling:
232
+
233
+ ```typescript
234
+ import { KortexClient } from '@kortex-ai/hub-client'
235
+
236
+ const client = new KortexClient({ apiToken: 'your-token' })
237
+
238
+ // Result pattern - check if operation succeeded
239
+ const result = await client.sendMessage({
240
+ waId: '1234567890',
241
+ message: {
242
+ type: 'text',
243
+ content: { text: 'Hello!' },
244
+ },
245
+ })
246
+
247
+ if (result.error) {
248
+ // Error - access error details
249
+ console.error('Failed:', result.error.message)
250
+ console.error('Status:', result.error.statusCode)
251
+ console.error('Response:', result.error.response)
252
+ } else {
253
+ // Success - access data
254
+ console.log('Message sent:', result.data.message)
255
+ }
256
+
257
+ // Or destructure for cleaner code
258
+ const { data, error } = await client.sendMessage({
259
+ /* ... */
260
+ })
261
+
262
+ if (error) {
263
+ console.error('Error:', error)
264
+ return
265
+ }
266
+
267
+ console.log('Success:', data)
268
+ ```
269
+
270
+ ## Advanced Usage
271
+
272
+ ### Custom Fetch Implementation
273
+
274
+ ```typescript
275
+ import { KortexClient } from '@kortex-ai/hub-client'
276
+ import fetch from 'node-fetch'
277
+
278
+ const client = new KortexClient({
279
+ apiToken: 'your-token',
280
+ fetch: fetch as any, // Use node-fetch in Node.js < 18
281
+ })
282
+ ```
283
+
284
+ ### Custom Timeout
285
+
286
+ ```typescript
287
+ const client = new KortexClient({
288
+ apiToken: 'your-token',
289
+ timeout: 60000, // 60 seconds
290
+ })
291
+ ```
292
+
293
+ ### Using with Different Environments
294
+
295
+ The package works seamlessly across different JavaScript environments:
296
+
297
+ ```typescript
298
+ // Node.js (18+)
299
+ import { KortexClient } from '@kortex-ai/hub-client'
300
+
301
+ // Node.js (< 18) - install node-fetch
302
+ import fetch from 'node-fetch'
303
+ const client = new KortexClient({
304
+ apiToken: 'token',
305
+ fetch: fetch as any,
306
+ })
307
+
308
+ // Deno
309
+ import { KortexClient } from 'npm:@kortex-ai/hub-client'
310
+
311
+ // Browser
312
+ import { KortexClient } from '@kortex-ai/hub-client'
313
+ ```
314
+
315
+ ## Type Exports
316
+
317
+ All TypeScript types and schemas are exported for your convenience:
318
+
319
+ ```typescript
320
+ import type {
321
+ AssignTagsPayload,
322
+ SendMessagePayload,
323
+ SendNotificationPayload,
324
+ ConversationWithTags,
325
+ BareNotification,
326
+ // ... and more
327
+ } from '@kortex-ai/hub-client'
328
+
329
+ import {
330
+ AssignTagsSchema,
331
+ SendMessageSchema,
332
+ // ... Zod schemas for validation
333
+ } from '@kortex-ai/hub-client'
334
+ ```
335
+
336
+ ## License
337
+
338
+ MIT
339
+
340
+ ## Support
341
+
342
+ For issues and questions, please visit [GitHub Issues](https://github.com/kortex/kortex-dashboard/issues) or contact support.
@@ -0,0 +1,173 @@
1
+ import * as convex_helpers_server_zod4 from 'convex-helpers/server/zod4';
2
+ import { z } from 'zod';
3
+
4
+ type Success<T> = {
5
+ data: T;
6
+ error: null;
7
+ };
8
+ type Failure<E> = {
9
+ data: null;
10
+ error: E;
11
+ };
12
+ type Result<T, E = Error> = Success<T> | Failure<E>;
13
+
14
+ declare const ConversationSchema: z.ZodObject<{
15
+ _id: convex_helpers_server_zod4.Zid<"conversations">;
16
+ _creationTime: z.ZodNumber;
17
+ organizationId: convex_helpers_server_zod4.Zid<"organizations">;
18
+ waId: z.ZodString;
19
+ name: z.ZodString;
20
+ assignedUserId: z.ZodNullable<convex_helpers_server_zod4.Zid<"users">>;
21
+ stopAi: z.ZodBoolean;
22
+ status: z.ZodEnum<{
23
+ open: "open";
24
+ closed: "closed";
25
+ }>;
26
+ messageWindowStart: z.ZodNullable<z.ZodNumber>;
27
+ lastMessageText: z.ZodNullable<z.ZodString>;
28
+ lastMessageTimestamp: z.ZodNullable<z.ZodNumber>;
29
+ unreadCount: z.ZodNumber;
30
+ }, z.core.$strip>;
31
+ type Conversation = z.infer<typeof ConversationSchema>;
32
+ type ConversationWithTags = Conversation & {
33
+ tags: string[];
34
+ };
35
+
36
+ declare const AssignTagsSchema: z.ZodObject<{
37
+ waId: z.ZodString;
38
+ tags: z.ZodArray<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ type AssignTagsPayload = z.infer<typeof AssignTagsSchema>;
41
+ type AssignTagsResponse = {
42
+ message: string;
43
+ };
44
+ declare const SendNotificationSchema: z.ZodObject<{
45
+ sendOptions: z.ZodArray<z.ZodEnum<{
46
+ push: "push";
47
+ email: "email";
48
+ dashboard: "dashboard";
49
+ }>>;
50
+ notification: z.ZodDiscriminatedUnion<[z.ZodObject<{
51
+ link: z.ZodNullable<z.ZodURL>;
52
+ message: z.ZodString;
53
+ title: z.ZodString;
54
+ category: z.ZodLiteral<"general">;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ message: z.ZodString;
57
+ title: z.ZodString;
58
+ category: z.ZodLiteral<"chat">;
59
+ conversationId: convex_helpers_server_zod4.Zid<"conversations">;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ message: z.ZodString;
62
+ title: z.ZodString;
63
+ category: z.ZodLiteral<"spaces">;
64
+ spaceUrlPath: z.ZodString;
65
+ }, z.core.$strip>], "category">;
66
+ }, z.core.$strip>;
67
+ type SendNotificationPayload = z.infer<typeof SendNotificationSchema>;
68
+ type SendNotificationResponse = {
69
+ message: string;
70
+ };
71
+ declare const SendMessageSchema: z.ZodObject<{
72
+ waId: z.ZodString;
73
+ message: z.ZodDiscriminatedUnion<[z.ZodObject<{
74
+ type: z.ZodLiteral<"text">;
75
+ content: z.ZodObject<{
76
+ text: z.ZodString;
77
+ }, z.core.$strip>;
78
+ }, z.core.$strip>, z.ZodObject<{
79
+ type: z.ZodLiteral<"note">;
80
+ content: z.ZodObject<{
81
+ text: z.ZodString;
82
+ }, z.core.$strip>;
83
+ }, z.core.$strip>, z.ZodObject<{
84
+ type: z.ZodLiteral<"template">;
85
+ content: z.ZodObject<{
86
+ name: z.ZodString;
87
+ language: z.ZodString;
88
+ header_variable: z.ZodOptional<z.ZodString>;
89
+ body_variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
90
+ button_variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
91
+ }, z.core.$strip>;
92
+ }, z.core.$strip>], "type">;
93
+ clientName: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>;
95
+ type SendMessagePayload = z.infer<typeof SendMessageSchema>;
96
+ type SendMessageResponse = {
97
+ message: string;
98
+ };
99
+ declare const StopConversationAiSchema: z.ZodObject<{
100
+ waId: z.ZodString;
101
+ stopAi: z.ZodBoolean;
102
+ }, z.core.$strip>;
103
+ type StopConversationAiPayload = z.infer<typeof StopConversationAiSchema>;
104
+ type StopConversationAiResponse = {
105
+ message: string;
106
+ };
107
+ declare const UpsertConversationSchema: z.ZodObject<{
108
+ waId: z.ZodString;
109
+ clientName: z.ZodString;
110
+ }, z.core.$strip>;
111
+ type UpsertConversationPayload = z.infer<typeof UpsertConversationSchema>;
112
+ type UpsertConversationResponse = {
113
+ message: string;
114
+ data: ConversationWithTags;
115
+ };
116
+
117
+ interface KortexClientConfig {
118
+ /**
119
+ * Base URL of the Kortex Hub API
120
+ * @default 'https://kortex-dashboard.vercel.app'
121
+ */
122
+ baseUrl?: string;
123
+ /**
124
+ * API token for authentication
125
+ */
126
+ apiToken: string;
127
+ }
128
+ type KortexAPIError = {
129
+ message: string;
130
+ statusCode?: number;
131
+ response?: unknown;
132
+ };
133
+ declare class KortexClient {
134
+ private readonly baseUrl;
135
+ private readonly apiToken;
136
+ constructor(config: KortexClientConfig);
137
+ /**
138
+ * Internal method to make API requests
139
+ */
140
+ private request;
141
+ /**
142
+ * Assign tags to a conversation
143
+ * @param payload - The waId and tags to assign
144
+ * @returns Result with the success message or error
145
+ */
146
+ assignTags(payload: AssignTagsPayload): Promise<Result<AssignTagsResponse, KortexAPIError>>;
147
+ /**
148
+ * Send a notification through specified channels
149
+ * @param payload - The notification and send options
150
+ * @returns Result with the success message or error
151
+ */
152
+ sendNotification(payload: SendNotificationPayload): Promise<Result<SendNotificationResponse, KortexAPIError>>;
153
+ /**
154
+ * Send a message (text, note, or template) to a WhatsApp conversation
155
+ * @param payload - The message details (waId, message type and content)
156
+ * @returns Result with the success message or error
157
+ */
158
+ sendMessage(payload: SendMessagePayload): Promise<Result<SendMessageResponse, KortexAPIError>>;
159
+ /**
160
+ * Stop or start AI for a conversation
161
+ * @param payload - The waId and stopAi boolean
162
+ * @returns Result with the success message or error
163
+ */
164
+ stopConversationAi(payload: StopConversationAiPayload): Promise<Result<StopConversationAiResponse, KortexAPIError>>;
165
+ /**
166
+ * Create or update a conversation
167
+ * @param payload - The waId and client name
168
+ * @returns Result with the conversation data or error
169
+ */
170
+ upsertConversation(payload: UpsertConversationPayload): Promise<Result<UpsertConversationResponse, KortexAPIError>>;
171
+ }
172
+
173
+ export { type AssignTagsPayload, type AssignTagsResponse, AssignTagsSchema, type KortexAPIError, KortexClient, type KortexClientConfig, type SendMessagePayload, type SendMessageResponse, SendMessageSchema, type SendNotificationPayload, type SendNotificationResponse, SendNotificationSchema, type StopConversationAiPayload, type StopConversationAiResponse, StopConversationAiSchema, type UpsertConversationPayload, type UpsertConversationResponse, UpsertConversationSchema };
@@ -0,0 +1,173 @@
1
+ import * as convex_helpers_server_zod4 from 'convex-helpers/server/zod4';
2
+ import { z } from 'zod';
3
+
4
+ type Success<T> = {
5
+ data: T;
6
+ error: null;
7
+ };
8
+ type Failure<E> = {
9
+ data: null;
10
+ error: E;
11
+ };
12
+ type Result<T, E = Error> = Success<T> | Failure<E>;
13
+
14
+ declare const ConversationSchema: z.ZodObject<{
15
+ _id: convex_helpers_server_zod4.Zid<"conversations">;
16
+ _creationTime: z.ZodNumber;
17
+ organizationId: convex_helpers_server_zod4.Zid<"organizations">;
18
+ waId: z.ZodString;
19
+ name: z.ZodString;
20
+ assignedUserId: z.ZodNullable<convex_helpers_server_zod4.Zid<"users">>;
21
+ stopAi: z.ZodBoolean;
22
+ status: z.ZodEnum<{
23
+ open: "open";
24
+ closed: "closed";
25
+ }>;
26
+ messageWindowStart: z.ZodNullable<z.ZodNumber>;
27
+ lastMessageText: z.ZodNullable<z.ZodString>;
28
+ lastMessageTimestamp: z.ZodNullable<z.ZodNumber>;
29
+ unreadCount: z.ZodNumber;
30
+ }, z.core.$strip>;
31
+ type Conversation = z.infer<typeof ConversationSchema>;
32
+ type ConversationWithTags = Conversation & {
33
+ tags: string[];
34
+ };
35
+
36
+ declare const AssignTagsSchema: z.ZodObject<{
37
+ waId: z.ZodString;
38
+ tags: z.ZodArray<z.ZodString>;
39
+ }, z.core.$strip>;
40
+ type AssignTagsPayload = z.infer<typeof AssignTagsSchema>;
41
+ type AssignTagsResponse = {
42
+ message: string;
43
+ };
44
+ declare const SendNotificationSchema: z.ZodObject<{
45
+ sendOptions: z.ZodArray<z.ZodEnum<{
46
+ push: "push";
47
+ email: "email";
48
+ dashboard: "dashboard";
49
+ }>>;
50
+ notification: z.ZodDiscriminatedUnion<[z.ZodObject<{
51
+ link: z.ZodNullable<z.ZodURL>;
52
+ message: z.ZodString;
53
+ title: z.ZodString;
54
+ category: z.ZodLiteral<"general">;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ message: z.ZodString;
57
+ title: z.ZodString;
58
+ category: z.ZodLiteral<"chat">;
59
+ conversationId: convex_helpers_server_zod4.Zid<"conversations">;
60
+ }, z.core.$strip>, z.ZodObject<{
61
+ message: z.ZodString;
62
+ title: z.ZodString;
63
+ category: z.ZodLiteral<"spaces">;
64
+ spaceUrlPath: z.ZodString;
65
+ }, z.core.$strip>], "category">;
66
+ }, z.core.$strip>;
67
+ type SendNotificationPayload = z.infer<typeof SendNotificationSchema>;
68
+ type SendNotificationResponse = {
69
+ message: string;
70
+ };
71
+ declare const SendMessageSchema: z.ZodObject<{
72
+ waId: z.ZodString;
73
+ message: z.ZodDiscriminatedUnion<[z.ZodObject<{
74
+ type: z.ZodLiteral<"text">;
75
+ content: z.ZodObject<{
76
+ text: z.ZodString;
77
+ }, z.core.$strip>;
78
+ }, z.core.$strip>, z.ZodObject<{
79
+ type: z.ZodLiteral<"note">;
80
+ content: z.ZodObject<{
81
+ text: z.ZodString;
82
+ }, z.core.$strip>;
83
+ }, z.core.$strip>, z.ZodObject<{
84
+ type: z.ZodLiteral<"template">;
85
+ content: z.ZodObject<{
86
+ name: z.ZodString;
87
+ language: z.ZodString;
88
+ header_variable: z.ZodOptional<z.ZodString>;
89
+ body_variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
90
+ button_variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
91
+ }, z.core.$strip>;
92
+ }, z.core.$strip>], "type">;
93
+ clientName: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strip>;
95
+ type SendMessagePayload = z.infer<typeof SendMessageSchema>;
96
+ type SendMessageResponse = {
97
+ message: string;
98
+ };
99
+ declare const StopConversationAiSchema: z.ZodObject<{
100
+ waId: z.ZodString;
101
+ stopAi: z.ZodBoolean;
102
+ }, z.core.$strip>;
103
+ type StopConversationAiPayload = z.infer<typeof StopConversationAiSchema>;
104
+ type StopConversationAiResponse = {
105
+ message: string;
106
+ };
107
+ declare const UpsertConversationSchema: z.ZodObject<{
108
+ waId: z.ZodString;
109
+ clientName: z.ZodString;
110
+ }, z.core.$strip>;
111
+ type UpsertConversationPayload = z.infer<typeof UpsertConversationSchema>;
112
+ type UpsertConversationResponse = {
113
+ message: string;
114
+ data: ConversationWithTags;
115
+ };
116
+
117
+ interface KortexClientConfig {
118
+ /**
119
+ * Base URL of the Kortex Hub API
120
+ * @default 'https://kortex-dashboard.vercel.app'
121
+ */
122
+ baseUrl?: string;
123
+ /**
124
+ * API token for authentication
125
+ */
126
+ apiToken: string;
127
+ }
128
+ type KortexAPIError = {
129
+ message: string;
130
+ statusCode?: number;
131
+ response?: unknown;
132
+ };
133
+ declare class KortexClient {
134
+ private readonly baseUrl;
135
+ private readonly apiToken;
136
+ constructor(config: KortexClientConfig);
137
+ /**
138
+ * Internal method to make API requests
139
+ */
140
+ private request;
141
+ /**
142
+ * Assign tags to a conversation
143
+ * @param payload - The waId and tags to assign
144
+ * @returns Result with the success message or error
145
+ */
146
+ assignTags(payload: AssignTagsPayload): Promise<Result<AssignTagsResponse, KortexAPIError>>;
147
+ /**
148
+ * Send a notification through specified channels
149
+ * @param payload - The notification and send options
150
+ * @returns Result with the success message or error
151
+ */
152
+ sendNotification(payload: SendNotificationPayload): Promise<Result<SendNotificationResponse, KortexAPIError>>;
153
+ /**
154
+ * Send a message (text, note, or template) to a WhatsApp conversation
155
+ * @param payload - The message details (waId, message type and content)
156
+ * @returns Result with the success message or error
157
+ */
158
+ sendMessage(payload: SendMessagePayload): Promise<Result<SendMessageResponse, KortexAPIError>>;
159
+ /**
160
+ * Stop or start AI for a conversation
161
+ * @param payload - The waId and stopAi boolean
162
+ * @returns Result with the success message or error
163
+ */
164
+ stopConversationAi(payload: StopConversationAiPayload): Promise<Result<StopConversationAiResponse, KortexAPIError>>;
165
+ /**
166
+ * Create or update a conversation
167
+ * @param payload - The waId and client name
168
+ * @returns Result with the conversation data or error
169
+ */
170
+ upsertConversation(payload: UpsertConversationPayload): Promise<Result<UpsertConversationResponse, KortexAPIError>>;
171
+ }
172
+
173
+ export { type AssignTagsPayload, type AssignTagsResponse, AssignTagsSchema, type KortexAPIError, KortexClient, type KortexClientConfig, type SendMessagePayload, type SendMessageResponse, SendMessageSchema, type SendNotificationPayload, type SendNotificationResponse, SendNotificationSchema, type StopConversationAiPayload, type StopConversationAiResponse, StopConversationAiSchema, type UpsertConversationPayload, type UpsertConversationResponse, UpsertConversationSchema };