phonic 0.21.1 → 0.23.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 +99 -1
- package/dist/index.d.mts +71 -3
- package/dist/index.d.ts +71 -3
- package/dist/index.js +71 -1
- package/dist/index.mjs +71 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,12 @@ Node.js library for the Phonic API.
|
|
|
10
10
|
- [Create agent](#create-agent)
|
|
11
11
|
- [Update agent](#update-agent)
|
|
12
12
|
- [Delete agent](#delete-agent)
|
|
13
|
+
- [Tools](#tools)
|
|
14
|
+
- [List tools](#list-tools)
|
|
15
|
+
- [Get tool](#get-tool)
|
|
16
|
+
- [Create tool](#create-tool)
|
|
17
|
+
- [Update tool](#update-tool)
|
|
18
|
+
- [Delete tool](#delete-tool)
|
|
13
19
|
- [Voices](#voices)
|
|
14
20
|
- [List voices](#list-voices)
|
|
15
21
|
- [Get voice](#get-voice)
|
|
@@ -62,6 +68,7 @@ const createAgentResult = await phonic.agents.create({
|
|
|
62
68
|
// Optional fields
|
|
63
69
|
project: "my-project", // Defaults to "main"
|
|
64
70
|
phoneNumber: "assign-automatically", // Defaults to null
|
|
71
|
+
timezone: "Australia/Melbourne", // Defaults to "America/Los_Angeles"
|
|
65
72
|
audioFormat: "mulaw_8000", // Defaults to "pcm_44100". Must be "mulaw_8000" when `phoneNumber` is "assign-automatically"
|
|
66
73
|
voiceId: "sarah", // Defaults to "grant"
|
|
67
74
|
welcomeMessage: "Hello, how can I help you?", // Defaults to ""
|
|
@@ -98,6 +105,7 @@ const updateAgentResult = await phonic.agents.update("my-agent", {
|
|
|
98
105
|
// Optional fields
|
|
99
106
|
project: "my-project",
|
|
100
107
|
phoneNumber: "assign-automatically", // or null
|
|
108
|
+
timezone: "Australia/Melbourne",
|
|
101
109
|
voiceId: "sarah",
|
|
102
110
|
audioFormat: "mulaw_8000", // Must be "mulaw_8000" when `phoneNumber` is "assign-automatically"
|
|
103
111
|
welcomeMessage: "Hello, how can I help you?",
|
|
@@ -136,6 +144,97 @@ const deleteAgentResult = await phonic.agents.delete({
|
|
|
136
144
|
});
|
|
137
145
|
```
|
|
138
146
|
|
|
147
|
+
## Tools
|
|
148
|
+
|
|
149
|
+
### List tools
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
const toolsResult = await phonic.tools.list();
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Get tool
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const toolResult = await phonic.tools.get("next_invoice");
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Create tool
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const createToolResult = await phonic.tools.create({
|
|
165
|
+
name: "next_invoice",
|
|
166
|
+
description: "Returns the next invoice of the given user",
|
|
167
|
+
endpointUrl: "https://myapp.com/webhooks/next-invoice",
|
|
168
|
+
endpointHeaders: {
|
|
169
|
+
Authorization: "Bearer 123"
|
|
170
|
+
},
|
|
171
|
+
endpointTimeoutMs: 20000, // Optional, defaults to 15000
|
|
172
|
+
parameters: [
|
|
173
|
+
{
|
|
174
|
+
type: "string",
|
|
175
|
+
name: "user",
|
|
176
|
+
description: "Full name of the user to get the invoice for",
|
|
177
|
+
isRequired: true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: "array",
|
|
181
|
+
itemType: "string",
|
|
182
|
+
name: "invoice_items",
|
|
183
|
+
description: "List of invoice items",
|
|
184
|
+
isRequired: false
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: "number",
|
|
188
|
+
name: "invoice_total",
|
|
189
|
+
description: "Total invoice amount in USD",
|
|
190
|
+
isRequired: true
|
|
191
|
+
},
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Update tool
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
const updateToolResult = await phonic.tools.update("next_invoice", {
|
|
200
|
+
name: "next_invoice_updated",
|
|
201
|
+
description: "Updated description.",
|
|
202
|
+
endpointUrl: "https://myapp.com/webhooks/next-invoice-updated",
|
|
203
|
+
endpointHeaders: {
|
|
204
|
+
Authorization: "Bearer 456"
|
|
205
|
+
},
|
|
206
|
+
endpointTimeoutMs: 30000,
|
|
207
|
+
parameters: [
|
|
208
|
+
{
|
|
209
|
+
type: "string",
|
|
210
|
+
name: "user",
|
|
211
|
+
description: "Full name of the user to get the invoice for",
|
|
212
|
+
isRequired: true
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: "array",
|
|
216
|
+
itemType: "string",
|
|
217
|
+
name: "invoice_items",
|
|
218
|
+
description: "List of invoice items",
|
|
219
|
+
isRequired: true
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
type: "number",
|
|
223
|
+
name: "invoice_total",
|
|
224
|
+
description: "Total invoice amount in USD",
|
|
225
|
+
isRequired: true
|
|
226
|
+
},
|
|
227
|
+
]
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Delete tool
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
const deleteToolResult = await phonic.tools.delete("next_invoice");
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
|
|
139
238
|
## Voices
|
|
140
239
|
|
|
141
240
|
### List voices
|
|
@@ -181,7 +280,6 @@ const conversationResult = await phonic.conversations.getByExternalId({
|
|
|
181
280
|
});
|
|
182
281
|
```
|
|
183
282
|
|
|
184
|
-
|
|
185
283
|
## STS outbound call
|
|
186
284
|
|
|
187
285
|
```ts
|
package/dist/index.d.mts
CHANGED
|
@@ -144,10 +144,10 @@ type Agent = {
|
|
|
144
144
|
timeout_ms: number;
|
|
145
145
|
} | null;
|
|
146
146
|
};
|
|
147
|
-
type
|
|
147
|
+
type ListAgentsParams = {
|
|
148
148
|
project?: string;
|
|
149
149
|
};
|
|
150
|
-
type
|
|
150
|
+
type ListAgentsSuccessResponse = DataOrError<{
|
|
151
151
|
agents: Array<Agent>;
|
|
152
152
|
}>;
|
|
153
153
|
type GetAgentParams = {
|
|
@@ -158,6 +158,7 @@ type GetAgentSuccessResponse = DataOrError<{
|
|
|
158
158
|
}>;
|
|
159
159
|
interface AgentOptionalParams {
|
|
160
160
|
project?: string;
|
|
161
|
+
timezone?: string;
|
|
161
162
|
voiceId?: string;
|
|
162
163
|
welcomeMessage?: string;
|
|
163
164
|
systemPrompt?: string;
|
|
@@ -219,7 +220,7 @@ declare class Agents {
|
|
|
219
220
|
private getQueryString;
|
|
220
221
|
private getTemplateVariablesForBody;
|
|
221
222
|
private getConfigurationEndpointForBody;
|
|
222
|
-
list(params?:
|
|
223
|
+
list(params?: ListAgentsParams): DataOrError<ListAgentsSuccessResponse>;
|
|
223
224
|
get(name: string, params?: GetAgentParams): DataOrError<GetAgentSuccessResponse>;
|
|
224
225
|
create(params: CreateAgentParams): DataOrError<CreateAgentSuccessResponse>;
|
|
225
226
|
update(name: string, params: UpdateAgentParams): DataOrError<UpdateAgentSuccessResponse>;
|
|
@@ -331,6 +332,72 @@ declare class SpeechToSpeech {
|
|
|
331
332
|
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
332
333
|
}
|
|
333
334
|
|
|
335
|
+
interface ParameterBase {
|
|
336
|
+
name: string;
|
|
337
|
+
description: string;
|
|
338
|
+
isRequired: boolean;
|
|
339
|
+
}
|
|
340
|
+
interface PrimitiveParameter extends ParameterBase {
|
|
341
|
+
type: "string" | "integer" | "number" | "boolean";
|
|
342
|
+
}
|
|
343
|
+
interface ArrayParameter extends ParameterBase {
|
|
344
|
+
type: "array";
|
|
345
|
+
itemType: "string" | "integer" | "number" | "boolean";
|
|
346
|
+
}
|
|
347
|
+
type ToolParameters = Array<PrimitiveParameter | ArrayParameter>;
|
|
348
|
+
type Tool = {
|
|
349
|
+
id: string;
|
|
350
|
+
name: string;
|
|
351
|
+
description: string;
|
|
352
|
+
endpoint_url: string;
|
|
353
|
+
endpoint_headers: Record<string, string>;
|
|
354
|
+
endpoint_timeout_ms: number;
|
|
355
|
+
parameters: ToolParameters;
|
|
356
|
+
};
|
|
357
|
+
type ListToolsSuccessResponse = DataOrError<{
|
|
358
|
+
tools: Array<Tool>;
|
|
359
|
+
}>;
|
|
360
|
+
type GetToolSuccessResponse = DataOrError<{
|
|
361
|
+
tool: Tool;
|
|
362
|
+
}>;
|
|
363
|
+
type CreateToolParams = {
|
|
364
|
+
name: string;
|
|
365
|
+
description: string;
|
|
366
|
+
endpointUrl: string;
|
|
367
|
+
endpointHeaders?: Record<string, string>;
|
|
368
|
+
endpointTimeoutMs?: number;
|
|
369
|
+
parameters?: ToolParameters;
|
|
370
|
+
};
|
|
371
|
+
type CreateToolSuccessResponse = {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
};
|
|
375
|
+
type UpdateToolParams = {
|
|
376
|
+
name?: string;
|
|
377
|
+
description?: string;
|
|
378
|
+
endpointUrl?: string;
|
|
379
|
+
endpointHeaders?: Record<string, string>;
|
|
380
|
+
endpointTimeoutMs?: number;
|
|
381
|
+
parameters?: Array<PrimitiveParameter | ArrayParameter>;
|
|
382
|
+
};
|
|
383
|
+
type UpdateToolSuccessResponse = {
|
|
384
|
+
success: true;
|
|
385
|
+
};
|
|
386
|
+
type DeleteToolSuccessResponse = {
|
|
387
|
+
success: true;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
declare class Tools {
|
|
391
|
+
private readonly phonic;
|
|
392
|
+
constructor(phonic: Phonic);
|
|
393
|
+
private getParametersForBody;
|
|
394
|
+
list(): DataOrError<ListToolsSuccessResponse>;
|
|
395
|
+
get(name: string): DataOrError<GetToolSuccessResponse>;
|
|
396
|
+
create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
|
|
397
|
+
update(name: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
|
|
398
|
+
delete(name: string): DataOrError<DeleteToolSuccessResponse>;
|
|
399
|
+
}
|
|
400
|
+
|
|
334
401
|
type Voice = {
|
|
335
402
|
id: string;
|
|
336
403
|
name: string;
|
|
@@ -358,6 +425,7 @@ declare class Phonic {
|
|
|
358
425
|
readonly headers: Record<string, string>;
|
|
359
426
|
readonly agents: Agents;
|
|
360
427
|
readonly conversations: Conversations;
|
|
428
|
+
readonly tools: Tools;
|
|
361
429
|
readonly voices: Voices;
|
|
362
430
|
readonly sts: SpeechToSpeech;
|
|
363
431
|
constructor(apiKey: string, config?: PhonicConfig);
|
package/dist/index.d.ts
CHANGED
|
@@ -144,10 +144,10 @@ type Agent = {
|
|
|
144
144
|
timeout_ms: number;
|
|
145
145
|
} | null;
|
|
146
146
|
};
|
|
147
|
-
type
|
|
147
|
+
type ListAgentsParams = {
|
|
148
148
|
project?: string;
|
|
149
149
|
};
|
|
150
|
-
type
|
|
150
|
+
type ListAgentsSuccessResponse = DataOrError<{
|
|
151
151
|
agents: Array<Agent>;
|
|
152
152
|
}>;
|
|
153
153
|
type GetAgentParams = {
|
|
@@ -158,6 +158,7 @@ type GetAgentSuccessResponse = DataOrError<{
|
|
|
158
158
|
}>;
|
|
159
159
|
interface AgentOptionalParams {
|
|
160
160
|
project?: string;
|
|
161
|
+
timezone?: string;
|
|
161
162
|
voiceId?: string;
|
|
162
163
|
welcomeMessage?: string;
|
|
163
164
|
systemPrompt?: string;
|
|
@@ -219,7 +220,7 @@ declare class Agents {
|
|
|
219
220
|
private getQueryString;
|
|
220
221
|
private getTemplateVariablesForBody;
|
|
221
222
|
private getConfigurationEndpointForBody;
|
|
222
|
-
list(params?:
|
|
223
|
+
list(params?: ListAgentsParams): DataOrError<ListAgentsSuccessResponse>;
|
|
223
224
|
get(name: string, params?: GetAgentParams): DataOrError<GetAgentSuccessResponse>;
|
|
224
225
|
create(params: CreateAgentParams): DataOrError<CreateAgentSuccessResponse>;
|
|
225
226
|
update(name: string, params: UpdateAgentParams): DataOrError<UpdateAgentSuccessResponse>;
|
|
@@ -331,6 +332,72 @@ declare class SpeechToSpeech {
|
|
|
331
332
|
outboundCall(toPhoneNumber: string, config: PhonicSTSOutboundCallConfig): DataOrError<OutboundCallSuccessResponse>;
|
|
332
333
|
}
|
|
333
334
|
|
|
335
|
+
interface ParameterBase {
|
|
336
|
+
name: string;
|
|
337
|
+
description: string;
|
|
338
|
+
isRequired: boolean;
|
|
339
|
+
}
|
|
340
|
+
interface PrimitiveParameter extends ParameterBase {
|
|
341
|
+
type: "string" | "integer" | "number" | "boolean";
|
|
342
|
+
}
|
|
343
|
+
interface ArrayParameter extends ParameterBase {
|
|
344
|
+
type: "array";
|
|
345
|
+
itemType: "string" | "integer" | "number" | "boolean";
|
|
346
|
+
}
|
|
347
|
+
type ToolParameters = Array<PrimitiveParameter | ArrayParameter>;
|
|
348
|
+
type Tool = {
|
|
349
|
+
id: string;
|
|
350
|
+
name: string;
|
|
351
|
+
description: string;
|
|
352
|
+
endpoint_url: string;
|
|
353
|
+
endpoint_headers: Record<string, string>;
|
|
354
|
+
endpoint_timeout_ms: number;
|
|
355
|
+
parameters: ToolParameters;
|
|
356
|
+
};
|
|
357
|
+
type ListToolsSuccessResponse = DataOrError<{
|
|
358
|
+
tools: Array<Tool>;
|
|
359
|
+
}>;
|
|
360
|
+
type GetToolSuccessResponse = DataOrError<{
|
|
361
|
+
tool: Tool;
|
|
362
|
+
}>;
|
|
363
|
+
type CreateToolParams = {
|
|
364
|
+
name: string;
|
|
365
|
+
description: string;
|
|
366
|
+
endpointUrl: string;
|
|
367
|
+
endpointHeaders?: Record<string, string>;
|
|
368
|
+
endpointTimeoutMs?: number;
|
|
369
|
+
parameters?: ToolParameters;
|
|
370
|
+
};
|
|
371
|
+
type CreateToolSuccessResponse = {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
};
|
|
375
|
+
type UpdateToolParams = {
|
|
376
|
+
name?: string;
|
|
377
|
+
description?: string;
|
|
378
|
+
endpointUrl?: string;
|
|
379
|
+
endpointHeaders?: Record<string, string>;
|
|
380
|
+
endpointTimeoutMs?: number;
|
|
381
|
+
parameters?: Array<PrimitiveParameter | ArrayParameter>;
|
|
382
|
+
};
|
|
383
|
+
type UpdateToolSuccessResponse = {
|
|
384
|
+
success: true;
|
|
385
|
+
};
|
|
386
|
+
type DeleteToolSuccessResponse = {
|
|
387
|
+
success: true;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
declare class Tools {
|
|
391
|
+
private readonly phonic;
|
|
392
|
+
constructor(phonic: Phonic);
|
|
393
|
+
private getParametersForBody;
|
|
394
|
+
list(): DataOrError<ListToolsSuccessResponse>;
|
|
395
|
+
get(name: string): DataOrError<GetToolSuccessResponse>;
|
|
396
|
+
create(params: CreateToolParams): DataOrError<CreateToolSuccessResponse>;
|
|
397
|
+
update(name: string, params: UpdateToolParams): DataOrError<UpdateToolSuccessResponse>;
|
|
398
|
+
delete(name: string): DataOrError<DeleteToolSuccessResponse>;
|
|
399
|
+
}
|
|
400
|
+
|
|
334
401
|
type Voice = {
|
|
335
402
|
id: string;
|
|
336
403
|
name: string;
|
|
@@ -358,6 +425,7 @@ declare class Phonic {
|
|
|
358
425
|
readonly headers: Record<string, string>;
|
|
359
426
|
readonly agents: Agents;
|
|
360
427
|
readonly conversations: Conversations;
|
|
428
|
+
readonly tools: Tools;
|
|
361
429
|
readonly voices: Voices;
|
|
362
430
|
readonly sts: SpeechToSpeech;
|
|
363
431
|
constructor(apiKey: string, config?: PhonicConfig);
|
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.23.0";
|
|
39
39
|
|
|
40
40
|
// src/agents/index.ts
|
|
41
41
|
var Agents = class {
|
|
@@ -90,6 +90,7 @@ var Agents = class {
|
|
|
90
90
|
{
|
|
91
91
|
name: params.name,
|
|
92
92
|
phone_number: params.phoneNumber,
|
|
93
|
+
timezone: params.timezone,
|
|
93
94
|
audio_format: params.phoneNumber === "assign-automatically" ? "mulaw_8000" : params.audioFormat,
|
|
94
95
|
voice_id: params.voiceId,
|
|
95
96
|
welcome_message: params.welcomeMessage,
|
|
@@ -115,6 +116,7 @@ var Agents = class {
|
|
|
115
116
|
{
|
|
116
117
|
name: params.name,
|
|
117
118
|
phone_number: params.phoneNumber,
|
|
119
|
+
timezone: params.timezone,
|
|
118
120
|
audio_format: params.phoneNumber === "assign-automatically" ? "mulaw_8000" : params.audioFormat,
|
|
119
121
|
voice_id: params.voiceId,
|
|
120
122
|
welcome_message: params.welcomeMessage,
|
|
@@ -344,6 +346,73 @@ var SpeechToSpeech = class {
|
|
|
344
346
|
}
|
|
345
347
|
};
|
|
346
348
|
|
|
349
|
+
// src/tools/index.ts
|
|
350
|
+
var Tools = class {
|
|
351
|
+
constructor(phonic) {
|
|
352
|
+
this.phonic = phonic;
|
|
353
|
+
}
|
|
354
|
+
getParametersForBody(parameters) {
|
|
355
|
+
if (parameters === void 0) {
|
|
356
|
+
return void 0;
|
|
357
|
+
}
|
|
358
|
+
return parameters.map((parameter) => {
|
|
359
|
+
return {
|
|
360
|
+
type: parameter.type,
|
|
361
|
+
name: parameter.name,
|
|
362
|
+
description: parameter.description,
|
|
363
|
+
is_required: parameter.isRequired,
|
|
364
|
+
...parameter.type === "array" && {
|
|
365
|
+
item_type: parameter.itemType
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async list() {
|
|
371
|
+
const response = await this.phonic.get("/tools");
|
|
372
|
+
return response;
|
|
373
|
+
}
|
|
374
|
+
async get(name) {
|
|
375
|
+
const response = await this.phonic.get(
|
|
376
|
+
`/tools/${name}`
|
|
377
|
+
);
|
|
378
|
+
return response;
|
|
379
|
+
}
|
|
380
|
+
async create(params) {
|
|
381
|
+
const response = await this.phonic.post(
|
|
382
|
+
"/tools",
|
|
383
|
+
{
|
|
384
|
+
name: params.name,
|
|
385
|
+
description: params.description,
|
|
386
|
+
endpoint_url: params.endpointUrl,
|
|
387
|
+
endpoint_headers: params.endpointHeaders,
|
|
388
|
+
endpoint_timeout_ms: params.endpointTimeoutMs,
|
|
389
|
+
parameters: this.getParametersForBody(params.parameters)
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
return response;
|
|
393
|
+
}
|
|
394
|
+
async update(name, params) {
|
|
395
|
+
const response = await this.phonic.patch(
|
|
396
|
+
`/tools/${name}`,
|
|
397
|
+
{
|
|
398
|
+
name: params.name,
|
|
399
|
+
description: params.description,
|
|
400
|
+
endpoint_url: params.endpointUrl,
|
|
401
|
+
endpoint_headers: params.endpointHeaders,
|
|
402
|
+
endpoint_timeout_ms: params.endpointTimeoutMs,
|
|
403
|
+
parameters: this.getParametersForBody(params.parameters)
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
return response;
|
|
407
|
+
}
|
|
408
|
+
async delete(name) {
|
|
409
|
+
const response = await this.phonic.delete(
|
|
410
|
+
`/tools/${name}`
|
|
411
|
+
);
|
|
412
|
+
return response;
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
347
416
|
// src/voices/index.ts
|
|
348
417
|
var Voices = class {
|
|
349
418
|
constructor(phonic) {
|
|
@@ -393,6 +462,7 @@ var Phonic = class {
|
|
|
393
462
|
headers;
|
|
394
463
|
agents = new Agents(this);
|
|
395
464
|
conversations = new Conversations(this);
|
|
465
|
+
tools = new Tools(this);
|
|
396
466
|
voices = new Voices(this);
|
|
397
467
|
sts = new SpeechToSpeech(this);
|
|
398
468
|
async fetchRequest(path, options) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.23.0";
|
|
3
3
|
|
|
4
4
|
// src/agents/index.ts
|
|
5
5
|
var Agents = class {
|
|
@@ -54,6 +54,7 @@ var Agents = class {
|
|
|
54
54
|
{
|
|
55
55
|
name: params.name,
|
|
56
56
|
phone_number: params.phoneNumber,
|
|
57
|
+
timezone: params.timezone,
|
|
57
58
|
audio_format: params.phoneNumber === "assign-automatically" ? "mulaw_8000" : params.audioFormat,
|
|
58
59
|
voice_id: params.voiceId,
|
|
59
60
|
welcome_message: params.welcomeMessage,
|
|
@@ -79,6 +80,7 @@ var Agents = class {
|
|
|
79
80
|
{
|
|
80
81
|
name: params.name,
|
|
81
82
|
phone_number: params.phoneNumber,
|
|
83
|
+
timezone: params.timezone,
|
|
82
84
|
audio_format: params.phoneNumber === "assign-automatically" ? "mulaw_8000" : params.audioFormat,
|
|
83
85
|
voice_id: params.voiceId,
|
|
84
86
|
welcome_message: params.welcomeMessage,
|
|
@@ -308,6 +310,73 @@ var SpeechToSpeech = class {
|
|
|
308
310
|
}
|
|
309
311
|
};
|
|
310
312
|
|
|
313
|
+
// src/tools/index.ts
|
|
314
|
+
var Tools = class {
|
|
315
|
+
constructor(phonic) {
|
|
316
|
+
this.phonic = phonic;
|
|
317
|
+
}
|
|
318
|
+
getParametersForBody(parameters) {
|
|
319
|
+
if (parameters === void 0) {
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
return parameters.map((parameter) => {
|
|
323
|
+
return {
|
|
324
|
+
type: parameter.type,
|
|
325
|
+
name: parameter.name,
|
|
326
|
+
description: parameter.description,
|
|
327
|
+
is_required: parameter.isRequired,
|
|
328
|
+
...parameter.type === "array" && {
|
|
329
|
+
item_type: parameter.itemType
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
async list() {
|
|
335
|
+
const response = await this.phonic.get("/tools");
|
|
336
|
+
return response;
|
|
337
|
+
}
|
|
338
|
+
async get(name) {
|
|
339
|
+
const response = await this.phonic.get(
|
|
340
|
+
`/tools/${name}`
|
|
341
|
+
);
|
|
342
|
+
return response;
|
|
343
|
+
}
|
|
344
|
+
async create(params) {
|
|
345
|
+
const response = await this.phonic.post(
|
|
346
|
+
"/tools",
|
|
347
|
+
{
|
|
348
|
+
name: params.name,
|
|
349
|
+
description: params.description,
|
|
350
|
+
endpoint_url: params.endpointUrl,
|
|
351
|
+
endpoint_headers: params.endpointHeaders,
|
|
352
|
+
endpoint_timeout_ms: params.endpointTimeoutMs,
|
|
353
|
+
parameters: this.getParametersForBody(params.parameters)
|
|
354
|
+
}
|
|
355
|
+
);
|
|
356
|
+
return response;
|
|
357
|
+
}
|
|
358
|
+
async update(name, params) {
|
|
359
|
+
const response = await this.phonic.patch(
|
|
360
|
+
`/tools/${name}`,
|
|
361
|
+
{
|
|
362
|
+
name: params.name,
|
|
363
|
+
description: params.description,
|
|
364
|
+
endpoint_url: params.endpointUrl,
|
|
365
|
+
endpoint_headers: params.endpointHeaders,
|
|
366
|
+
endpoint_timeout_ms: params.endpointTimeoutMs,
|
|
367
|
+
parameters: this.getParametersForBody(params.parameters)
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
return response;
|
|
371
|
+
}
|
|
372
|
+
async delete(name) {
|
|
373
|
+
const response = await this.phonic.delete(
|
|
374
|
+
`/tools/${name}`
|
|
375
|
+
);
|
|
376
|
+
return response;
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
311
380
|
// src/voices/index.ts
|
|
312
381
|
var Voices = class {
|
|
313
382
|
constructor(phonic) {
|
|
@@ -357,6 +426,7 @@ var Phonic = class {
|
|
|
357
426
|
headers;
|
|
358
427
|
agents = new Agents(this);
|
|
359
428
|
conversations = new Conversations(this);
|
|
429
|
+
tools = new Tools(this);
|
|
360
430
|
voices = new Voices(this);
|
|
361
431
|
sts = new SpeechToSpeech(this);
|
|
362
432
|
async fetchRequest(path, options) {
|