retell-sdk 4.30.0 → 4.32.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.
@@ -0,0 +1,575 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../resource';
4
+ import * as Core from '../core';
5
+
6
+ export class Chat extends APIResource {
7
+ /**
8
+ * Create a chat session
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const chatResponse = await client.chat.create({
13
+ * agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
14
+ * });
15
+ * ```
16
+ */
17
+ create(body: ChatCreateParams, options?: Core.RequestOptions): Core.APIPromise<ChatResponse> {
18
+ return this._client.post('/create-chat', { body, ...options });
19
+ }
20
+
21
+ /**
22
+ * Retrieve details of a specific chat
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const chatResponse = await client.chat.retrieve(
27
+ * '16b980523634a6dc504898cda492e939',
28
+ * );
29
+ * ```
30
+ */
31
+ retrieve(chatId: string, options?: Core.RequestOptions): Core.APIPromise<ChatResponse> {
32
+ return this._client.get(`/get-chat/${chatId}`, options);
33
+ }
34
+
35
+ /**
36
+ * List all chats
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const chatResponses = await client.chat.list();
41
+ * ```
42
+ */
43
+ list(options?: Core.RequestOptions): Core.APIPromise<ChatListResponse> {
44
+ return this._client.get('/list-chat', options);
45
+ }
46
+
47
+ /**
48
+ * Create a chat completion message
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const response = await client.chat.createChatCompletion({
53
+ * chat_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD',
54
+ * content: 'hi how are you doing?',
55
+ * });
56
+ * ```
57
+ */
58
+ createChatCompletion(
59
+ body: ChatCreateChatCompletionParams,
60
+ options?: Core.RequestOptions,
61
+ ): Core.APIPromise<ChatCreateChatCompletionResponse> {
62
+ return this._client.post('/create-chat-completion', { body, ...options });
63
+ }
64
+
65
+ /**
66
+ * End an ongoing chat
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * await client.chat.end('16b980523634a6dc504898cda492e939');
71
+ * ```
72
+ */
73
+ end(chatId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
74
+ return this._client.patch(`/end-chat/${chatId}`, {
75
+ ...options,
76
+ headers: { Accept: '*/*', ...options?.headers },
77
+ });
78
+ }
79
+ }
80
+
81
+ export interface ChatResponse {
82
+ /**
83
+ * Corresponding chat agent id of this chat.
84
+ */
85
+ agent_id: string;
86
+
87
+ /**
88
+ * Unique id of the chat.
89
+ */
90
+ chat_id: string;
91
+
92
+ /**
93
+ * Status of chat.
94
+ *
95
+ * - `ongoing`: Chat session is ongoing, chat agent can receive new message and
96
+ * generate response.
97
+ *
98
+ * - `ended`: Chat session has ended can not generate new response.
99
+ *
100
+ * - `error`: Chat encountered error.
101
+ */
102
+ chat_status: 'ongoing' | 'ended' | 'error';
103
+
104
+ /**
105
+ * Post chat analysis that includes information such as sentiment, status, summary,
106
+ * and custom defined data to extract. Available after chat ends. Subscribe to
107
+ * `chat_analyzed` webhook event type to receive it once ready.
108
+ */
109
+ chat_analysis?: ChatResponse.ChatAnalysis;
110
+
111
+ chat_cost?: ChatResponse.ChatCost;
112
+
113
+ /**
114
+ * Dynamic variables collected from the chat. Only available after the chat ends.
115
+ */
116
+ collected_dynamic_variables?: Record<string, unknown>;
117
+
118
+ /**
119
+ * End timestamp (milliseconds since epoch) of the chat. Available after chat ends.
120
+ */
121
+ end_timestamp?: number;
122
+
123
+ /**
124
+ * Transcript of the chat weaved with tool call invocation and results.
125
+ */
126
+ message_with_tool_calls?: Array<
127
+ | ChatResponse.Message
128
+ | ChatResponse.ToolCallInvocationMessage
129
+ | ChatResponse.ToolCallResultMessage
130
+ | ChatResponse.NodeTransitionMessage
131
+ | ChatResponse.StateTransitionMessage
132
+ >;
133
+
134
+ /**
135
+ * An arbitrary object for storage purpose only. You can put anything here like
136
+ * your internal customer id associated with the chat. Not used for processing. You
137
+ * can later get this field from the chat object.
138
+ */
139
+ metadata?: unknown;
140
+
141
+ /**
142
+ * Add optional dynamic variables in key value pairs of string that injects into
143
+ * your Response Engine prompt and tool description. Only applicable for Response
144
+ * Engine.
145
+ */
146
+ retell_llm_dynamic_variables?: Record<string, unknown>;
147
+
148
+ /**
149
+ * Begin timestamp (milliseconds since epoch) of the chat. Available after chat
150
+ * starts.
151
+ */
152
+ start_timestamp?: number;
153
+
154
+ /**
155
+ * Transcription of the chat.
156
+ */
157
+ transcript?: string;
158
+ }
159
+
160
+ export namespace ChatResponse {
161
+ /**
162
+ * Post chat analysis that includes information such as sentiment, status, summary,
163
+ * and custom defined data to extract. Available after chat ends. Subscribe to
164
+ * `chat_analyzed` webhook event type to receive it once ready.
165
+ */
166
+ export interface ChatAnalysis {
167
+ /**
168
+ * Whether the agent seems to have a successful chat with the user, where the agent
169
+ * finishes the task, and the call was complete without being cutoff.
170
+ */
171
+ chat_successful?: boolean;
172
+
173
+ /**
174
+ * A high level summary of the chat.
175
+ */
176
+ chat_summary?: string;
177
+
178
+ /**
179
+ * Custom analysis data that was extracted based on the schema defined in chat
180
+ * agent post chat analysis data. Can be empty if nothing is specified.
181
+ */
182
+ custom_analysis_data?: unknown;
183
+
184
+ /**
185
+ * Sentiment of the user in the chat.
186
+ */
187
+ user_sentiment?: 'Negative' | 'Positive' | 'Neutral' | 'Unknown';
188
+ }
189
+
190
+ export interface ChatCost {
191
+ /**
192
+ * Combined cost of all individual costs in cents
193
+ */
194
+ combined_cost?: number;
195
+
196
+ /**
197
+ * List of products with their unit prices and costs in cents
198
+ */
199
+ product_costs?: Array<ChatCost.ProductCost>;
200
+ }
201
+
202
+ export namespace ChatCost {
203
+ export interface ProductCost {
204
+ /**
205
+ * Cost for the product in cents for the duration of the call.
206
+ */
207
+ cost: number;
208
+
209
+ /**
210
+ * Product name that has a cost associated with it.
211
+ */
212
+ product: string;
213
+
214
+ /**
215
+ * Unit price of the product in cents per second.
216
+ */
217
+ unitPrice: number;
218
+ }
219
+ }
220
+
221
+ export interface Message {
222
+ /**
223
+ * Content of the message
224
+ */
225
+ content: string;
226
+
227
+ /**
228
+ * Create timestamp of the message
229
+ */
230
+ created_timestamp: number;
231
+
232
+ /**
233
+ * Unique id ot the message
234
+ */
235
+ message_id: string;
236
+
237
+ /**
238
+ * Documents whether this message is sent by agent or user.
239
+ */
240
+ role: 'agent' | 'user';
241
+ }
242
+
243
+ export interface ToolCallInvocationMessage {
244
+ /**
245
+ * Arguments for this tool call, it's a stringified JSON object.
246
+ */
247
+ arguments: string;
248
+
249
+ /**
250
+ * Unique id ot the message
251
+ */
252
+ message_id: string;
253
+
254
+ /**
255
+ * Name of the function in this tool call.
256
+ */
257
+ name: string;
258
+
259
+ /**
260
+ * This is a tool call invocation.
261
+ */
262
+ role: 'tool_call_invocation';
263
+
264
+ /**
265
+ * Tool call id, globally unique.
266
+ */
267
+ tool_call_id: string;
268
+
269
+ /**
270
+ * Create timestamp of the message
271
+ */
272
+ created_timestamp?: number;
273
+ }
274
+
275
+ export interface ToolCallResultMessage {
276
+ /**
277
+ * Result of the tool call, can be a string, a stringified json, etc.
278
+ */
279
+ content: string;
280
+
281
+ /**
282
+ * Create timestamp of the message
283
+ */
284
+ created_timestamp: number;
285
+
286
+ /**
287
+ * Unique id ot the message
288
+ */
289
+ message_id: string;
290
+
291
+ /**
292
+ * This is result of a tool call.
293
+ */
294
+ role: 'tool_call_result';
295
+
296
+ /**
297
+ * Tool call id, globally unique.
298
+ */
299
+ tool_call_id: string;
300
+ }
301
+
302
+ export interface NodeTransitionMessage {
303
+ /**
304
+ * Create timestamp of the message
305
+ */
306
+ created_timestamp: number;
307
+
308
+ /**
309
+ * Unique id ot the message
310
+ */
311
+ message_id: string;
312
+
313
+ /**
314
+ * This is node transition.
315
+ */
316
+ role: 'node_transition';
317
+
318
+ /**
319
+ * Former node id
320
+ */
321
+ former_node_id?: string;
322
+
323
+ /**
324
+ * Former node name
325
+ */
326
+ former_node_name?: string;
327
+
328
+ /**
329
+ * New node id
330
+ */
331
+ new_node_id?: string;
332
+
333
+ /**
334
+ * New node name
335
+ */
336
+ new_node_name?: string;
337
+ }
338
+
339
+ export interface StateTransitionMessage {
340
+ /**
341
+ * Create timestamp of the message
342
+ */
343
+ created_timestamp: number;
344
+
345
+ /**
346
+ * Unique id ot the message
347
+ */
348
+ message_id: string;
349
+
350
+ /**
351
+ * This is state transition for .
352
+ */
353
+ role: 'state_transition';
354
+
355
+ /**
356
+ * Former state name
357
+ */
358
+ former_state_name?: string;
359
+
360
+ /**
361
+ * New state name
362
+ */
363
+ new_state_name?: string;
364
+ }
365
+ }
366
+
367
+ export type ChatListResponse = Array<ChatResponse>;
368
+
369
+ export interface ChatCreateChatCompletionResponse {
370
+ /**
371
+ * Transcript of the chat completion weaved with tool call invocation and results.
372
+ */
373
+ messages: Array<
374
+ | ChatCreateChatCompletionResponse.Message
375
+ | ChatCreateChatCompletionResponse.ToolCallInvocationMessage
376
+ | ChatCreateChatCompletionResponse.ToolCallResultMessage
377
+ | ChatCreateChatCompletionResponse.NodeTransitionMessage
378
+ | ChatCreateChatCompletionResponse.StateTransitionMessage
379
+ >;
380
+ }
381
+
382
+ export namespace ChatCreateChatCompletionResponse {
383
+ export interface Message {
384
+ /**
385
+ * Content of the message
386
+ */
387
+ content: string;
388
+
389
+ /**
390
+ * Create timestamp of the message
391
+ */
392
+ created_timestamp: number;
393
+
394
+ /**
395
+ * Unique id ot the message
396
+ */
397
+ message_id: string;
398
+
399
+ /**
400
+ * Documents whether this message is sent by agent or user.
401
+ */
402
+ role: 'agent' | 'user';
403
+ }
404
+
405
+ export interface ToolCallInvocationMessage {
406
+ /**
407
+ * Arguments for this tool call, it's a stringified JSON object.
408
+ */
409
+ arguments: string;
410
+
411
+ /**
412
+ * Unique id ot the message
413
+ */
414
+ message_id: string;
415
+
416
+ /**
417
+ * Name of the function in this tool call.
418
+ */
419
+ name: string;
420
+
421
+ /**
422
+ * This is a tool call invocation.
423
+ */
424
+ role: 'tool_call_invocation';
425
+
426
+ /**
427
+ * Tool call id, globally unique.
428
+ */
429
+ tool_call_id: string;
430
+
431
+ /**
432
+ * Create timestamp of the message
433
+ */
434
+ created_timestamp?: number;
435
+ }
436
+
437
+ export interface ToolCallResultMessage {
438
+ /**
439
+ * Result of the tool call, can be a string, a stringified json, etc.
440
+ */
441
+ content: string;
442
+
443
+ /**
444
+ * Create timestamp of the message
445
+ */
446
+ created_timestamp: number;
447
+
448
+ /**
449
+ * Unique id ot the message
450
+ */
451
+ message_id: string;
452
+
453
+ /**
454
+ * This is result of a tool call.
455
+ */
456
+ role: 'tool_call_result';
457
+
458
+ /**
459
+ * Tool call id, globally unique.
460
+ */
461
+ tool_call_id: string;
462
+ }
463
+
464
+ export interface NodeTransitionMessage {
465
+ /**
466
+ * Create timestamp of the message
467
+ */
468
+ created_timestamp: number;
469
+
470
+ /**
471
+ * Unique id ot the message
472
+ */
473
+ message_id: string;
474
+
475
+ /**
476
+ * This is node transition.
477
+ */
478
+ role: 'node_transition';
479
+
480
+ /**
481
+ * Former node id
482
+ */
483
+ former_node_id?: string;
484
+
485
+ /**
486
+ * Former node name
487
+ */
488
+ former_node_name?: string;
489
+
490
+ /**
491
+ * New node id
492
+ */
493
+ new_node_id?: string;
494
+
495
+ /**
496
+ * New node name
497
+ */
498
+ new_node_name?: string;
499
+ }
500
+
501
+ export interface StateTransitionMessage {
502
+ /**
503
+ * Create timestamp of the message
504
+ */
505
+ created_timestamp: number;
506
+
507
+ /**
508
+ * Unique id ot the message
509
+ */
510
+ message_id: string;
511
+
512
+ /**
513
+ * This is state transition for .
514
+ */
515
+ role: 'state_transition';
516
+
517
+ /**
518
+ * Former state name
519
+ */
520
+ former_state_name?: string;
521
+
522
+ /**
523
+ * New state name
524
+ */
525
+ new_state_name?: string;
526
+ }
527
+ }
528
+
529
+ export interface ChatCreateParams {
530
+ /**
531
+ * The chat agent to use for the call.
532
+ */
533
+ agent_id: string;
534
+
535
+ /**
536
+ * The version of the chat agent to use for the call.
537
+ */
538
+ agent_version?: number;
539
+
540
+ /**
541
+ * An arbitrary object for storage purpose only. You can put anything here like
542
+ * your internal customer id associated with the chat. Not used for processing. You
543
+ * can later get this field from the chat object.
544
+ */
545
+ metadata?: unknown;
546
+
547
+ /**
548
+ * Add optional dynamic variables in key value pairs of string that injects into
549
+ * your Response Engine prompt and tool description. Only applicable for Response
550
+ * Engine.
551
+ */
552
+ retell_llm_dynamic_variables?: Record<string, unknown>;
553
+ }
554
+
555
+ export interface ChatCreateChatCompletionParams {
556
+ /**
557
+ * Unique id of the chat to create completion.
558
+ */
559
+ chat_id: string;
560
+
561
+ /**
562
+ * user message to generate agent chat completion.
563
+ */
564
+ content: string;
565
+ }
566
+
567
+ export declare namespace Chat {
568
+ export {
569
+ type ChatResponse as ChatResponse,
570
+ type ChatListResponse as ChatListResponse,
571
+ type ChatCreateChatCompletionResponse as ChatCreateChatCompletionResponse,
572
+ type ChatCreateParams as ChatCreateParams,
573
+ type ChatCreateChatCompletionParams as ChatCreateChatCompletionParams,
574
+ };
575
+ }
@@ -22,6 +22,14 @@ export {
22
22
  type CallCreateWebCallParams,
23
23
  type CallRegisterPhoneCallParams,
24
24
  } from './call';
25
+ export {
26
+ Chat,
27
+ type ChatResponse,
28
+ type ChatListResponse,
29
+ type ChatCreateChatCompletionResponse,
30
+ type ChatCreateParams,
31
+ type ChatCreateChatCompletionParams,
32
+ } from './chat';
25
33
  export { Concurrency, type ConcurrencyRetrieveResponse } from './concurrency';
26
34
  export {
27
35
  KnowledgeBase,
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.30.0'; // x-release-please-version
1
+ export const VERSION = '4.32.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.30.0";
1
+ export declare const VERSION = "4.32.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '4.30.0'; // x-release-please-version
4
+ exports.VERSION = '4.32.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.30.0'; // x-release-please-version
1
+ export const VERSION = '4.32.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map