phonic 0.24.0 → 0.24.2
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 +98 -1
- package/dist/index.d.mts +35 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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,52 @@ 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: {
|
|
545
|
+
call_info: {
|
|
546
|
+
from_phone_number: string;
|
|
547
|
+
to_phone_number: string;
|
|
548
|
+
} | null;
|
|
549
|
+
[key: string]: unknown;
|
|
550
|
+
} | null;
|
|
551
|
+
response_body: Record<string, unknown> | null;
|
|
552
|
+
response_status_code: number | null;
|
|
553
|
+
timed_out: boolean | null;
|
|
554
|
+
error_message: string | null;
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
Sent when a tool is called during the conversation. Built-in tools will have null values for endpoint-related fields.
|
|
558
|
+
|
|
559
|
+
When a custom tool is called, the `request_body` field always includes a `call_info` field.
|
|
560
|
+
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").
|
|
561
|
+
|
|
562
|
+
#### `error`
|
|
563
|
+
|
|
564
|
+
```ts
|
|
565
|
+
{
|
|
566
|
+
type: "error";
|
|
567
|
+
error: {
|
|
568
|
+
message: string;
|
|
569
|
+
code?: string;
|
|
570
|
+
};
|
|
571
|
+
param_errors?: Record<string, string>;
|
|
572
|
+
}
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
Sent when an error occurs during the conversation.
|
|
576
|
+
|
|
480
577
|
## License
|
|
481
578
|
|
|
482
579
|
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,46 @@ 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: {
|
|
101
|
+
call_info: {
|
|
102
|
+
from_phone_number: string;
|
|
103
|
+
to_phone_number: string;
|
|
104
|
+
} | null;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
} | null;
|
|
107
|
+
response_body: Record<string, unknown> | null;
|
|
108
|
+
response_status_code: number | null;
|
|
109
|
+
timed_out: boolean | null;
|
|
110
|
+
error_message: string | null;
|
|
76
111
|
} | {
|
|
77
112
|
type: "error";
|
|
78
113
|
error: {
|
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,46 @@ 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: {
|
|
101
|
+
call_info: {
|
|
102
|
+
from_phone_number: string;
|
|
103
|
+
to_phone_number: string;
|
|
104
|
+
} | null;
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
} | null;
|
|
107
|
+
response_body: Record<string, unknown> | null;
|
|
108
|
+
response_status_code: number | null;
|
|
109
|
+
timed_out: boolean | null;
|
|
110
|
+
error_message: string | null;
|
|
76
111
|
} | {
|
|
77
112
|
type: "error";
|
|
78
113
|
error: {
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED