@burki.dev/sdk 0.1.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 ADDED
@@ -0,0 +1,476 @@
1
+ # Burki JavaScript/TypeScript SDK
2
+
3
+ Official JavaScript/TypeScript SDK for the [Burki Voice AI Platform](https://burki.dev).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @burki.dev/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { BurkiClient } from '@burki/sdk';
15
+
16
+ // Initialize the client
17
+ const client = new BurkiClient({ apiKey: 'your-api-key' });
18
+
19
+ // List all assistants
20
+ const assistants = await client.assistants.list();
21
+ for (const assistant of assistants) {
22
+ console.log(`${assistant.id}: ${assistant.name}`);
23
+ }
24
+
25
+ // Create a new assistant
26
+ const assistant = await client.assistants.create({
27
+ name: 'Support Bot',
28
+ description: 'Customer support assistant',
29
+ llmSettings: {
30
+ model: 'gpt-4o-mini',
31
+ temperature: 0.7,
32
+ systemPrompt: 'You are a helpful customer support agent.'
33
+ },
34
+ ttsSettings: {
35
+ provider: 'elevenlabs',
36
+ voiceId: 'rachel'
37
+ }
38
+ });
39
+ ```
40
+
41
+ ## Features
42
+
43
+ ### Assistants
44
+
45
+ ```typescript
46
+ // List assistants
47
+ const assistants = await client.assistants.list();
48
+
49
+ // List with options
50
+ const activeAssistants = await client.assistants.list({
51
+ activeOnly: true,
52
+ includeStats: true,
53
+ limit: 50
54
+ });
55
+
56
+ // Get a specific assistant
57
+ const assistant = await client.assistants.get(123);
58
+
59
+ // Get an assistant by phone number
60
+ const assistant = await client.assistants.getByPhone('+14155551234');
61
+
62
+ // Create an assistant
63
+ const assistant = await client.assistants.create({
64
+ name: 'My Bot',
65
+ llmSettings: { model: 'gpt-4o-mini' }
66
+ });
67
+
68
+ // Update an assistant
69
+ const updated = await client.assistants.update(123, { name: 'Updated Bot' });
70
+
71
+ // Quick status update
72
+ await client.assistants.updateStatus(123, false); // Deactivate
73
+
74
+ // Delete an assistant
75
+ await client.assistants.delete(123);
76
+
77
+ // Get assistant count
78
+ const count = await client.assistants.getCount(true); // Active only
79
+
80
+ // Export assistants
81
+ const csvBlob = await client.assistants.export({ format: 'csv' });
82
+
83
+ // Get cloned voices
84
+ const voices = await client.assistants.getClonedVoices({ provider: 'elevenlabs' });
85
+
86
+ // Get available LLM providers
87
+ const providers = await client.assistants.getProviders();
88
+
89
+ // Get organization info
90
+ const orgInfo = await client.assistants.getOrganizationInfo();
91
+ ```
92
+
93
+ ### Calls
94
+
95
+ ```typescript
96
+ // Initiate an outbound call
97
+ const response = await client.calls.initiate({
98
+ fromPhoneNumber: '+14155559999',
99
+ toPhoneNumber: '+14155551234',
100
+ welcomeMessage: 'Hello! This is a follow-up call.',
101
+ agenda: 'Discuss the recent proposal'
102
+ });
103
+
104
+ // List calls with filters
105
+ const calls = await client.calls.list({
106
+ status: 'completed',
107
+ dateFrom: '2026-01-01',
108
+ limit: 50
109
+ });
110
+
111
+ // Get call details
112
+ const call = await client.calls.get(123);
113
+
114
+ // Get call by SID
115
+ const call = await client.calls.getBySid('CA123...');
116
+
117
+ // Update call metadata
118
+ await client.calls.updateMetadata(123, { customField: 'value' });
119
+
120
+ // Get call transcripts
121
+ const transcripts = await client.calls.getTranscripts(123);
122
+
123
+ // Get transcripts by SID
124
+ const transcripts = await client.calls.getTranscriptsBySid('CA123...');
125
+
126
+ // Export transcripts
127
+ const txtBlob = await client.calls.exportTranscripts(123, { format: 'txt' });
128
+
129
+ // Get call recordings
130
+ const recordings = await client.calls.getRecordings(123);
131
+
132
+ // Get recording URL
133
+ const url = client.calls.getRecordingUrl(123, 456);
134
+
135
+ // Get call metrics
136
+ const metrics = await client.calls.getMetrics(123);
137
+
138
+ // Get chat messages (LLM conversation)
139
+ const messages = await client.calls.getMessages(123);
140
+
141
+ // Get webhook logs
142
+ const logs = await client.calls.getWebhookLogs(123);
143
+
144
+ // Terminate an ongoing call
145
+ await client.calls.terminate('CA123...');
146
+
147
+ // Get analytics
148
+ const analytics = await client.calls.getAnalytics('7d');
149
+
150
+ // Get stats
151
+ const stats = await client.calls.getStats();
152
+
153
+ // Search calls
154
+ const results = await client.calls.search('customer name');
155
+
156
+ // Export calls
157
+ const csvBlob = await client.calls.export({ format: 'csv', status: 'completed' });
158
+ ```
159
+
160
+ ### Phone Numbers
161
+
162
+ ```typescript
163
+ // List phone numbers
164
+ const numbers = await client.phoneNumbers.list();
165
+
166
+ // Search available numbers
167
+ const available = await client.phoneNumbers.search({
168
+ provider: 'twilio',
169
+ countryCode: 'US',
170
+ areaCode: '415'
171
+ });
172
+
173
+ // Purchase a number
174
+ const result = await client.phoneNumbers.purchase({
175
+ phoneNumber: '+14155551234',
176
+ provider: 'twilio',
177
+ friendlyName: 'Support Line'
178
+ });
179
+
180
+ // Release a number
181
+ await client.phoneNumbers.release('+14155551234');
182
+
183
+ // Assign to an assistant
184
+ await client.phoneNumbers.assign(123, { assistantId: 456 });
185
+
186
+ // Unassign from assistant
187
+ await client.phoneNumbers.unassign(123);
188
+
189
+ // Get available countries
190
+ const countries = await client.phoneNumbers.getCountries('telnyx');
191
+
192
+ // Diagnose connection (Telnyx)
193
+ const diagnosis = await client.phoneNumbers.diagnose('+14155551234');
194
+
195
+ // Get webhook configuration
196
+ const webhooks = await client.phoneNumbers.getWebhooks('+14155551234');
197
+
198
+ // Update webhooks
199
+ await client.phoneNumbers.updateWebhooks({
200
+ phoneNumber: '+14155551234',
201
+ voiceWebhookUrl: 'https://example.com/voice'
202
+ });
203
+
204
+ // Sync verified caller IDs
205
+ await client.phoneNumbers.syncVerifiedCallerIds();
206
+
207
+ // Add a verified caller ID
208
+ await client.phoneNumbers.addVerifiedCallerId({
209
+ phoneNumber: '+14155551234',
210
+ friendlyName: 'My Phone'
211
+ });
212
+ ```
213
+
214
+ ### Documents (RAG)
215
+
216
+ ```typescript
217
+ // Upload a document (browser)
218
+ const file = new File(['content'], 'knowledge.pdf', { type: 'application/pdf' });
219
+ const document = await client.documents.upload(123, file, 'knowledge.pdf');
220
+
221
+ // Upload from URL
222
+ const document = await client.documents.uploadFromUrl({
223
+ assistantId: 123,
224
+ url: 'https://example.com/document.pdf'
225
+ });
226
+
227
+ // List documents
228
+ const documents = await client.documents.list(123);
229
+
230
+ // Check processing status
231
+ const status = await client.documents.getStatus(456);
232
+
233
+ // Reprocess a document
234
+ await client.documents.reprocess(456);
235
+
236
+ // Delete a document
237
+ await client.documents.delete(456);
238
+ ```
239
+
240
+ ### Tools
241
+
242
+ ```typescript
243
+ // List tools
244
+ const tools = await client.tools.list();
245
+
246
+ // Get a tool
247
+ const tool = await client.tools.get(123);
248
+
249
+ // Create an HTTP tool
250
+ const tool = await client.tools.create({
251
+ name: 'check_inventory',
252
+ toolType: 'http',
253
+ description: 'Check product inventory',
254
+ httpConfig: {
255
+ method: 'GET',
256
+ url: 'https://api.example.com/inventory'
257
+ }
258
+ });
259
+
260
+ // Update a tool
261
+ await client.tools.update(123, { description: 'Updated description' });
262
+
263
+ // Delete a tool
264
+ await client.tools.delete(123);
265
+
266
+ // Assign tool to assistant
267
+ await client.tools.assign(123, 456);
268
+
269
+ // Unassign tool from assistant
270
+ await client.tools.unassign(123, 456);
271
+
272
+ // Discover AWS Lambda functions
273
+ const lambdas = await client.tools.discoverLambda('us-east-1');
274
+ ```
275
+
276
+ ### SMS
277
+
278
+ ```typescript
279
+ // Send an SMS
280
+ const response = await client.sms.send({
281
+ fromPhoneNumber: '+14155559999',
282
+ toPhoneNumber: '+14155551234',
283
+ message: 'Hello from Burki!',
284
+ queue: true // Use rate-limited queue
285
+ });
286
+
287
+ // Get message status
288
+ const status = await client.sms.getStatus('msg_123');
289
+
290
+ // Cancel a queued message
291
+ await client.sms.cancel('msg_123');
292
+
293
+ // Get queue statistics
294
+ const stats = await client.sms.getQueueStats();
295
+
296
+ // List conversations
297
+ const conversations = await client.sms.listConversations({
298
+ assistantId: 123,
299
+ status: 'active'
300
+ });
301
+
302
+ // Get a conversation
303
+ const conversation = await client.sms.getConversation('conv_123');
304
+
305
+ // Get messages in a conversation
306
+ const messages = await client.sms.getMessages('conv_123');
307
+
308
+ // Get related conversations (voice + SMS unified session)
309
+ const related = await client.sms.getRelatedConversations('conv_123');
310
+
311
+ // Delete/archive a conversation
312
+ await client.sms.deleteConversation('conv_123');
313
+
314
+ // Export a conversation
315
+ const txtBlob = await client.sms.exportConversation('conv_123', { format: 'txt' });
316
+ ```
317
+
318
+ ### Campaigns
319
+
320
+ ```typescript
321
+ // List campaigns
322
+ const campaigns = await client.campaigns.list({ status: 'running' });
323
+
324
+ // Get a campaign
325
+ const campaign = await client.campaigns.get(123);
326
+
327
+ // Create a campaign
328
+ const campaign = await client.campaigns.create({
329
+ name: 'Outreach Campaign',
330
+ assistantId: 123,
331
+ contacts: [
332
+ { phoneNumber: '+14155551234', name: 'John', variables: { company: 'Acme' } },
333
+ { phoneNumber: '+14155555678', name: 'Jane' }
334
+ ],
335
+ settings: {
336
+ maxConcurrentCalls: 5,
337
+ callsPerMinute: 10
338
+ }
339
+ });
340
+
341
+ // Update a campaign
342
+ await client.campaigns.update(123, { name: 'Updated Campaign' });
343
+
344
+ // Delete a campaign
345
+ await client.campaigns.delete(123);
346
+
347
+ // Start the campaign
348
+ await client.campaigns.start(123);
349
+
350
+ // Pause the campaign
351
+ await client.campaigns.pause(123);
352
+
353
+ // Resume the campaign
354
+ await client.campaigns.resume(123);
355
+
356
+ // Cancel the campaign
357
+ await client.campaigns.cancel(123);
358
+
359
+ // Get campaign progress
360
+ const progress = await client.campaigns.getProgress(123);
361
+
362
+ // Get contacts
363
+ const contacts = await client.campaigns.getContacts(123, { status: 'pending' });
364
+
365
+ // Add contacts
366
+ await client.campaigns.addContacts(123, [
367
+ { phoneNumber: '+14155559999', name: 'New Contact' }
368
+ ]);
369
+ ```
370
+
371
+ ### Real-time Streaming (WebSocket)
372
+
373
+ ```typescript
374
+ // Stream live transcripts during a call
375
+ const stream = client.realtime.liveTranscript('CA123...');
376
+ await stream.connect();
377
+
378
+ for await (const event of stream) {
379
+ if (event.type === 'transcript') {
380
+ console.log(`[${event.speaker}]: ${event.content}`);
381
+ } else if (event.type === 'call_status') {
382
+ console.log(`Call status: ${event.status}`);
383
+ }
384
+ }
385
+
386
+ stream.disconnect();
387
+ ```
388
+
389
+ ```typescript
390
+ // Stream campaign progress updates
391
+ const stream = client.realtime.campaignProgress(123);
392
+ await stream.connect();
393
+
394
+ for await (const event of stream) {
395
+ if (event.type === 'progress') {
396
+ console.log(`Progress: ${event.completedContacts}/${event.totalContacts}`);
397
+ } else if (event.type === 'campaign_completed') {
398
+ console.log(`Campaign completed! Success rate: ${event.successRate}%`);
399
+ }
400
+ }
401
+ ```
402
+
403
+ ## Configuration
404
+
405
+ ### Custom Base URL
406
+
407
+ ```typescript
408
+ const client = new BurkiClient({
409
+ apiKey: 'your-api-key',
410
+ baseUrl: 'https://custom.burki.dev'
411
+ });
412
+ ```
413
+
414
+ ### Timeout Settings
415
+
416
+ ```typescript
417
+ const client = new BurkiClient({
418
+ apiKey: 'your-api-key',
419
+ timeout: 60000 // 60 seconds
420
+ });
421
+ ```
422
+
423
+ ## Error Handling
424
+
425
+ ```typescript
426
+ import {
427
+ BurkiClient,
428
+ AuthenticationError,
429
+ NotFoundError,
430
+ ValidationError,
431
+ RateLimitError,
432
+ ServerError,
433
+ WebSocketError
434
+ } from '@burki/sdk';
435
+
436
+ const client = new BurkiClient({ apiKey: 'your-api-key' });
437
+
438
+ try {
439
+ const assistant = await client.assistants.get(999);
440
+ } catch (error) {
441
+ if (error instanceof AuthenticationError) {
442
+ console.error('Invalid API key');
443
+ } else if (error instanceof NotFoundError) {
444
+ console.error('Assistant not found');
445
+ } else if (error instanceof ValidationError) {
446
+ console.error(`Validation error: ${error.message}`);
447
+ } else if (error instanceof RateLimitError) {
448
+ console.error(`Rate limited. Retry after ${error.retryAfter} seconds`);
449
+ } else if (error instanceof ServerError) {
450
+ console.error('Server error occurred');
451
+ } else if (error instanceof WebSocketError) {
452
+ console.error('WebSocket connection error');
453
+ }
454
+ }
455
+ ```
456
+
457
+ ## TypeScript Support
458
+
459
+ This SDK is written in TypeScript and provides full type definitions for all models and methods.
460
+
461
+ ```typescript
462
+ import type {
463
+ Assistant,
464
+ AssistantCreateParams,
465
+ Call,
466
+ CallListParams,
467
+ Campaign,
468
+ PhoneNumber,
469
+ Tool,
470
+ // ... and more
471
+ } from '@burki/sdk';
472
+ ```
473
+
474
+ ## License
475
+
476
+ MIT License