phonic 0.23.0 → 0.24.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.
- package/README.md +9 -9
- package/dist/index.d.mts +26 -27
- package/dist/index.d.ts +26 -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
|
|
package/dist/index.d.mts
CHANGED
|
@@ -90,10 +90,6 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
90
90
|
type OnMessageCallback = (message: PhonicSTSWebSocketResponseMessage) => void;
|
|
91
91
|
type OnCloseCallback = (event: WebSocket.CloseEvent) => void;
|
|
92
92
|
type OnErrorCallback = (event: WebSocket.ErrorEvent) => void;
|
|
93
|
-
type PhonicSTSOutboundCallConfig = Omit<PhonicSTSConfig, "input_format" | "output_format">;
|
|
94
|
-
type OutboundCallSuccessResponse = {
|
|
95
|
-
success: true;
|
|
96
|
-
};
|
|
97
93
|
type PhonicTool = "send_dtmf_tone" | "end_conversation";
|
|
98
94
|
type PhonicConfigurationEndpointRequestPayload = {
|
|
99
95
|
project: {
|
|
@@ -263,41 +259,46 @@ type ConversationSuccessResponse = {
|
|
|
263
259
|
type ConversationsSuccessResponse = {
|
|
264
260
|
conversations: Array<Conversation>;
|
|
265
261
|
};
|
|
262
|
+
type OutboundCallConfig = Omit<PhonicSTSConfigWithAgent, "input_format" | "output_format"> | Omit<PhonicSTSConfigWithProject, "input_format" | "output_format">;
|
|
263
|
+
type OutboundCallSuccessResponse = {
|
|
264
|
+
conversation_id: string;
|
|
265
|
+
};
|
|
266
266
|
|
|
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 = {
|
|
267
|
+
type TwilioOutboundCallParams = {
|
|
285
268
|
account_sid: string;
|
|
286
269
|
api_key_sid: string;
|
|
287
270
|
api_key_secret: string;
|
|
288
271
|
from_phone_number: string;
|
|
289
272
|
to_phone_number: string;
|
|
290
273
|
};
|
|
291
|
-
type
|
|
274
|
+
type TwilioOutboundCallConfig = OutboundCallConfig;
|
|
292
275
|
type TwilioOutboundCallSuccessResponse = {
|
|
293
|
-
success: true;
|
|
294
276
|
callSid: string;
|
|
295
277
|
};
|
|
296
278
|
|
|
297
279
|
declare class Twilio {
|
|
298
280
|
private readonly phonic;
|
|
299
281
|
constructor(phonic: Phonic);
|
|
300
|
-
outboundCall(params:
|
|
282
|
+
outboundCall(params: TwilioOutboundCallParams, config: TwilioOutboundCallConfig): DataOrError<TwilioOutboundCallSuccessResponse>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare class Conversations {
|
|
286
|
+
private readonly phonic;
|
|
287
|
+
readonly twilio: Twilio;
|
|
288
|
+
constructor(phonic: Phonic);
|
|
289
|
+
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
290
|
+
project?: string;
|
|
291
|
+
durationMin?: number;
|
|
292
|
+
durationMax?: number;
|
|
293
|
+
startedAtMin?: ISODate | ISODateTime$1;
|
|
294
|
+
startedAtMax?: ISODate | ISODateTime$1;
|
|
295
|
+
}): DataOrError<ConversationsSuccessResponse>;
|
|
296
|
+
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
297
|
+
getByExternalId({ project, externalId, }: {
|
|
298
|
+
project?: string;
|
|
299
|
+
externalId: string;
|
|
300
|
+
}): DataOrError<ConversationSuccessResponse>;
|
|
301
|
+
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
declare class PhonicSTSWebSocket {
|
|
@@ -326,10 +327,8 @@ declare class PhonicSTSWebSocket {
|
|
|
326
327
|
|
|
327
328
|
declare class SpeechToSpeech {
|
|
328
329
|
private readonly phonic;
|
|
329
|
-
readonly twilio: Twilio;
|
|
330
330
|
constructor(phonic: Phonic);
|
|
331
331
|
websocket(config: PhonicSTSConfig): PhonicSTSWebSocket;
|
|
332
|
-
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
333
332
|
}
|
|
334
333
|
|
|
335
334
|
interface ParameterBase {
|
package/dist/index.d.ts
CHANGED
|
@@ -90,10 +90,6 @@ type PhonicSTSWebSocketResponseMessage = {
|
|
|
90
90
|
type OnMessageCallback = (message: PhonicSTSWebSocketResponseMessage) => void;
|
|
91
91
|
type OnCloseCallback = (event: WebSocket.CloseEvent) => void;
|
|
92
92
|
type OnErrorCallback = (event: WebSocket.ErrorEvent) => void;
|
|
93
|
-
type PhonicSTSOutboundCallConfig = Omit<PhonicSTSConfig, "input_format" | "output_format">;
|
|
94
|
-
type OutboundCallSuccessResponse = {
|
|
95
|
-
success: true;
|
|
96
|
-
};
|
|
97
93
|
type PhonicTool = "send_dtmf_tone" | "end_conversation";
|
|
98
94
|
type PhonicConfigurationEndpointRequestPayload = {
|
|
99
95
|
project: {
|
|
@@ -263,41 +259,46 @@ type ConversationSuccessResponse = {
|
|
|
263
259
|
type ConversationsSuccessResponse = {
|
|
264
260
|
conversations: Array<Conversation>;
|
|
265
261
|
};
|
|
262
|
+
type OutboundCallConfig = Omit<PhonicSTSConfigWithAgent, "input_format" | "output_format"> | Omit<PhonicSTSConfigWithProject, "input_format" | "output_format">;
|
|
263
|
+
type OutboundCallSuccessResponse = {
|
|
264
|
+
conversation_id: string;
|
|
265
|
+
};
|
|
266
266
|
|
|
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 = {
|
|
267
|
+
type TwilioOutboundCallParams = {
|
|
285
268
|
account_sid: string;
|
|
286
269
|
api_key_sid: string;
|
|
287
270
|
api_key_secret: string;
|
|
288
271
|
from_phone_number: string;
|
|
289
272
|
to_phone_number: string;
|
|
290
273
|
};
|
|
291
|
-
type
|
|
274
|
+
type TwilioOutboundCallConfig = OutboundCallConfig;
|
|
292
275
|
type TwilioOutboundCallSuccessResponse = {
|
|
293
|
-
success: true;
|
|
294
276
|
callSid: string;
|
|
295
277
|
};
|
|
296
278
|
|
|
297
279
|
declare class Twilio {
|
|
298
280
|
private readonly phonic;
|
|
299
281
|
constructor(phonic: Phonic);
|
|
300
|
-
outboundCall(params:
|
|
282
|
+
outboundCall(params: TwilioOutboundCallParams, config: TwilioOutboundCallConfig): DataOrError<TwilioOutboundCallSuccessResponse>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare class Conversations {
|
|
286
|
+
private readonly phonic;
|
|
287
|
+
readonly twilio: Twilio;
|
|
288
|
+
constructor(phonic: Phonic);
|
|
289
|
+
list({ project, durationMin, durationMax, startedAtMin, startedAtMax, }: {
|
|
290
|
+
project?: string;
|
|
291
|
+
durationMin?: number;
|
|
292
|
+
durationMax?: number;
|
|
293
|
+
startedAtMin?: ISODate | ISODateTime$1;
|
|
294
|
+
startedAtMax?: ISODate | ISODateTime$1;
|
|
295
|
+
}): DataOrError<ConversationsSuccessResponse>;
|
|
296
|
+
get(id: string): DataOrError<ConversationSuccessResponse>;
|
|
297
|
+
getByExternalId({ project, externalId, }: {
|
|
298
|
+
project?: string;
|
|
299
|
+
externalId: string;
|
|
300
|
+
}): DataOrError<ConversationSuccessResponse>;
|
|
301
|
+
outboundCall(toPhoneNumber: string, config: OutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
301
302
|
}
|
|
302
303
|
|
|
303
304
|
declare class PhonicSTSWebSocket {
|
|
@@ -326,10 +327,8 @@ declare class PhonicSTSWebSocket {
|
|
|
326
327
|
|
|
327
328
|
declare class SpeechToSpeech {
|
|
328
329
|
private readonly phonic;
|
|
329
|
-
readonly twilio: Twilio;
|
|
330
330
|
constructor(phonic: Phonic);
|
|
331
331
|
websocket(config: PhonicSTSConfig): PhonicSTSWebSocket;
|
|
332
|
-
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
333
332
|
}
|
|
334
333
|
|
|
335
334
|
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.0";
|
|
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.0";
|
|
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.0",
|
|
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"
|