phonic 0.23.0 → 0.24.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/README.md +101 -10
- package/dist/index.d.mts +55 -27
- package/dist/index.d.ts +55 -27
- package/dist/index.js +48 -48
- package/dist/index.mjs +48 -48
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -23,8 +23,8 @@ Node.js library for the Phonic API.
|
|
|
23
23
|
- [List conversations](#list-conversations)
|
|
24
24
|
- [Get conversation by id](#get-conversation-by-id)
|
|
25
25
|
- [Get conversation by external id](#get-conversation-by-external-id)
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
26
|
+
- [Outbound call](#outbound-call)
|
|
27
|
+
- [Outbound call using own Twilio account](#outbound-call-using-own-twilio-account)
|
|
28
28
|
- [STS via WebSocket](#sts-via-websocket)
|
|
29
29
|
- [Messages that Phonic sends back to you](#messages-that-phonic-sends-back-to-you)
|
|
30
30
|
- [License](#license)
|
|
@@ -280,10 +280,10 @@ const conversationResult = await phonic.conversations.getByExternalId({
|
|
|
280
280
|
});
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
### Outbound call
|
|
284
284
|
|
|
285
285
|
```ts
|
|
286
|
-
const
|
|
286
|
+
const outboundCallResult = await phonic.conversations.outboundCall("+19189396241", {
|
|
287
287
|
// Optional fields
|
|
288
288
|
welcome_message: "Hello, how can I help you?",
|
|
289
289
|
project: "main",
|
|
@@ -294,16 +294,16 @@ const { data, error } = await phonic.sts.outboundCall("+19189396241", {
|
|
|
294
294
|
vad_min_speech_duration_ms: 40,
|
|
295
295
|
vad_min_silence_duration_ms: 550,
|
|
296
296
|
vad_threshold: 0.6,
|
|
297
|
-
tools: ["
|
|
297
|
+
tools: ["keypad_input", "natural_conversation_ending"]
|
|
298
298
|
});
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
### Outbound call using own Twilio account
|
|
302
302
|
|
|
303
303
|
In Twilio, create a restricted API key with the following permissions: `voice -> calls -> read` and `voice -> calls -> create`.
|
|
304
304
|
|
|
305
305
|
```ts
|
|
306
|
-
const
|
|
306
|
+
const twilioOutboundCallResult = await phonic.conversations.twilio.outboundCall(
|
|
307
307
|
{
|
|
308
308
|
account_sid: "AC...",
|
|
309
309
|
api_key_sid: "SK...",
|
|
@@ -322,7 +322,7 @@ const { data, error } = await phonic.sts.twilio.outboundCall(
|
|
|
322
322
|
vad_min_speech_duration_ms: 40,
|
|
323
323
|
vad_min_silence_duration_ms: 550,
|
|
324
324
|
vad_threshold: 0.6,
|
|
325
|
-
tools: ["
|
|
325
|
+
tools: ["keypad_input", "natural_conversation_ending"]
|
|
326
326
|
}
|
|
327
327
|
);
|
|
328
328
|
```
|
|
@@ -346,7 +346,7 @@ const phonicWebSocket = phonic.sts.websocket({
|
|
|
346
346
|
vad_min_speech_duration_ms: 40,
|
|
347
347
|
vad_min_silence_duration_ms: 550,
|
|
348
348
|
vad_threshold: 0.6,
|
|
349
|
-
tools: ["
|
|
349
|
+
tools: ["keypad_input", "natural_conversation_ending"]
|
|
350
350
|
});
|
|
351
351
|
```
|
|
352
352
|
|
|
@@ -423,6 +423,27 @@ phonicWebSocket.onError((event) => {
|
|
|
423
423
|
|
|
424
424
|
### Messages that Phonic sends back to you
|
|
425
425
|
|
|
426
|
+
#### `conversation_created`
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
{
|
|
430
|
+
type: "conversation_created";
|
|
431
|
+
conversation_id: string;
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Sent when the conversation has been successfully created.
|
|
436
|
+
|
|
437
|
+
#### `ready_to_start_conversation`
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
{
|
|
441
|
+
type: "ready_to_start_conversation";
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Sent when Phonic is ready to begin processing audio. You should start sending audio chunks after receiving this message.
|
|
446
|
+
|
|
426
447
|
#### `input_text`
|
|
427
448
|
|
|
428
449
|
```ts
|
|
@@ -456,6 +477,26 @@ These are the assistant response audio chunks.
|
|
|
456
477
|
|
|
457
478
|
Sent after the last "audio_chunk" is sent.
|
|
458
479
|
|
|
480
|
+
#### `user_started_speaking`
|
|
481
|
+
|
|
482
|
+
```ts
|
|
483
|
+
{
|
|
484
|
+
type: "user_started_speaking";
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Sent when the user begins speaking.
|
|
489
|
+
|
|
490
|
+
#### `user_finished_speaking`
|
|
491
|
+
|
|
492
|
+
```ts
|
|
493
|
+
{
|
|
494
|
+
type: "user_finished_speaking";
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Sent when the user stops speaking.
|
|
499
|
+
|
|
459
500
|
#### `interrupted_response`
|
|
460
501
|
|
|
461
502
|
```ts
|
|
@@ -467,7 +508,17 @@ Sent after the last "audio_chunk" is sent.
|
|
|
467
508
|
|
|
468
509
|
Sent when the user interrupts the assistant, after the user has finished speaking.
|
|
469
510
|
|
|
470
|
-
|
|
511
|
+
#### `assistant_chose_not_to_respond`
|
|
512
|
+
|
|
513
|
+
```ts
|
|
514
|
+
{
|
|
515
|
+
type: "assistant_chose_not_to_respond";
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Sent when the assistant decides not to respond to the user's input.
|
|
520
|
+
|
|
521
|
+
#### `assistant_ended_conversation`
|
|
471
522
|
|
|
472
523
|
```ts
|
|
473
524
|
{
|
|
@@ -477,6 +528,46 @@ Sent when the user interrupts the assistant, after the user has finished speakin
|
|
|
477
528
|
|
|
478
529
|
Sent when the assistant decides to end the conversation.
|
|
479
530
|
|
|
531
|
+
#### `tool_call`
|
|
532
|
+
|
|
533
|
+
```ts
|
|
534
|
+
{
|
|
535
|
+
type: "tool_call";
|
|
536
|
+
id: string;
|
|
537
|
+
tool: {
|
|
538
|
+
id: string;
|
|
539
|
+
name: string;
|
|
540
|
+
};
|
|
541
|
+
endpoint_url: string | null;
|
|
542
|
+
endpoint_timeout_ms: number | null;
|
|
543
|
+
endpoint_called_at: string | null;
|
|
544
|
+
request_body: object | null;
|
|
545
|
+
response_body: object | null;
|
|
546
|
+
response_status_code: number | null;
|
|
547
|
+
timed_out: boolean | null;
|
|
548
|
+
error_message: string | null;
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
Sent when a tool is called during the conversation. Built-in tools will have null values for endpoint-related fields.
|
|
552
|
+
|
|
553
|
+
When a custom tool is called, the `request_body` field always includes a `call_info` field.
|
|
554
|
+
If the conversation is not a phone call, `call_info` will be `null`. If it is a phone call, `call_info` will be an object with `from_phone_number` and `to_phone_number` fields, both formatted as E.164 phone numbers (e.g., "+1234567890").
|
|
555
|
+
|
|
556
|
+
#### `error`
|
|
557
|
+
|
|
558
|
+
```ts
|
|
559
|
+
{
|
|
560
|
+
type: "error";
|
|
561
|
+
error: {
|
|
562
|
+
message: string;
|
|
563
|
+
code?: string;
|
|
564
|
+
};
|
|
565
|
+
param_errors?: Record<string, string>;
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
Sent when an error occurs during the conversation.
|
|
570
|
+
|
|
480
571
|
## License
|
|
481
572
|
|
|
482
573
|
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -57,6 +57,9 @@ interface PhonicSTSConfigWithProject extends PhonicSTSConfigBase {
|
|
|
57
57
|
}
|
|
58
58
|
type PhonicSTSConfig = PhonicSTSConfigWithAgent | PhonicSTSConfigWithProject;
|
|
59
59
|
type PhonicSTSWebSocketResponseMessage = {
|
|
60
|
+
type: "conversation_created";
|
|
61
|
+
conversation_id: string;
|
|
62
|
+
} | {
|
|
60
63
|
type: "ready_to_start_conversation";
|
|
61
64
|
} | {
|
|
62
65
|
type: "input_text";
|
|
@@ -65,14 +68,40 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
65
68
|
type: "audio_chunk";
|
|
66
69
|
text: string;
|
|
67
70
|
audio: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "audio_finished";
|
|
68
73
|
} | {
|
|
69
74
|
type: "is_user_speaking";
|
|
70
75
|
isUserSpeaking: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
type: "user_started_speaking";
|
|
78
|
+
} | {
|
|
79
|
+
type: "user_finished_speaking";
|
|
71
80
|
} | {
|
|
72
81
|
type: "interrupted_response";
|
|
73
82
|
interruptedResponse: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: "assistant_chose_not_to_respond";
|
|
74
85
|
} | {
|
|
75
86
|
type: "assistant_ended_conversation";
|
|
87
|
+
} | {
|
|
88
|
+
type: "dtmf";
|
|
89
|
+
digits: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: "tool_call";
|
|
92
|
+
id: string;
|
|
93
|
+
tool: {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
endpoint_url: string | null;
|
|
98
|
+
endpoint_timeout_ms: number | null;
|
|
99
|
+
endpoint_called_at: string | null;
|
|
100
|
+
request_body: object | null;
|
|
101
|
+
response_body: object | null;
|
|
102
|
+
response_status_code: number | null;
|
|
103
|
+
timed_out: boolean | null;
|
|
104
|
+
error_message: string | null;
|
|
76
105
|
} | {
|
|
77
106
|
type: "error";
|
|
78
107
|
error: {
|
|
@@ -90,10 +119,6 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
90
119
|
type OnMessageCallback = (message: PhonicSTSWebSocketResponseMessage) => void;
|
|
91
120
|
type OnCloseCallback = (event: WebSocket.CloseEvent) => void;
|
|
92
121
|
type OnErrorCallback = (event: WebSocket.ErrorEvent) => void;
|
|
93
|
-
type PhonicSTSOutboundCallConfig = Omit<PhonicSTSConfig, "input_format" | "output_format">;
|
|
94
|
-
type OutboundCallSuccessResponse = {
|
|
95
|
-
success: true;
|
|
96
|
-
};
|
|
97
122
|
type PhonicTool = "send_dtmf_tone" | "end_conversation";
|
|
98
123
|
type PhonicConfigurationEndpointRequestPayload = {
|
|
99
124
|
project: {
|
|
@@ -263,41 +288,46 @@ type ConversationSuccessResponse = {
|
|
|
263
288
|
type ConversationsSuccessResponse = {
|
|
264
289
|
conversations: Array<Conversation>;
|
|
265
290
|
};
|
|
291
|
+
type OutboundCallConfig = Omit<PhonicSTSConfigWithAgent, "input_format" | "output_format"> | Omit<PhonicSTSConfigWithProject, "input_format" | "output_format">;
|
|
292
|
+
type OutboundCallSuccessResponse = {
|
|
293
|
+
conversation_id: string;
|
|
294
|
+
};
|
|
266
295
|
|
|
267
|
-
|
|
268
|
-
private readonly phonic;
|
|
269
|
-
constructor(phonic: Phonic);
|
|
270
|
-
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
271
|
-
getByExternalId({ project, externalId, }: {
|
|
272
|
-
project?: string;
|
|
273
|
-
externalId: string;
|
|
274
|
-
}): DataOrError<ConversationSuccessResponse>;
|
|
275
|
-
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
276
|
-
project?: string;
|
|
277
|
-
durationMin?: number;
|
|
278
|
-
durationMax?: number;
|
|
279
|
-
startedAtMin?: ISODate | ISODateTime$1;
|
|
280
|
-
startedAtMax?: ISODate | ISODateTime$1;
|
|
281
|
-
}): DataOrError<ConversationsSuccessResponse>;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
type PhonicSTSTwilioOutboundCallParams = {
|
|
296
|
+
type TwilioOutboundCallParams = {
|
|
285
297
|
account_sid: string;
|
|
286
298
|
api_key_sid: string;
|
|
287
299
|
api_key_secret: string;
|
|
288
300
|
from_phone_number: string;
|
|
289
301
|
to_phone_number: string;
|
|
290
302
|
};
|
|
291
|
-
type
|
|
303
|
+
type TwilioOutboundCallConfig = OutboundCallConfig;
|
|
292
304
|
type TwilioOutboundCallSuccessResponse = {
|
|
293
|
-
success: true;
|
|
294
305
|
callSid: string;
|
|
295
306
|
};
|
|
296
307
|
|
|
297
308
|
declare class Twilio {
|
|
298
309
|
private readonly phonic;
|
|
299
310
|
constructor(phonic: Phonic);
|
|
300
|
-
outboundCall(params:
|
|
311
|
+
outboundCall(params: TwilioOutboundCallParams, config: TwilioOutboundCallConfig): DataOrError<TwilioOutboundCallSuccessResponse>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class Conversations {
|
|
315
|
+
private readonly phonic;
|
|
316
|
+
readonly twilio: Twilio;
|
|
317
|
+
constructor(phonic: Phonic);
|
|
318
|
+
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
319
|
+
project?: string;
|
|
320
|
+
durationMin?: number;
|
|
321
|
+
durationMax?: number;
|
|
322
|
+
startedAtMin?: ISODate | ISODateTime$1;
|
|
323
|
+
startedAtMax?: ISODate | ISODateTime$1;
|
|
324
|
+
}): DataOrError<ConversationsSuccessResponse>;
|
|
325
|
+
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
326
|
+
getByExternalId({ project, externalId, }: {
|
|
327
|
+
project?: string;
|
|
328
|
+
externalId: string;
|
|
329
|
+
}): DataOrError<ConversationSuccessResponse>;
|
|
330
|
+
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
301
331
|
}
|
|
302
332
|
|
|
303
333
|
declare class PhonicSTSWebSocket {
|
|
@@ -326,10 +356,8 @@ declare class PhonicSTSWebSocket {
|
|
|
326
356
|
|
|
327
357
|
declare class SpeechToSpeech {
|
|
328
358
|
private readonly phonic;
|
|
329
|
-
readonly twilio: Twilio;
|
|
330
359
|
constructor(phonic: Phonic);
|
|
331
360
|
websocket(config: PhonicSTSConfig): PhonicSTSWebSocket;
|
|
332
|
-
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
333
361
|
}
|
|
334
362
|
|
|
335
363
|
interface ParameterBase {
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,9 @@ interface PhonicSTSConfigWithProject extends PhonicSTSConfigBase {
|
|
|
57
57
|
}
|
|
58
58
|
type PhonicSTSConfig = PhonicSTSConfigWithAgent | PhonicSTSConfigWithProject;
|
|
59
59
|
type PhonicSTSWebSocketResponseMessage = {
|
|
60
|
+
type: "conversation_created";
|
|
61
|
+
conversation_id: string;
|
|
62
|
+
} | {
|
|
60
63
|
type: "ready_to_start_conversation";
|
|
61
64
|
} | {
|
|
62
65
|
type: "input_text";
|
|
@@ -65,14 +68,40 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
65
68
|
type: "audio_chunk";
|
|
66
69
|
text: string;
|
|
67
70
|
audio: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "audio_finished";
|
|
68
73
|
} | {
|
|
69
74
|
type: "is_user_speaking";
|
|
70
75
|
isUserSpeaking: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
type: "user_started_speaking";
|
|
78
|
+
} | {
|
|
79
|
+
type: "user_finished_speaking";
|
|
71
80
|
} | {
|
|
72
81
|
type: "interrupted_response";
|
|
73
82
|
interruptedResponse: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: "assistant_chose_not_to_respond";
|
|
74
85
|
} | {
|
|
75
86
|
type: "assistant_ended_conversation";
|
|
87
|
+
} | {
|
|
88
|
+
type: "dtmf";
|
|
89
|
+
digits: string;
|
|
90
|
+
} | {
|
|
91
|
+
type: "tool_call";
|
|
92
|
+
id: string;
|
|
93
|
+
tool: {
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
};
|
|
97
|
+
endpoint_url: string | null;
|
|
98
|
+
endpoint_timeout_ms: number | null;
|
|
99
|
+
endpoint_called_at: string | null;
|
|
100
|
+
request_body: object | null;
|
|
101
|
+
response_body: object | null;
|
|
102
|
+
response_status_code: number | null;
|
|
103
|
+
timed_out: boolean | null;
|
|
104
|
+
error_message: string | null;
|
|
76
105
|
} | {
|
|
77
106
|
type: "error";
|
|
78
107
|
error: {
|
|
@@ -90,10 +119,6 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
90
119
|
type OnMessageCallback = (message: PhonicSTSWebSocketResponseMessage) => void;
|
|
91
120
|
type OnCloseCallback = (event: WebSocket.CloseEvent) => void;
|
|
92
121
|
type OnErrorCallback = (event: WebSocket.ErrorEvent) => void;
|
|
93
|
-
type PhonicSTSOutboundCallConfig = Omit<PhonicSTSConfig, "input_format" | "output_format">;
|
|
94
|
-
type OutboundCallSuccessResponse = {
|
|
95
|
-
success: true;
|
|
96
|
-
};
|
|
97
122
|
type PhonicTool = "send_dtmf_tone" | "end_conversation";
|
|
98
123
|
type PhonicConfigurationEndpointRequestPayload = {
|
|
99
124
|
project: {
|
|
@@ -263,41 +288,46 @@ type ConversationSuccessResponse = {
|
|
|
263
288
|
type ConversationsSuccessResponse = {
|
|
264
289
|
conversations: Array<Conversation>;
|
|
265
290
|
};
|
|
291
|
+
type OutboundCallConfig = Omit<PhonicSTSConfigWithAgent, "input_format" | "output_format"> | Omit<PhonicSTSConfigWithProject, "input_format" | "output_format">;
|
|
292
|
+
type OutboundCallSuccessResponse = {
|
|
293
|
+
conversation_id: string;
|
|
294
|
+
};
|
|
266
295
|
|
|
267
|
-
|
|
268
|
-
private readonly phonic;
|
|
269
|
-
constructor(phonic: Phonic);
|
|
270
|
-
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
271
|
-
getByExternalId({ project, externalId, }: {
|
|
272
|
-
project?: string;
|
|
273
|
-
externalId: string;
|
|
274
|
-
}): DataOrError<ConversationSuccessResponse>;
|
|
275
|
-
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
276
|
-
project?: string;
|
|
277
|
-
durationMin?: number;
|
|
278
|
-
durationMax?: number;
|
|
279
|
-
startedAtMin?: ISODate | ISODateTime$1;
|
|
280
|
-
startedAtMax?: ISODate | ISODateTime$1;
|
|
281
|
-
}): DataOrError<ConversationsSuccessResponse>;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
type PhonicSTSTwilioOutboundCallParams = {
|
|
296
|
+
type TwilioOutboundCallParams = {
|
|
285
297
|
account_sid: string;
|
|
286
298
|
api_key_sid: string;
|
|
287
299
|
api_key_secret: string;
|
|
288
300
|
from_phone_number: string;
|
|
289
301
|
to_phone_number: string;
|
|
290
302
|
};
|
|
291
|
-
type
|
|
303
|
+
type TwilioOutboundCallConfig = OutboundCallConfig;
|
|
292
304
|
type TwilioOutboundCallSuccessResponse = {
|
|
293
|
-
success: true;
|
|
294
305
|
callSid: string;
|
|
295
306
|
};
|
|
296
307
|
|
|
297
308
|
declare class Twilio {
|
|
298
309
|
private readonly phonic;
|
|
299
310
|
constructor(phonic: Phonic);
|
|
300
|
-
outboundCall(params:
|
|
311
|
+
outboundCall(params: TwilioOutboundCallParams, config: TwilioOutboundCallConfig): DataOrError<TwilioOutboundCallSuccessResponse>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
declare class Conversations {
|
|
315
|
+
private readonly phonic;
|
|
316
|
+
readonly twilio: Twilio;
|
|
317
|
+
constructor(phonic: Phonic);
|
|
318
|
+
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
319
|
+
project?: string;
|
|
320
|
+
durationMin?: number;
|
|
321
|
+
durationMax?: number;
|
|
322
|
+
startedAtMin?: ISODate | ISODateTime$1;
|
|
323
|
+
startedAtMax?: ISODate | ISODateTime$1;
|
|
324
|
+
}): DataOrError<ConversationsSuccessResponse>;
|
|
325
|
+
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
326
|
+
getByExternalId({ project, externalId, }: {
|
|
327
|
+
project?: string;
|
|
328
|
+
externalId: string;
|
|
329
|
+
}): DataOrError<ConversationSuccessResponse>;
|
|
330
|
+
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
301
331
|
}
|
|
302
332
|
|
|
303
333
|
declare class PhonicSTSWebSocket {
|
|
@@ -326,10 +356,8 @@ declare class PhonicSTSWebSocket {
|
|
|
326
356
|
|
|
327
357
|
declare class SpeechToSpeech {
|
|
328
358
|
private readonly phonic;
|
|
329
|
-
readonly twilio: Twilio;
|
|
330
359
|
constructor(phonic: Phonic);
|
|
331
360
|
websocket(config: PhonicSTSConfig): PhonicSTSWebSocket;
|
|
332
|
-
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
333
361
|
}
|
|
334
362
|
|
|
335
363
|
interface ParameterBase {
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "0.
|
|
38
|
+
var version = "0.24.1";
|
|
39
39
|
|
|
40
40
|
// src/agents/index.ts
|
|
41
41
|
var Agents = class {
|
|
@@ -144,30 +144,36 @@ var Agents = class {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
// src/conversations/index.ts
|
|
148
|
-
var
|
|
147
|
+
// src/conversations/twilio/index.ts
|
|
148
|
+
var Twilio = class {
|
|
149
149
|
constructor(phonic) {
|
|
150
150
|
this.phonic = phonic;
|
|
151
151
|
}
|
|
152
|
-
async
|
|
153
|
-
const response = await this.phonic.
|
|
154
|
-
|
|
152
|
+
async outboundCall(params, config) {
|
|
153
|
+
const response = await this.phonic.post(
|
|
154
|
+
"/conversations/twilio/outbound_call",
|
|
155
|
+
{
|
|
156
|
+
from_phone_number: params.from_phone_number,
|
|
157
|
+
to_phone_number: params.to_phone_number,
|
|
158
|
+
config
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"X-Twilio-Account-Sid": params.account_sid,
|
|
162
|
+
"X-Twilio-Api-Key-Sid": params.api_key_sid,
|
|
163
|
+
"X-Twilio-Api-Key-Secret": params.api_key_secret
|
|
164
|
+
}
|
|
155
165
|
);
|
|
156
166
|
return response;
|
|
157
167
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}).toString();
|
|
166
|
-
const response = await this.phonic.get(
|
|
167
|
-
`/conversations?${queryString}`
|
|
168
|
-
);
|
|
169
|
-
return response;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/conversations/index.ts
|
|
171
|
+
var Conversations = class {
|
|
172
|
+
constructor(phonic) {
|
|
173
|
+
this.phonic = phonic;
|
|
174
|
+
this.twilio = new Twilio(phonic);
|
|
170
175
|
}
|
|
176
|
+
twilio;
|
|
171
177
|
async list({
|
|
172
178
|
project,
|
|
173
179
|
durationMin,
|
|
@@ -187,34 +193,40 @@ var Conversations = class {
|
|
|
187
193
|
);
|
|
188
194
|
return response;
|
|
189
195
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// src/sts/twilio/index.ts
|
|
196
|
-
var Twilio = class {
|
|
197
|
-
constructor(phonic) {
|
|
198
|
-
this.phonic = phonic;
|
|
196
|
+
async get(id) {
|
|
197
|
+
const response = await this.phonic.get(
|
|
198
|
+
`/conversations/${id}`
|
|
199
|
+
);
|
|
200
|
+
return response;
|
|
199
201
|
}
|
|
200
|
-
async
|
|
202
|
+
async getByExternalId({
|
|
203
|
+
project,
|
|
204
|
+
externalId
|
|
205
|
+
}) {
|
|
206
|
+
const queryString = new URLSearchParams({
|
|
207
|
+
...project !== void 0 && { project },
|
|
208
|
+
external_id: externalId
|
|
209
|
+
}).toString();
|
|
210
|
+
const response = await this.phonic.get(
|
|
211
|
+
`/conversations?${queryString}`
|
|
212
|
+
);
|
|
213
|
+
return response;
|
|
214
|
+
}
|
|
215
|
+
async outboundCall(toPhoneNumber, config) {
|
|
201
216
|
const response = await this.phonic.post(
|
|
202
|
-
"/
|
|
217
|
+
"/conversations/outbound_call",
|
|
203
218
|
{
|
|
204
|
-
|
|
205
|
-
to_phone_number: params.to_phone_number,
|
|
219
|
+
to_phone_number: toPhoneNumber,
|
|
206
220
|
config
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
"X-Twilio-Account-Sid": params.account_sid,
|
|
210
|
-
"X-Twilio-Api-Key-Sid": params.api_key_sid,
|
|
211
|
-
"X-Twilio-Api-Key-Secret": params.api_key_secret
|
|
212
221
|
}
|
|
213
222
|
);
|
|
214
223
|
return response;
|
|
215
224
|
}
|
|
216
225
|
};
|
|
217
226
|
|
|
227
|
+
// src/sts/index.ts
|
|
228
|
+
var import_ws = __toESM(require("ws"));
|
|
229
|
+
|
|
218
230
|
// src/sts/websocket.ts
|
|
219
231
|
var PhonicSTSWebSocket = class {
|
|
220
232
|
constructor(ws, config) {
|
|
@@ -318,9 +330,7 @@ var PhonicSTSWebSocket = class {
|
|
|
318
330
|
var SpeechToSpeech = class {
|
|
319
331
|
constructor(phonic) {
|
|
320
332
|
this.phonic = phonic;
|
|
321
|
-
this.twilio = new Twilio(phonic);
|
|
322
333
|
}
|
|
323
|
-
twilio;
|
|
324
334
|
websocket(config) {
|
|
325
335
|
const wsBaseUrl = this.phonic.baseUrl.replace(/^http/, "ws");
|
|
326
336
|
const queryString = new URLSearchParams({
|
|
@@ -334,16 +344,6 @@ var SpeechToSpeech = class {
|
|
|
334
344
|
});
|
|
335
345
|
return new PhonicSTSWebSocket(ws, config);
|
|
336
346
|
}
|
|
337
|
-
async outboundCall(toPhoneNumber, config) {
|
|
338
|
-
const response = await this.phonic.post(
|
|
339
|
-
"/sts/outbound_call",
|
|
340
|
-
{
|
|
341
|
-
to_phone_number: toPhoneNumber,
|
|
342
|
-
config
|
|
343
|
-
}
|
|
344
|
-
);
|
|
345
|
-
return response;
|
|
346
|
-
}
|
|
347
347
|
};
|
|
348
348
|
|
|
349
349
|
// src/tools/index.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.24.1";
|
|
3
3
|
|
|
4
4
|
// src/agents/index.ts
|
|
5
5
|
var Agents = class {
|
|
@@ -108,30 +108,36 @@ var Agents = class {
|
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
// src/conversations/index.ts
|
|
112
|
-
var
|
|
111
|
+
// src/conversations/twilio/index.ts
|
|
112
|
+
var Twilio = class {
|
|
113
113
|
constructor(phonic) {
|
|
114
114
|
this.phonic = phonic;
|
|
115
115
|
}
|
|
116
|
-
async
|
|
117
|
-
const response = await this.phonic.
|
|
118
|
-
|
|
116
|
+
async outboundCall(params, config) {
|
|
117
|
+
const response = await this.phonic.post(
|
|
118
|
+
"/conversations/twilio/outbound_call",
|
|
119
|
+
{
|
|
120
|
+
from_phone_number: params.from_phone_number,
|
|
121
|
+
to_phone_number: params.to_phone_number,
|
|
122
|
+
config
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"X-Twilio-Account-Sid": params.account_sid,
|
|
126
|
+
"X-Twilio-Api-Key-Sid": params.api_key_sid,
|
|
127
|
+
"X-Twilio-Api-Key-Secret": params.api_key_secret
|
|
128
|
+
}
|
|
119
129
|
);
|
|
120
130
|
return response;
|
|
121
131
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}).toString();
|
|
130
|
-
const response = await this.phonic.get(
|
|
131
|
-
`/conversations?${queryString}`
|
|
132
|
-
);
|
|
133
|
-
return response;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// src/conversations/index.ts
|
|
135
|
+
var Conversations = class {
|
|
136
|
+
constructor(phonic) {
|
|
137
|
+
this.phonic = phonic;
|
|
138
|
+
this.twilio = new Twilio(phonic);
|
|
134
139
|
}
|
|
140
|
+
twilio;
|
|
135
141
|
async list({
|
|
136
142
|
project,
|
|
137
143
|
durationMin,
|
|
@@ -151,34 +157,40 @@ var Conversations = class {
|
|
|
151
157
|
);
|
|
152
158
|
return response;
|
|
153
159
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// src/sts/twilio/index.ts
|
|
160
|
-
var Twilio = class {
|
|
161
|
-
constructor(phonic) {
|
|
162
|
-
this.phonic = phonic;
|
|
160
|
+
async get(id) {
|
|
161
|
+
const response = await this.phonic.get(
|
|
162
|
+
`/conversations/${id}`
|
|
163
|
+
);
|
|
164
|
+
return response;
|
|
163
165
|
}
|
|
164
|
-
async
|
|
166
|
+
async getByExternalId({
|
|
167
|
+
project,
|
|
168
|
+
externalId
|
|
169
|
+
}) {
|
|
170
|
+
const queryString = new URLSearchParams({
|
|
171
|
+
...project !== void 0 && { project },
|
|
172
|
+
external_id: externalId
|
|
173
|
+
}).toString();
|
|
174
|
+
const response = await this.phonic.get(
|
|
175
|
+
`/conversations?${queryString}`
|
|
176
|
+
);
|
|
177
|
+
return response;
|
|
178
|
+
}
|
|
179
|
+
async outboundCall(toPhoneNumber, config) {
|
|
165
180
|
const response = await this.phonic.post(
|
|
166
|
-
"/
|
|
181
|
+
"/conversations/outbound_call",
|
|
167
182
|
{
|
|
168
|
-
|
|
169
|
-
to_phone_number: params.to_phone_number,
|
|
183
|
+
to_phone_number: toPhoneNumber,
|
|
170
184
|
config
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
"X-Twilio-Account-Sid": params.account_sid,
|
|
174
|
-
"X-Twilio-Api-Key-Sid": params.api_key_sid,
|
|
175
|
-
"X-Twilio-Api-Key-Secret": params.api_key_secret
|
|
176
185
|
}
|
|
177
186
|
);
|
|
178
187
|
return response;
|
|
179
188
|
}
|
|
180
189
|
};
|
|
181
190
|
|
|
191
|
+
// src/sts/index.ts
|
|
192
|
+
import WebSocket from "ws";
|
|
193
|
+
|
|
182
194
|
// src/sts/websocket.ts
|
|
183
195
|
var PhonicSTSWebSocket = class {
|
|
184
196
|
constructor(ws, config) {
|
|
@@ -282,9 +294,7 @@ var PhonicSTSWebSocket = class {
|
|
|
282
294
|
var SpeechToSpeech = class {
|
|
283
295
|
constructor(phonic) {
|
|
284
296
|
this.phonic = phonic;
|
|
285
|
-
this.twilio = new Twilio(phonic);
|
|
286
297
|
}
|
|
287
|
-
twilio;
|
|
288
298
|
websocket(config) {
|
|
289
299
|
const wsBaseUrl = this.phonic.baseUrl.replace(/^http/, "ws");
|
|
290
300
|
const queryString = new URLSearchParams({
|
|
@@ -298,16 +308,6 @@ var SpeechToSpeech = class {
|
|
|
298
308
|
});
|
|
299
309
|
return new PhonicSTSWebSocket(ws, config);
|
|
300
310
|
}
|
|
301
|
-
async outboundCall(toPhoneNumber, config) {
|
|
302
|
-
const response = await this.phonic.post(
|
|
303
|
-
"/sts/outbound_call",
|
|
304
|
-
{
|
|
305
|
-
to_phone_number: toPhoneNumber,
|
|
306
|
-
config
|
|
307
|
-
}
|
|
308
|
-
);
|
|
309
|
-
return response;
|
|
310
|
-
}
|
|
311
311
|
};
|
|
312
312
|
|
|
313
313
|
// src/tools/index.ts
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phonic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "Phonic Node.js SDK",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
7
7
|
"check": "biome check --write",
|
|
8
|
+
"ct": "bun check && bun tsc",
|
|
8
9
|
"ci": "bun tsc && biome ci && bun test",
|
|
9
10
|
"version": "changeset version && bun check",
|
|
10
11
|
"release": "bun run build && changeset publish"
|