@chanl-ai/sdk 2.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.
Files changed (137) hide show
  1. package/dist/adapters/openai.d.ts +106 -0
  2. package/dist/adapters/openai.d.ts.map +1 -0
  3. package/dist/adapters/openai.js +185 -0
  4. package/dist/adapters/openai.js.map +1 -0
  5. package/dist/client.d.ts +74 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +293 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/errors/index.d.ts +179 -0
  10. package/dist/errors/index.d.ts.map +1 -0
  11. package/dist/errors/index.js +319 -0
  12. package/dist/errors/index.js.map +1 -0
  13. package/dist/index.d.ts +38 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +76 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/live/index.d.ts +9 -0
  18. package/dist/live/index.d.ts.map +1 -0
  19. package/dist/live/index.js +16 -0
  20. package/dist/live/index.js.map +1 -0
  21. package/dist/live/live-call.d.ts +48 -0
  22. package/dist/live/live-call.d.ts.map +1 -0
  23. package/dist/live/live-call.js +148 -0
  24. package/dist/live/live-call.js.map +1 -0
  25. package/dist/live/live-chat.d.ts +71 -0
  26. package/dist/live/live-chat.d.ts.map +1 -0
  27. package/dist/live/live-chat.js +95 -0
  28. package/dist/live/live-chat.js.map +1 -0
  29. package/dist/live/live-execution.d.ts +55 -0
  30. package/dist/live/live-execution.d.ts.map +1 -0
  31. package/dist/live/live-execution.js +170 -0
  32. package/dist/live/live-execution.js.map +1 -0
  33. package/dist/live/typed-emitter.d.ts +15 -0
  34. package/dist/live/typed-emitter.d.ts.map +1 -0
  35. package/dist/live/typed-emitter.js +40 -0
  36. package/dist/live/typed-emitter.js.map +1 -0
  37. package/dist/live/types.d.ts +24 -0
  38. package/dist/live/types.d.ts.map +1 -0
  39. package/dist/live/types.js +6 -0
  40. package/dist/live/types.js.map +1 -0
  41. package/dist/modules/agents.d.ts +378 -0
  42. package/dist/modules/agents.d.ts.map +1 -0
  43. package/dist/modules/agents.js +259 -0
  44. package/dist/modules/agents.js.map +1 -0
  45. package/dist/modules/alerts.d.ts +43 -0
  46. package/dist/modules/alerts.d.ts.map +1 -0
  47. package/dist/modules/alerts.js +56 -0
  48. package/dist/modules/alerts.js.map +1 -0
  49. package/dist/modules/audio.d.ts +47 -0
  50. package/dist/modules/audio.d.ts.map +1 -0
  51. package/dist/modules/audio.js +75 -0
  52. package/dist/modules/audio.js.map +1 -0
  53. package/dist/modules/auth.d.ts +76 -0
  54. package/dist/modules/auth.d.ts.map +1 -0
  55. package/dist/modules/auth.js +59 -0
  56. package/dist/modules/auth.js.map +1 -0
  57. package/dist/modules/calls.d.ts +825 -0
  58. package/dist/modules/calls.d.ts.map +1 -0
  59. package/dist/modules/calls.js +398 -0
  60. package/dist/modules/calls.js.map +1 -0
  61. package/dist/modules/chat.d.ts +165 -0
  62. package/dist/modules/chat.d.ts.map +1 -0
  63. package/dist/modules/chat.js +169 -0
  64. package/dist/modules/chat.js.map +1 -0
  65. package/dist/modules/health.d.ts +45 -0
  66. package/dist/modules/health.d.ts.map +1 -0
  67. package/dist/modules/health.js +22 -0
  68. package/dist/modules/health.js.map +1 -0
  69. package/dist/modules/knowledge.d.ts +202 -0
  70. package/dist/modules/knowledge.d.ts.map +1 -0
  71. package/dist/modules/knowledge.js +147 -0
  72. package/dist/modules/knowledge.js.map +1 -0
  73. package/dist/modules/mcp.d.ts +140 -0
  74. package/dist/modules/mcp.d.ts.map +1 -0
  75. package/dist/modules/mcp.js +110 -0
  76. package/dist/modules/mcp.js.map +1 -0
  77. package/dist/modules/memory.d.ts +163 -0
  78. package/dist/modules/memory.d.ts.map +1 -0
  79. package/dist/modules/memory.js +208 -0
  80. package/dist/modules/memory.js.map +1 -0
  81. package/dist/modules/personas.d.ts +168 -0
  82. package/dist/modules/personas.d.ts.map +1 -0
  83. package/dist/modules/personas.js +106 -0
  84. package/dist/modules/personas.js.map +1 -0
  85. package/dist/modules/prompts.d.ts +128 -0
  86. package/dist/modules/prompts.d.ts.map +1 -0
  87. package/dist/modules/prompts.js +93 -0
  88. package/dist/modules/prompts.js.map +1 -0
  89. package/dist/modules/scenarios.d.ts +294 -0
  90. package/dist/modules/scenarios.d.ts.map +1 -0
  91. package/dist/modules/scenarios.js +349 -0
  92. package/dist/modules/scenarios.js.map +1 -0
  93. package/dist/modules/scorecard.d.ts +642 -0
  94. package/dist/modules/scorecard.d.ts.map +1 -0
  95. package/dist/modules/scorecard.js +327 -0
  96. package/dist/modules/scorecard.js.map +1 -0
  97. package/dist/modules/tools.d.ts +222 -0
  98. package/dist/modules/tools.d.ts.map +1 -0
  99. package/dist/modules/tools.js +302 -0
  100. package/dist/modules/tools.js.map +1 -0
  101. package/dist/modules/toolsets.d.ts +173 -0
  102. package/dist/modules/toolsets.d.ts.map +1 -0
  103. package/dist/modules/toolsets.js +216 -0
  104. package/dist/modules/toolsets.js.map +1 -0
  105. package/dist/modules/transcript.d.ts +60 -0
  106. package/dist/modules/transcript.d.ts.map +1 -0
  107. package/dist/modules/transcript.js +69 -0
  108. package/dist/modules/transcript.js.map +1 -0
  109. package/dist/modules/workspace.d.ts +48 -0
  110. package/dist/modules/workspace.d.ts.map +1 -0
  111. package/dist/modules/workspace.js +49 -0
  112. package/dist/modules/workspace.js.map +1 -0
  113. package/dist/types/api.d.ts +8 -0
  114. package/dist/types/api.d.ts.map +1 -0
  115. package/dist/types/api.js +25 -0
  116. package/dist/types/api.js.map +1 -0
  117. package/dist/types/config.d.ts +70 -0
  118. package/dist/types/config.d.ts.map +1 -0
  119. package/dist/types/config.js +3 -0
  120. package/dist/types/config.js.map +1 -0
  121. package/dist/types/memory.d.ts +243 -0
  122. package/dist/types/memory.d.ts.map +1 -0
  123. package/dist/types/memory.js +9 -0
  124. package/dist/types/memory.js.map +1 -0
  125. package/dist/types/tool-calls.d.ts +61 -0
  126. package/dist/types/tool-calls.d.ts.map +1 -0
  127. package/dist/types/tool-calls.js +9 -0
  128. package/dist/types/tool-calls.js.map +1 -0
  129. package/dist/types/tools.d.ts +321 -0
  130. package/dist/types/tools.d.ts.map +1 -0
  131. package/dist/types/tools.js +9 -0
  132. package/dist/types/tools.js.map +1 -0
  133. package/dist/types/toolsets.d.ts +149 -0
  134. package/dist/types/toolsets.d.ts.map +1 -0
  135. package/dist/types/toolsets.js +8 -0
  136. package/dist/types/toolsets.js.map +1 -0
  137. package/package.json +60 -0
@@ -0,0 +1,825 @@
1
+ /**
2
+ * CallsModule - SDK module for call management
3
+ *
4
+ * Provides operations for:
5
+ * - Importing calls (transcript, audio URL, audio ID, S3)
6
+ * - Listing and querying calls (including external reference filtering)
7
+ * - Call analysis and evaluation
8
+ * - Metrics and transcripts
9
+ */
10
+ import { ChanlSDK } from '../client';
11
+ import { ApiResponse } from '../types/config';
12
+ import { ToolCall } from '../types/tool-calls';
13
+ /**
14
+ * Call direction - inbound (customer called), outbound (agent called), or web-based
15
+ */
16
+ export type CallDirection = 'inbound' | 'outbound' | 'web';
17
+ /**
18
+ * Call status - current state of the call
19
+ */
20
+ export type CallStatus = 'queued' | 'ringing' | 'in-progress' | 'forwarding' | 'ended' | 'failed';
21
+ /**
22
+ * Call origin - whether real call or simulated from scenario
23
+ */
24
+ export type CallOrigin = 'simulation' | 'real';
25
+ /**
26
+ * Analysis fields that can be requested during import
27
+ * When not specified, all fields are analyzed (default behavior)
28
+ */
29
+ export type AnalysisField = 'followups' | 'sentiment' | 'topics' | 'keywords' | 'coaching' | 'predictions' | 'quality' | 'speakers' | 'upsell' | 'metrics' | 'extraction';
30
+ /**
31
+ * Extraction field types supported
32
+ */
33
+ export type ExtractionFieldType = 'string' | 'number' | 'boolean' | 'date';
34
+ /**
35
+ * Structured transcript segment for import operations
36
+ * Uses startTime/endTime in milliseconds (differs from Transcript module's start/end)
37
+ */
38
+ export interface ImportTranscriptSegment {
39
+ /** Speaker role */
40
+ speaker: 'agent' | 'customer' | 'unknown';
41
+ /** Segment text content */
42
+ text: string;
43
+ /** Segment start time in milliseconds */
44
+ startTime?: number;
45
+ /** Segment end time in milliseconds */
46
+ endTime?: number;
47
+ }
48
+ /**
49
+ * Custom extraction field definition
50
+ * Used to extract business-specific data from call transcripts
51
+ */
52
+ export interface CustomExtractionField {
53
+ /** Unique key for this field (used in extractedData.custom response) */
54
+ key: string;
55
+ /** Human-readable label for this field */
56
+ label: string;
57
+ /** Data type for the extracted value */
58
+ type: ExtractionFieldType;
59
+ /** Description of what this field captures (helps LLM accuracy) */
60
+ description?: string;
61
+ /** Whether this field is required */
62
+ required?: boolean;
63
+ /** Hint for the LLM on how to find/extract this value */
64
+ promptHint?: string;
65
+ }
66
+ /**
67
+ * Extracted field value with confidence
68
+ */
69
+ export interface ExtractedValue {
70
+ value: string | number | boolean;
71
+ confidence: number;
72
+ source?: string;
73
+ }
74
+ /**
75
+ * Extracted data from call transcript
76
+ */
77
+ export interface ExtractedData {
78
+ customerId?: string;
79
+ customerEmail?: string;
80
+ customerPhone?: string;
81
+ orderNumber?: string;
82
+ accountNumber?: string;
83
+ custom?: Record<string, ExtractedValue>;
84
+ extractedAt?: string;
85
+ templateId?: string;
86
+ }
87
+ /**
88
+ * Options for importing a call
89
+ *
90
+ * Supports four input modes (at least one required):
91
+ * 1. S3 Import: bucket + region + accessKeyId + secretAccessKey + key
92
+ * 2. Audio URL: audioUrl (downloaded to storage)
93
+ * 3. Audio ID: audioId (reference pre-uploaded audio)
94
+ * 4. Transcript Only: transcript (skips Deepgram)
95
+ */
96
+ export interface CallImportOptions {
97
+ /** Pre-existing transcript - raw text or structured segments */
98
+ transcript?: string | ImportTranscriptSegment[];
99
+ /** Direct URL to audio file */
100
+ audioUrl?: string;
101
+ /** ID of pre-uploaded audio */
102
+ audioId?: string;
103
+ /** S3 bucket name */
104
+ bucket?: string;
105
+ /** S3 object key */
106
+ key?: string;
107
+ /** AWS region (use "auto" for Tigris) */
108
+ region?: string;
109
+ /** AWS access key ID */
110
+ accessKeyId?: string;
111
+ /** AWS secret access key */
112
+ secretAccessKey?: string;
113
+ /** Custom S3 endpoint for S3-compatible services */
114
+ endpoint?: string;
115
+ /** Agent ID to associate */
116
+ agentId?: string;
117
+ /** Customer name */
118
+ customerName?: string;
119
+ /** Customer phone number */
120
+ customerPhone?: string;
121
+ /** Agent name */
122
+ agentName?: string;
123
+ /** Agent phone number */
124
+ agentPhone?: string;
125
+ /** Call direction */
126
+ callDirection?: 'inbound' | 'outbound';
127
+ /** When the call started (ISO 8601) */
128
+ callStartedAt?: string;
129
+ /** When the call ended (ISO 8601) */
130
+ callEndedAt?: string;
131
+ /** Custom metadata */
132
+ metadata?: Record<string, unknown>;
133
+ /** Language code for transcription */
134
+ language?: string;
135
+ /** Customer-provided external reference IDs */
136
+ externalReferenceIds?: Record<string, string>;
137
+ /** Specific analysis fields to include (default: all) */
138
+ analysisFields?: AnalysisField[];
139
+ /** Scorecard ID to evaluate against */
140
+ scorecardId?: string;
141
+ /** Custom extraction fields (overrides workspace defaults) */
142
+ customExtractions?: CustomExtractionField[];
143
+ /** Extraction template ID */
144
+ extractionTemplateId?: string;
145
+ /** Skip extraction entirely */
146
+ skipExtraction?: boolean;
147
+ /** Webhook URL for analysis completion */
148
+ webhookUrl?: string;
149
+ /** Webhook secret for HMAC signature */
150
+ webhookSecret?: string;
151
+ }
152
+ /**
153
+ * Response from call import
154
+ */
155
+ export interface CallImportResponse {
156
+ /** Call ID (may be empty if created later by processor) */
157
+ callId: string;
158
+ /** Audio record ID */
159
+ audioId: string;
160
+ /** Storage key */
161
+ storageKey: string;
162
+ /** Original S3 key (for S3 imports) */
163
+ originalKey?: string;
164
+ /** File size in bytes */
165
+ fileSize: number;
166
+ /** Processing status */
167
+ processingStatus: 'pending' | 'processing' | 'completed' | 'failed';
168
+ /** Transcript ID (if provided directly) */
169
+ transcriptId?: string;
170
+ /** External reference IDs (echoed back) */
171
+ externalReferenceIds?: Record<string, string>;
172
+ /** Import mode used */
173
+ importMode?: 'transcriptOnly' | 'audioUrl' | 'audioId' | 's3';
174
+ }
175
+ /**
176
+ * Call entity - represents a call record
177
+ */
178
+ export interface Call {
179
+ id: string;
180
+ workspaceId: string;
181
+ scenarioId?: string;
182
+ scenarioExecutionId?: string;
183
+ agentId?: string;
184
+ personaId?: string;
185
+ provider: string;
186
+ providerCallId: string;
187
+ direction: CallDirection;
188
+ status: CallStatus;
189
+ origin: CallOrigin;
190
+ customerName: string;
191
+ customerPhone: string;
192
+ agentName: string;
193
+ agentPhone?: string;
194
+ startTime: string;
195
+ endTime?: string;
196
+ duration?: number;
197
+ cost?: number;
198
+ recordingUrl?: string;
199
+ transcriptId?: string;
200
+ audioId?: string;
201
+ scorecardResultIds?: string[];
202
+ score?: number;
203
+ demandsAction?: boolean;
204
+ externalReferenceIds?: Record<string, string>;
205
+ analysisStatus?: 'none' | 'pending' | 'processing' | 'completed' | 'failed';
206
+ analysisFields?: AnalysisField[];
207
+ summary?: CallSummary;
208
+ metrics?: CallMetricsData;
209
+ extractedData?: ExtractedData;
210
+ metadata?: {
211
+ escalationNeeded?: boolean;
212
+ tags?: string[];
213
+ customData?: Record<string, unknown>;
214
+ };
215
+ createdAt: string;
216
+ updatedAt: string;
217
+ }
218
+ /**
219
+ * Call summary - scorecard-independent analysis
220
+ */
221
+ export interface CallSummary {
222
+ sentiment?: {
223
+ beginning: 'positive' | 'neutral' | 'negative';
224
+ ending: 'positive' | 'neutral' | 'negative';
225
+ average: number;
226
+ trend: 'improving' | 'stable' | 'declining';
227
+ };
228
+ topics?: string[];
229
+ keywords?: string[];
230
+ callSummary?: string;
231
+ problem?: string;
232
+ resolution?: string;
233
+ language?: string;
234
+ speakers?: {
235
+ agent: {
236
+ speakerIndex: number;
237
+ name?: string;
238
+ confidence: number;
239
+ };
240
+ customer: {
241
+ speakerIndex: number;
242
+ name?: string;
243
+ confidence: number;
244
+ };
245
+ };
246
+ qualityMetrics?: {
247
+ resolutionConfidence: number;
248
+ customerEffortScore: number;
249
+ empathyScore: number;
250
+ escalationRisk: 'low' | 'medium' | 'high';
251
+ complianceScore: number;
252
+ agentConfidence: number;
253
+ issueComplexity: 'simple' | 'moderate' | 'complex';
254
+ };
255
+ predictions?: {
256
+ firstCallResolution: boolean;
257
+ callbackProbability: number;
258
+ customerSatisfactionPrediction: number;
259
+ };
260
+ coaching?: {
261
+ opportunities: string[];
262
+ knowledgeGaps: string[];
263
+ };
264
+ upsellOpportunity?: {
265
+ detected: boolean;
266
+ context: string | null;
267
+ };
268
+ actionItems?: {
269
+ agentCommitments: string[];
270
+ customerActions: string[];
271
+ followUpRequired: boolean;
272
+ followUpTimeframe?: string;
273
+ };
274
+ computedAt?: string;
275
+ }
276
+ /**
277
+ * Call metrics data structure
278
+ */
279
+ export interface CallMetricsData {
280
+ talkTime: {
281
+ agent: number;
282
+ customer: number;
283
+ total: number;
284
+ agentRatio: number;
285
+ customerRatio: number;
286
+ };
287
+ responseTime: {
288
+ agent: number;
289
+ customer: number;
290
+ average: number;
291
+ };
292
+ silence: {
293
+ maxDuration: number;
294
+ total: number;
295
+ average: number;
296
+ };
297
+ interruptions: {
298
+ agent: number;
299
+ customer: number;
300
+ total: number;
301
+ };
302
+ duration: number;
303
+ longestMonologue?: {
304
+ agent: number;
305
+ customer: number;
306
+ };
307
+ talkSpeed?: {
308
+ agent: number;
309
+ customer: number;
310
+ average: number;
311
+ };
312
+ questionCount?: {
313
+ agent: number;
314
+ customer: number;
315
+ total: number;
316
+ };
317
+ turnCount?: number;
318
+ }
319
+ /**
320
+ * Call filters for list operations
321
+ */
322
+ export interface CallFilters {
323
+ scenarioId?: string;
324
+ scenarioExecutionId?: string;
325
+ agentId?: string;
326
+ personaId?: string;
327
+ status?: string;
328
+ direction?: string;
329
+ origin?: string;
330
+ provider?: string;
331
+ customerName?: string;
332
+ customerPhone?: string;
333
+ startDate?: string;
334
+ endDate?: string;
335
+ demandsAction?: boolean;
336
+ /**
337
+ * External reference filters
338
+ * Keys map to externalReferenceIds stored on the call
339
+ * @example { orderId: 'ORDER-123', customerId: 'cust_789' }
340
+ */
341
+ externalRefs?: Record<string, string>;
342
+ page?: number;
343
+ limit?: number;
344
+ sortBy?: string;
345
+ sortOrder?: 'asc' | 'desc';
346
+ }
347
+ export interface CallListResponse {
348
+ calls: Call[];
349
+ pagination?: {
350
+ total: number;
351
+ page: number;
352
+ limit: number;
353
+ pages: number;
354
+ };
355
+ }
356
+ export interface CallResponse {
357
+ call: Call;
358
+ }
359
+ /**
360
+ * Options for updating a call
361
+ */
362
+ export interface UpdateCallOptions {
363
+ /** Call direction */
364
+ direction?: 'inbound' | 'outbound' | 'web';
365
+ /** Call status */
366
+ status?: CallStatus;
367
+ /** Customer name */
368
+ customerName?: string;
369
+ /** Customer phone number */
370
+ customerPhone?: string;
371
+ /** Agent name */
372
+ agentName?: string;
373
+ /** Agent phone number */
374
+ agentPhone?: string;
375
+ /** Agent ID */
376
+ agentId?: string;
377
+ /** Call metadata */
378
+ metadata?: {
379
+ escalationNeeded?: boolean;
380
+ tags?: string[];
381
+ customData?: Record<string, unknown>;
382
+ };
383
+ }
384
+ /**
385
+ * Options for bulk deleting calls
386
+ */
387
+ export interface BulkDeleteOptions {
388
+ /** Array of call IDs to delete (max 100) */
389
+ callIds: string[];
390
+ /** Also delete associated storage files (default: true) */
391
+ deleteStorageFiles?: boolean;
392
+ }
393
+ /**
394
+ * Response from bulk delete operation
395
+ */
396
+ export interface BulkDeleteResponse {
397
+ success: boolean;
398
+ deletedCount: number;
399
+ storageFilesDeleted: number;
400
+ failedIds?: string[];
401
+ error?: string;
402
+ }
403
+ export interface AnalyzeCallOptions {
404
+ scorecardId?: string;
405
+ forceReanalysis?: boolean;
406
+ force?: boolean;
407
+ }
408
+ export interface AnalyzeCallResponse {
409
+ callId: string;
410
+ resultId?: string;
411
+ status: 'queued' | 'no_scorecard' | 'no_transcript';
412
+ message?: string;
413
+ }
414
+ export interface CallScorecardResult {
415
+ id: string;
416
+ callId: string;
417
+ scorecardId: string;
418
+ overallScore?: number;
419
+ status?: string;
420
+ categoryScores?: Array<{
421
+ categoryId: string;
422
+ categoryName: string;
423
+ score: number;
424
+ weight: number;
425
+ }>;
426
+ criteriaResults?: Array<{
427
+ criterionId: string;
428
+ criterionName: string;
429
+ score: number;
430
+ feedback?: string;
431
+ evidence?: string;
432
+ }>;
433
+ feedback?: string;
434
+ createdAt: string;
435
+ updatedAt: string;
436
+ }
437
+ export interface CallAnalysisResponse {
438
+ results: CallScorecardResult[];
439
+ }
440
+ export interface CallMetrics {
441
+ callId: string;
442
+ metrics: {
443
+ talkTime?: {
444
+ total?: number;
445
+ agent?: number;
446
+ customer?: number;
447
+ };
448
+ responseTime?: {
449
+ average?: number;
450
+ max?: number;
451
+ };
452
+ silence?: {
453
+ total?: number;
454
+ count?: number;
455
+ };
456
+ interruptions?: {
457
+ total?: number;
458
+ byAgent?: number;
459
+ byCustomer?: number;
460
+ };
461
+ duration?: number;
462
+ longestMonologue?: {
463
+ speaker?: string;
464
+ duration?: number;
465
+ };
466
+ talkSpeed?: {
467
+ agent?: number;
468
+ customer?: number;
469
+ };
470
+ questionCount?: {
471
+ agent?: number;
472
+ customer?: number;
473
+ };
474
+ turnCount?: number;
475
+ };
476
+ }
477
+ export interface CallMetricsResponse {
478
+ callId: string;
479
+ metrics: CallMetrics['metrics'];
480
+ }
481
+ export interface CallTranscript {
482
+ id: string;
483
+ callId?: string;
484
+ audioId?: string;
485
+ text: string;
486
+ segments?: Array<{
487
+ speaker: string;
488
+ text: string;
489
+ start: number;
490
+ end: number;
491
+ confidence?: number;
492
+ }>;
493
+ toolCalls?: ToolCall[];
494
+ wordCount?: number;
495
+ speakerCount?: number;
496
+ language?: string;
497
+ confidence?: number;
498
+ status?: string;
499
+ createdAt: string;
500
+ updatedAt: string;
501
+ }
502
+ export interface CallTranscriptResponse {
503
+ transcript: CallTranscript | null;
504
+ }
505
+ /**
506
+ * Input for initiating an outbound call
507
+ */
508
+ export interface InitiateCallInput {
509
+ /** Agent ID to handle the call */
510
+ agentId: string;
511
+ /** Customer phone number in E.164 format (e.g., "+15551234567") */
512
+ phone: string;
513
+ /** Customer name (optional) */
514
+ customerName?: string;
515
+ /** Source phone number ID (from channels-service) */
516
+ phoneNumberId?: string;
517
+ /** Inline phone number object (alternative to phoneNumberId) */
518
+ phoneNumber?: {
519
+ number: string;
520
+ provider: string;
521
+ };
522
+ /** Scorecard ID to evaluate the call against */
523
+ scorecardId?: string;
524
+ /** Custom metadata */
525
+ metadata?: Record<string, unknown>;
526
+ }
527
+ /**
528
+ * Response from initiating a call
529
+ */
530
+ export interface InitiateCallResponse {
531
+ id: string;
532
+ status: CallStatus;
533
+ providerCallId?: string;
534
+ agentId: string;
535
+ customerPhone: string;
536
+ direction: 'outbound';
537
+ createdAt: string;
538
+ }
539
+ import { LiveCall } from '../live/live-call';
540
+ import type { LiveOptions } from '../live/types';
541
+ export declare class CallsModule {
542
+ private sdk;
543
+ constructor(sdk: ChanlSDK);
544
+ /**
545
+ * Initiate an outbound phone call
546
+ *
547
+ * Creates a new outbound call to the specified phone number using the given agent.
548
+ * Requires a source phone number (via phoneNumberId or phoneNumber object).
549
+ *
550
+ * @example
551
+ * ```typescript
552
+ * // Initiate with phone number ID
553
+ * const { data } = await sdk.calls.initiate({
554
+ * agentId: 'agent_abc',
555
+ * phone: '+15551234567',
556
+ * phoneNumberId: 'pn_xyz',
557
+ * });
558
+ * console.log('Call started:', data.id, data.status);
559
+ *
560
+ * // Initiate with inline phone number
561
+ * const { data } = await sdk.calls.initiate({
562
+ * agentId: 'agent_abc',
563
+ * phone: '+15551234567',
564
+ * phoneNumber: { number: '+18005551234', provider: 'twilio' },
565
+ * customerName: 'John Doe',
566
+ * });
567
+ * ```
568
+ */
569
+ initiate(input: InitiateCallInput): Promise<ApiResponse<InitiateCallResponse>>;
570
+ /**
571
+ * List all calls with optional filters
572
+ *
573
+ * Supports filtering by standard fields as well as external reference IDs.
574
+ * External refs use dot notation: `{ externalRefs: { orderId: 'ORDER-123' } }`
575
+ * becomes `?externalRef.orderId=ORDER-123` in the request.
576
+ *
577
+ * @example
578
+ * ```typescript
579
+ * // Basic listing
580
+ * const { data } = await sdk.calls.list();
581
+ * console.log(data.calls);
582
+ *
583
+ * // Filter by status and direction
584
+ * const { data } = await sdk.calls.list({
585
+ * status: 'ended',
586
+ * direction: 'inbound',
587
+ * page: 1,
588
+ * limit: 20
589
+ * });
590
+ *
591
+ * // Filter by external reference IDs
592
+ * const { data } = await sdk.calls.list({
593
+ * externalRefs: {
594
+ * orderId: 'ORDER-123',
595
+ * customerId: 'cust_456'
596
+ * }
597
+ * });
598
+ * ```
599
+ */
600
+ list(filters?: CallFilters): Promise<ApiResponse<CallListResponse>>;
601
+ /**
602
+ * Import a call from transcript, audio URL, audio ID, or S3
603
+ *
604
+ * Supports four input modes (at least one required):
605
+ * 1. **Transcript Only**: Provide transcript text or segments directly (skips Deepgram)
606
+ * 2. **Audio URL**: Download audio from a URL and transcribe
607
+ * 3. **Audio ID**: Reference pre-uploaded audio
608
+ * 4. **S3 Import**: Stream audio from S3 bucket
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * // Import with transcript text
613
+ * const { data } = await sdk.calls.import({
614
+ * transcript: 'Agent: Hello! Customer: Hi, I need help...',
615
+ * customerName: 'John Doe',
616
+ * externalReferenceIds: { orderId: 'ORDER-123' }
617
+ * });
618
+ *
619
+ * // Import with structured transcript segments
620
+ * const { data } = await sdk.calls.import({
621
+ * transcript: [
622
+ * { speaker: 'agent', text: 'Hello, how can I help?', startTime: 0, endTime: 2500 },
623
+ * { speaker: 'customer', text: 'I have a question about my order.', startTime: 2600, endTime: 5000 }
624
+ * ],
625
+ * scorecardId: 'scorecard_xyz',
626
+ * analysisFields: ['sentiment', 'topics', 'quality']
627
+ * });
628
+ *
629
+ * // Import from audio URL
630
+ * const { data } = await sdk.calls.import({
631
+ * audioUrl: 'https://example.com/recording.mp3',
632
+ * customerName: 'Jane Smith',
633
+ * agentName: 'Support Agent'
634
+ * });
635
+ *
636
+ * // Import from S3
637
+ * const { data } = await sdk.calls.import({
638
+ * bucket: 'my-recordings',
639
+ * key: 'calls/2024/recording.mp3',
640
+ * region: 'us-east-1',
641
+ * accessKeyId: 'AKIA...',
642
+ * secretAccessKey: '...',
643
+ * externalReferenceIds: { ticketId: 'TICKET-456' }
644
+ * });
645
+ *
646
+ * // Import with custom extraction fields
647
+ * const { data } = await sdk.calls.import({
648
+ * transcript: '...',
649
+ * customExtractions: [
650
+ * { key: 'claimNumber', label: 'Claim Number', type: 'string', description: 'Insurance claim ID' },
651
+ * { key: 'amount', label: 'Claim Amount', type: 'number' }
652
+ * ]
653
+ * });
654
+ * ```
655
+ */
656
+ import(options: CallImportOptions): Promise<ApiResponse<CallImportResponse>>;
657
+ /**
658
+ * Get a single call by ID
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const { data } = await sdk.calls.get('call_abc');
663
+ * console.log(data.call.status);
664
+ * ```
665
+ */
666
+ get(id: string): Promise<ApiResponse<CallResponse>>;
667
+ /**
668
+ * Update a call
669
+ *
670
+ * Updates call metadata and properties. Cannot update immutable fields
671
+ * like providerCallId or transcriptId.
672
+ *
673
+ * @example
674
+ * ```typescript
675
+ * const { data } = await sdk.calls.update('call_abc', {
676
+ * customerName: 'Updated Name',
677
+ * metadata: {
678
+ * tags: ['priority', 'follow-up'],
679
+ * customData: { priority: 'high' }
680
+ * }
681
+ * });
682
+ * ```
683
+ */
684
+ update(id: string, data: UpdateCallOptions): Promise<ApiResponse<CallResponse>>;
685
+ /**
686
+ * Delete a single call
687
+ *
688
+ * Removes the call from the database and optionally cleans up
689
+ * associated storage files. Does NOT delete from the provider.
690
+ *
691
+ * @example
692
+ * ```typescript
693
+ * await sdk.calls.delete('call_abc');
694
+ * ```
695
+ */
696
+ delete(id: string): Promise<ApiResponse<{
697
+ deleted: boolean;
698
+ }>>;
699
+ /**
700
+ * Bulk delete multiple calls
701
+ *
702
+ * Deletes up to 100 calls at once. Optionally cleans up associated
703
+ * storage files. Does NOT delete from the provider.
704
+ *
705
+ * @example
706
+ * ```typescript
707
+ * const { data } = await sdk.calls.bulkDelete('ws_123', {
708
+ * callIds: ['call_1', 'call_2', 'call_3'],
709
+ * deleteStorageFiles: true
710
+ * });
711
+ * console.log(`Deleted ${data.deletedCount} calls`);
712
+ * ```
713
+ */
714
+ bulkDelete(options: BulkDeleteOptions): Promise<ApiResponse<BulkDeleteResponse>>;
715
+ /**
716
+ * Trigger analysis for a call
717
+ *
718
+ * Analyzes the call using the appropriate scorecard. Automatically creates
719
+ * a transcript from provider data if missing.
720
+ *
721
+ * @example
722
+ * ```typescript
723
+ * // Analyze with default scorecard
724
+ * const { data } = await sdk.calls.analyze('call_abc');
725
+ * console.log('Status:', data.status);
726
+ *
727
+ * // Analyze with specific scorecard
728
+ * const { data } = await sdk.calls.analyze('call_abc', {
729
+ * scorecardId: 'scorecard_xyz',
730
+ * forceReanalysis: true
731
+ * });
732
+ * ```
733
+ */
734
+ analyze(callId: string, options?: AnalyzeCallOptions): Promise<ApiResponse<AnalyzeCallResponse>>;
735
+ /**
736
+ * Get analysis results (scorecard evaluations) for a call
737
+ *
738
+ * @example
739
+ * ```typescript
740
+ * const { data } = await sdk.calls.getAnalysis('ws_123', 'call_abc');
741
+ * for (const result of data.results) {
742
+ * console.log('Score:', result.overallScore);
743
+ * }
744
+ * ```
745
+ */
746
+ getAnalysis(callId: string): Promise<ApiResponse<CallAnalysisResponse>>;
747
+ /**
748
+ * Get call metrics
749
+ *
750
+ * Returns calculated metrics including talk time, response time, silence,
751
+ * interruptions, and enhanced metrics like longest monologue and talk speed.
752
+ *
753
+ * @example
754
+ * ```typescript
755
+ * const { data } = await sdk.calls.getMetrics('ws_123', 'call_abc');
756
+ * console.log('Talk time:', data.metrics.talkTime);
757
+ * console.log('Interruptions:', data.metrics.interruptions?.total);
758
+ * ```
759
+ */
760
+ getMetrics(callId: string): Promise<ApiResponse<CallMetricsResponse>>;
761
+ /**
762
+ * Get transcript for a call
763
+ *
764
+ * Fetches the complete transcript including speaker-segmented dialogue
765
+ * with timestamps, word count, confidence scores, and language detection.
766
+ *
767
+ * @example
768
+ * ```typescript
769
+ * const { data } = await sdk.calls.getTranscript('ws_123', 'call_abc');
770
+ * if (data.transcript) {
771
+ * console.log('Full text:', data.transcript.text);
772
+ * console.log('Segments:', data.transcript.segments?.length);
773
+ * }
774
+ * ```
775
+ */
776
+ getTranscript(callId: string): Promise<ApiResponse<CallTranscriptResponse>>;
777
+ /**
778
+ * Get scorecard evaluation results for a call
779
+ *
780
+ * Returns the scorecard results associated with a specific call,
781
+ * including category scores, criteria results, and overall score.
782
+ *
783
+ * @example
784
+ * ```typescript
785
+ * const { data } = await sdk.calls.getScorecard('ws_123', 'call_abc');
786
+ * console.log('Overall score:', data.results?.[0]?.overallScore);
787
+ * ```
788
+ */
789
+ getScorecard(callId: string): Promise<ApiResponse<CallAnalysisResponse>>;
790
+ /**
791
+ * Initiate a call and return a LiveCall monitor
792
+ *
793
+ * Combines `initiate()` with live monitoring. The returned `LiveCall`
794
+ * emits events as the call progresses and resolves `.completed` when done.
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * const live = await sdk.calls.start({
799
+ * agentId: 'agent_abc',
800
+ * phone: '+15551234567',
801
+ * phoneNumberId: 'pn_xyz',
802
+ * });
803
+ * live.on('transcript', (seg) => console.log(`${seg.speaker}: ${seg.text}`));
804
+ * live.on('ended', (sum) => console.log(`Call ${sum.status}`));
805
+ * await live.completed;
806
+ * ```
807
+ */
808
+ start(input: InitiateCallInput, options?: LiveOptions): Promise<LiveCall>;
809
+ /**
810
+ * Monitor an existing call
811
+ *
812
+ * Returns a LiveCall that polls the call's status and transcript,
813
+ * emitting typed events as data arrives.
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * const live = sdk.calls.watch('call_abc');
818
+ * live.on('status', (s) => console.log('Status:', s));
819
+ * live.on('transcript', (seg) => console.log(`${seg.speaker}: ${seg.text}`));
820
+ * await live.completed;
821
+ * ```
822
+ */
823
+ watch(callId: string, options?: LiveOptions): LiveCall;
824
+ }
825
+ //# sourceMappingURL=calls.d.ts.map