retell-sdk 4.30.0 → 4.31.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,570 @@
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
+ * End timestamp (milliseconds since epoch) of the chat. Available after chat ends.
115
+ */
116
+ end_timestamp?: number;
117
+
118
+ /**
119
+ * Transcript of the chat weaved with tool call invocation and results.
120
+ */
121
+ message_with_tool_calls?: Array<
122
+ | ChatResponse.Message
123
+ | ChatResponse.ToolCallInvocationMessage
124
+ | ChatResponse.ToolCallResultMessage
125
+ | ChatResponse.NodeTransitionMessage
126
+ | ChatResponse.StateTransitionMessage
127
+ >;
128
+
129
+ /**
130
+ * An arbitrary object for storage purpose only. You can put anything here like
131
+ * your internal customer id associated with the chat. Not used for processing. You
132
+ * can later get this field from the chat object.
133
+ */
134
+ metadata?: unknown;
135
+
136
+ /**
137
+ * Add optional dynamic variables in key value pairs of string that injects into
138
+ * your Response Engine prompt and tool description. Only applicable for Response
139
+ * Engine.
140
+ */
141
+ retell_llm_dynamic_variables?: Record<string, unknown>;
142
+
143
+ /**
144
+ * Begin timestamp (milliseconds since epoch) of the chat. Available after chat
145
+ * starts.
146
+ */
147
+ start_timestamp?: number;
148
+
149
+ /**
150
+ * Transcription of the chat.
151
+ */
152
+ transcript?: string;
153
+ }
154
+
155
+ export namespace ChatResponse {
156
+ /**
157
+ * Post chat analysis that includes information such as sentiment, status, summary,
158
+ * and custom defined data to extract. Available after chat ends. Subscribe to
159
+ * `chat_analyzed` webhook event type to receive it once ready.
160
+ */
161
+ export interface ChatAnalysis {
162
+ /**
163
+ * Whether the agent seems to have a successful chat with the user, where the agent
164
+ * finishes the task, and the call was complete without being cutoff.
165
+ */
166
+ chat_successful?: boolean;
167
+
168
+ /**
169
+ * A high level summary of the chat.
170
+ */
171
+ chat_summary?: string;
172
+
173
+ /**
174
+ * Custom analysis data that was extracted based on the schema defined in chat
175
+ * agent post chat analysis data. Can be empty if nothing is specified.
176
+ */
177
+ custom_analysis_data?: unknown;
178
+
179
+ /**
180
+ * Sentiment of the user in the chat.
181
+ */
182
+ user_sentiment?: 'Negative' | 'Positive' | 'Neutral' | 'Unknown';
183
+ }
184
+
185
+ export interface ChatCost {
186
+ /**
187
+ * Combined cost of all individual costs in cents
188
+ */
189
+ combined_cost?: number;
190
+
191
+ /**
192
+ * List of products with their unit prices and costs in cents
193
+ */
194
+ product_costs?: Array<ChatCost.ProductCost>;
195
+ }
196
+
197
+ export namespace ChatCost {
198
+ export interface ProductCost {
199
+ /**
200
+ * Cost for the product in cents for the duration of the call.
201
+ */
202
+ cost: number;
203
+
204
+ /**
205
+ * Product name that has a cost associated with it.
206
+ */
207
+ product: string;
208
+
209
+ /**
210
+ * Unit price of the product in cents per second.
211
+ */
212
+ unitPrice: number;
213
+ }
214
+ }
215
+
216
+ export interface Message {
217
+ /**
218
+ * Content of the message
219
+ */
220
+ content: string;
221
+
222
+ /**
223
+ * Create timestamp of the message
224
+ */
225
+ created_timestamp: number;
226
+
227
+ /**
228
+ * Unique id ot the message
229
+ */
230
+ message_id: string;
231
+
232
+ /**
233
+ * Documents whether this message is sent by agent or user.
234
+ */
235
+ role: 'agent' | 'user';
236
+ }
237
+
238
+ export interface ToolCallInvocationMessage {
239
+ /**
240
+ * Arguments for this tool call, it's a stringified JSON object.
241
+ */
242
+ arguments: string;
243
+
244
+ /**
245
+ * Unique id ot the message
246
+ */
247
+ message_id: string;
248
+
249
+ /**
250
+ * Name of the function in this tool call.
251
+ */
252
+ name: string;
253
+
254
+ /**
255
+ * This is a tool call invocation.
256
+ */
257
+ role: 'tool_call_invocation';
258
+
259
+ /**
260
+ * Tool call id, globally unique.
261
+ */
262
+ tool_call_id: string;
263
+
264
+ /**
265
+ * Create timestamp of the message
266
+ */
267
+ created_timestamp?: number;
268
+ }
269
+
270
+ export interface ToolCallResultMessage {
271
+ /**
272
+ * Result of the tool call, can be a string, a stringified json, etc.
273
+ */
274
+ content: string;
275
+
276
+ /**
277
+ * Create timestamp of the message
278
+ */
279
+ created_timestamp: number;
280
+
281
+ /**
282
+ * Unique id ot the message
283
+ */
284
+ message_id: string;
285
+
286
+ /**
287
+ * This is result of a tool call.
288
+ */
289
+ role: 'tool_call_result';
290
+
291
+ /**
292
+ * Tool call id, globally unique.
293
+ */
294
+ tool_call_id: string;
295
+ }
296
+
297
+ export interface NodeTransitionMessage {
298
+ /**
299
+ * Create timestamp of the message
300
+ */
301
+ created_timestamp: number;
302
+
303
+ /**
304
+ * Unique id ot the message
305
+ */
306
+ message_id: string;
307
+
308
+ /**
309
+ * This is node transition.
310
+ */
311
+ role: 'node_transition';
312
+
313
+ /**
314
+ * Former node id
315
+ */
316
+ former_node_id?: string;
317
+
318
+ /**
319
+ * Former node name
320
+ */
321
+ former_node_name?: string;
322
+
323
+ /**
324
+ * New node id
325
+ */
326
+ new_node_id?: string;
327
+
328
+ /**
329
+ * New node name
330
+ */
331
+ new_node_name?: string;
332
+ }
333
+
334
+ export interface StateTransitionMessage {
335
+ /**
336
+ * Create timestamp of the message
337
+ */
338
+ created_timestamp: number;
339
+
340
+ /**
341
+ * Unique id ot the message
342
+ */
343
+ message_id: string;
344
+
345
+ /**
346
+ * This is state transition for .
347
+ */
348
+ role: 'state_transition';
349
+
350
+ /**
351
+ * Former state name
352
+ */
353
+ former_state_name?: string;
354
+
355
+ /**
356
+ * New state name
357
+ */
358
+ new_state_name?: string;
359
+ }
360
+ }
361
+
362
+ export type ChatListResponse = Array<ChatResponse>;
363
+
364
+ export interface ChatCreateChatCompletionResponse {
365
+ /**
366
+ * Transcript of the chat completion weaved with tool call invocation and results.
367
+ */
368
+ messages: Array<
369
+ | ChatCreateChatCompletionResponse.Message
370
+ | ChatCreateChatCompletionResponse.ToolCallInvocationMessage
371
+ | ChatCreateChatCompletionResponse.ToolCallResultMessage
372
+ | ChatCreateChatCompletionResponse.NodeTransitionMessage
373
+ | ChatCreateChatCompletionResponse.StateTransitionMessage
374
+ >;
375
+ }
376
+
377
+ export namespace ChatCreateChatCompletionResponse {
378
+ export interface Message {
379
+ /**
380
+ * Content of the message
381
+ */
382
+ content: string;
383
+
384
+ /**
385
+ * Create timestamp of the message
386
+ */
387
+ created_timestamp: number;
388
+
389
+ /**
390
+ * Unique id ot the message
391
+ */
392
+ message_id: string;
393
+
394
+ /**
395
+ * Documents whether this message is sent by agent or user.
396
+ */
397
+ role: 'agent' | 'user';
398
+ }
399
+
400
+ export interface ToolCallInvocationMessage {
401
+ /**
402
+ * Arguments for this tool call, it's a stringified JSON object.
403
+ */
404
+ arguments: string;
405
+
406
+ /**
407
+ * Unique id ot the message
408
+ */
409
+ message_id: string;
410
+
411
+ /**
412
+ * Name of the function in this tool call.
413
+ */
414
+ name: string;
415
+
416
+ /**
417
+ * This is a tool call invocation.
418
+ */
419
+ role: 'tool_call_invocation';
420
+
421
+ /**
422
+ * Tool call id, globally unique.
423
+ */
424
+ tool_call_id: string;
425
+
426
+ /**
427
+ * Create timestamp of the message
428
+ */
429
+ created_timestamp?: number;
430
+ }
431
+
432
+ export interface ToolCallResultMessage {
433
+ /**
434
+ * Result of the tool call, can be a string, a stringified json, etc.
435
+ */
436
+ content: string;
437
+
438
+ /**
439
+ * Create timestamp of the message
440
+ */
441
+ created_timestamp: number;
442
+
443
+ /**
444
+ * Unique id ot the message
445
+ */
446
+ message_id: string;
447
+
448
+ /**
449
+ * This is result of a tool call.
450
+ */
451
+ role: 'tool_call_result';
452
+
453
+ /**
454
+ * Tool call id, globally unique.
455
+ */
456
+ tool_call_id: string;
457
+ }
458
+
459
+ export interface NodeTransitionMessage {
460
+ /**
461
+ * Create timestamp of the message
462
+ */
463
+ created_timestamp: number;
464
+
465
+ /**
466
+ * Unique id ot the message
467
+ */
468
+ message_id: string;
469
+
470
+ /**
471
+ * This is node transition.
472
+ */
473
+ role: 'node_transition';
474
+
475
+ /**
476
+ * Former node id
477
+ */
478
+ former_node_id?: string;
479
+
480
+ /**
481
+ * Former node name
482
+ */
483
+ former_node_name?: string;
484
+
485
+ /**
486
+ * New node id
487
+ */
488
+ new_node_id?: string;
489
+
490
+ /**
491
+ * New node name
492
+ */
493
+ new_node_name?: string;
494
+ }
495
+
496
+ export interface StateTransitionMessage {
497
+ /**
498
+ * Create timestamp of the message
499
+ */
500
+ created_timestamp: number;
501
+
502
+ /**
503
+ * Unique id ot the message
504
+ */
505
+ message_id: string;
506
+
507
+ /**
508
+ * This is state transition for .
509
+ */
510
+ role: 'state_transition';
511
+
512
+ /**
513
+ * Former state name
514
+ */
515
+ former_state_name?: string;
516
+
517
+ /**
518
+ * New state name
519
+ */
520
+ new_state_name?: string;
521
+ }
522
+ }
523
+
524
+ export interface ChatCreateParams {
525
+ /**
526
+ * The chat agent to use for the call.
527
+ */
528
+ agent_id: string;
529
+
530
+ /**
531
+ * The version of the chat agent to use for the call.
532
+ */
533
+ agent_version?: number;
534
+
535
+ /**
536
+ * An arbitrary object for storage purpose only. You can put anything here like
537
+ * your internal customer id associated with the chat. Not used for processing. You
538
+ * can later get this field from the chat object.
539
+ */
540
+ metadata?: unknown;
541
+
542
+ /**
543
+ * Add optional dynamic variables in key value pairs of string that injects into
544
+ * your Response Engine prompt and tool description. Only applicable for Response
545
+ * Engine.
546
+ */
547
+ retell_llm_dynamic_variables?: Record<string, unknown>;
548
+ }
549
+
550
+ export interface ChatCreateChatCompletionParams {
551
+ /**
552
+ * Unique id of the chat to create completion.
553
+ */
554
+ chat_id: string;
555
+
556
+ /**
557
+ * user message to generate agent chat completion.
558
+ */
559
+ content: string;
560
+ }
561
+
562
+ export declare namespace Chat {
563
+ export {
564
+ type ChatResponse as ChatResponse,
565
+ type ChatListResponse as ChatListResponse,
566
+ type ChatCreateChatCompletionResponse as ChatCreateChatCompletionResponse,
567
+ type ChatCreateParams as ChatCreateParams,
568
+ type ChatCreateChatCompletionParams as ChatCreateChatCompletionParams,
569
+ };
570
+ }
@@ -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.31.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.31.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.31.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.31.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map