@vapi-ai/web 1.0.260 → 1.0.263
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/dist/__tests__/vapi.test.d.ts +1 -0
- package/dist/__tests__/vapi.test.js +51 -0
- package/dist/api.d.ts +132 -47
- package/dist/api.js +39 -8
- package/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +10 -0
- package/dist/vapi.d.ts +2 -0
- package/dist/vapi.js +35 -3
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vapi_1 = __importDefault(require("../vapi")); // Adjust the import path based on your project structure
|
|
7
|
+
describe("Vapi", () => {
|
|
8
|
+
let vapi;
|
|
9
|
+
let mockCall;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// Mock the DailyCall object
|
|
12
|
+
mockCall = {
|
|
13
|
+
setLocalAudio: jest.fn(),
|
|
14
|
+
localAudio: jest.fn(),
|
|
15
|
+
};
|
|
16
|
+
// Initialize Vapi instance and inject the mock
|
|
17
|
+
vapi = new vapi_1.default("dummy_token");
|
|
18
|
+
vapi["call"] = mockCall; // Assuming you have a way to set this for testing
|
|
19
|
+
});
|
|
20
|
+
describe("setMuted", () => {
|
|
21
|
+
it("should mute the audio", () => {
|
|
22
|
+
vapi["setMuted"](true);
|
|
23
|
+
expect(mockCall.setLocalAudio).toHaveBeenCalledWith(false);
|
|
24
|
+
});
|
|
25
|
+
it("should unmute the audio", () => {
|
|
26
|
+
vapi["setMuted"](false);
|
|
27
|
+
expect(mockCall.setLocalAudio).toHaveBeenCalledWith(true);
|
|
28
|
+
});
|
|
29
|
+
it("should handle errors when call object is not available", () => {
|
|
30
|
+
vapi["call"] = null; // Simulate call object not being available
|
|
31
|
+
expect(() => vapi["setMuted"](true)).toThrow("Call object is not available.");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe("isMuted", () => {
|
|
35
|
+
it("should return false if false", () => {
|
|
36
|
+
mockCall.localAudio.mockReturnValue(false); // Initially not muted
|
|
37
|
+
const res = vapi.isMuted();
|
|
38
|
+
expect(res).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
it("should return true if true", () => {
|
|
41
|
+
mockCall.localAudio.mockReturnValue(true); // Initially not muted
|
|
42
|
+
const res = vapi.isMuted();
|
|
43
|
+
expect(res).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
it("should return false if no call in progress", () => {
|
|
46
|
+
vapi["call"] = null; // Simulate call object not being available
|
|
47
|
+
const res = vapi.isMuted();
|
|
48
|
+
expect(res).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
package/dist/api.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ export interface DeepgramVoice {
|
|
|
4
4
|
/** This is the provider-specific ID that will be used. */
|
|
5
5
|
voiceId: "asteria" | "luna" | "hera" | "athena" | "varun" | "leo" | "perseus" | "helios" | "angus" | string;
|
|
6
6
|
}
|
|
7
|
+
export interface OpenAIMessage {
|
|
8
|
+
content: string | null;
|
|
9
|
+
role: object;
|
|
10
|
+
function_call?: object;
|
|
11
|
+
tool_calls?: object[];
|
|
12
|
+
}
|
|
7
13
|
export interface JsonSchema {
|
|
8
14
|
type: "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
9
15
|
/** This is of type JsonSchema. However, Swagger doesn't support circular references. */
|
|
@@ -109,17 +115,17 @@ export interface OpenAIFunction {
|
|
|
109
115
|
parameters?: OpenAIFunctionParameters;
|
|
110
116
|
}
|
|
111
117
|
export interface TogetherAIModel {
|
|
118
|
+
/** This is the starting state for the conversation. */
|
|
119
|
+
messages?: OpenAIMessage[];
|
|
112
120
|
provider: "together-ai";
|
|
113
121
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
114
122
|
model: string;
|
|
115
123
|
/**
|
|
116
|
-
* This is the temperature that will be used for calls. Default is
|
|
124
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
117
125
|
* @min 0
|
|
118
126
|
* @max 2
|
|
119
127
|
*/
|
|
120
128
|
temperature?: number;
|
|
121
|
-
/** This is the starting state for the conversation. */
|
|
122
|
-
messages: object[];
|
|
123
129
|
/** These are the functions that the assistant can execute during the call. */
|
|
124
130
|
functions?: OpenAIFunction[];
|
|
125
131
|
/**
|
|
@@ -130,17 +136,17 @@ export interface TogetherAIModel {
|
|
|
130
136
|
maxTokens?: number;
|
|
131
137
|
}
|
|
132
138
|
export interface AnyscaleModel {
|
|
139
|
+
/** This is the starting state for the conversation. */
|
|
140
|
+
messages?: OpenAIMessage[];
|
|
133
141
|
provider: "anyscale";
|
|
134
142
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
135
143
|
model: string;
|
|
136
144
|
/**
|
|
137
|
-
* This is the temperature that will be used for calls. Default is
|
|
145
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
138
146
|
* @min 0
|
|
139
147
|
* @max 2
|
|
140
148
|
*/
|
|
141
149
|
temperature?: number;
|
|
142
|
-
/** This is the starting state for the conversation. */
|
|
143
|
-
messages: object[];
|
|
144
150
|
/** These are the functions that the assistant can execute during the call. */
|
|
145
151
|
functions?: OpenAIFunction[];
|
|
146
152
|
/**
|
|
@@ -151,17 +157,17 @@ export interface AnyscaleModel {
|
|
|
151
157
|
maxTokens?: number;
|
|
152
158
|
}
|
|
153
159
|
export interface OpenRouterModel {
|
|
160
|
+
/** This is the starting state for the conversation. */
|
|
161
|
+
messages?: OpenAIMessage[];
|
|
154
162
|
provider: "openrouter";
|
|
155
163
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
156
164
|
model: string;
|
|
157
165
|
/**
|
|
158
|
-
* This is the temperature that will be used for calls. Default is
|
|
166
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
159
167
|
* @min 0
|
|
160
168
|
* @max 2
|
|
161
169
|
*/
|
|
162
170
|
temperature?: number;
|
|
163
|
-
/** This is the starting state for the conversation. */
|
|
164
|
-
messages: object[];
|
|
165
171
|
/** These are the functions that the assistant can execute during the call. */
|
|
166
172
|
functions?: OpenAIFunction[];
|
|
167
173
|
/**
|
|
@@ -172,17 +178,17 @@ export interface OpenRouterModel {
|
|
|
172
178
|
maxTokens?: number;
|
|
173
179
|
}
|
|
174
180
|
export interface PerplexityAIModel {
|
|
181
|
+
/** This is the starting state for the conversation. */
|
|
182
|
+
messages?: OpenAIMessage[];
|
|
175
183
|
provider: "perplexity-ai";
|
|
176
184
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
177
185
|
model: string;
|
|
178
186
|
/**
|
|
179
|
-
* This is the temperature that will be used for calls. Default is
|
|
187
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
180
188
|
* @min 0
|
|
181
189
|
* @max 2
|
|
182
190
|
*/
|
|
183
191
|
temperature?: number;
|
|
184
|
-
/** This is the starting state for the conversation. */
|
|
185
|
-
messages: object[];
|
|
186
192
|
/** These are the functions that the assistant can execute during the call. */
|
|
187
193
|
functions?: OpenAIFunction[];
|
|
188
194
|
/**
|
|
@@ -193,17 +199,17 @@ export interface PerplexityAIModel {
|
|
|
193
199
|
maxTokens?: number;
|
|
194
200
|
}
|
|
195
201
|
export interface DeepInfraModel {
|
|
202
|
+
/** This is the starting state for the conversation. */
|
|
203
|
+
messages?: OpenAIMessage[];
|
|
196
204
|
provider: "deepinfra";
|
|
197
205
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
198
206
|
model: string;
|
|
199
207
|
/**
|
|
200
|
-
* This is the temperature that will be used for calls. Default is
|
|
208
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
201
209
|
* @min 0
|
|
202
210
|
* @max 2
|
|
203
211
|
*/
|
|
204
212
|
temperature?: number;
|
|
205
|
-
/** This is the starting state for the conversation. */
|
|
206
|
-
messages: object[];
|
|
207
213
|
/** These are the functions that the assistant can execute during the call. */
|
|
208
214
|
functions?: OpenAIFunction[];
|
|
209
215
|
/**
|
|
@@ -214,6 +220,8 @@ export interface DeepInfraModel {
|
|
|
214
220
|
maxTokens?: number;
|
|
215
221
|
}
|
|
216
222
|
export interface CustomLLMModel {
|
|
223
|
+
/** This is the starting state for the conversation. */
|
|
224
|
+
messages?: OpenAIMessage[];
|
|
217
225
|
/** This is the provider that will be used for the model. Any service, including your own server, that is compatible with the OpenAI API can be used. */
|
|
218
226
|
provider: "custom-llm";
|
|
219
227
|
/** These is the URL we'll use for the OpenAI client's `baseURL`. Ex. https://openrouter.ai/api/v1 */
|
|
@@ -221,13 +229,11 @@ export interface CustomLLMModel {
|
|
|
221
229
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
222
230
|
model: string;
|
|
223
231
|
/**
|
|
224
|
-
* This is the temperature that will be used for calls. Default is
|
|
232
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
225
233
|
* @min 0
|
|
226
234
|
* @max 2
|
|
227
235
|
*/
|
|
228
236
|
temperature?: number;
|
|
229
|
-
/** This is the starting state for the conversation. */
|
|
230
|
-
messages: object[];
|
|
231
237
|
/** These are the functions that the assistant can execute during the call. */
|
|
232
238
|
functions?: OpenAIFunction[];
|
|
233
239
|
/**
|
|
@@ -238,17 +244,17 @@ export interface CustomLLMModel {
|
|
|
238
244
|
maxTokens?: number;
|
|
239
245
|
}
|
|
240
246
|
export interface GroqModel {
|
|
247
|
+
/** This is the starting state for the conversation. */
|
|
248
|
+
messages?: OpenAIMessage[];
|
|
241
249
|
/** The key of the model from the custom provider. Ex. cognitivecomputations/dolphin-mixtral-8x7b */
|
|
242
250
|
model: "mixtral-8x7b-32768";
|
|
243
251
|
provider: "groq";
|
|
244
252
|
/**
|
|
245
|
-
* This is the temperature that will be used for calls. Default is
|
|
253
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
246
254
|
* @min 0
|
|
247
255
|
* @max 2
|
|
248
256
|
*/
|
|
249
257
|
temperature?: number;
|
|
250
|
-
/** This is the starting state for the conversation. */
|
|
251
|
-
messages: object[];
|
|
252
258
|
/** These are the functions that the assistant can execute during the call. */
|
|
253
259
|
functions?: OpenAIFunction[];
|
|
254
260
|
/**
|
|
@@ -270,7 +276,7 @@ export interface ElevenLabsVoice {
|
|
|
270
276
|
/** This is the voice provider that will be used. */
|
|
271
277
|
provider: "11labs";
|
|
272
278
|
/** This is the provider-specific ID that will be used. Ensure the Voice is present in your 11Labs Voice Library. */
|
|
273
|
-
voiceId: "burt" | "marissa" | "andrea" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "mark" | string;
|
|
279
|
+
voiceId: "burt" | "marissa" | "andrea" | "sarah" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "mark" | string;
|
|
274
280
|
/**
|
|
275
281
|
* Defines the stability for voice settings.
|
|
276
282
|
* @min 0
|
|
@@ -297,20 +303,27 @@ export interface ElevenLabsVoice {
|
|
|
297
303
|
* @example false
|
|
298
304
|
*/
|
|
299
305
|
useSpeakerBoost?: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Defines the optimize streaming latency for voice settings.
|
|
308
|
+
* @min 1
|
|
309
|
+
* @max 4
|
|
310
|
+
* @example 4
|
|
311
|
+
*/
|
|
312
|
+
optimizeStreamingLatency?: number;
|
|
300
313
|
}
|
|
301
314
|
export interface OpenAIModel {
|
|
315
|
+
/** This is the starting state for the conversation. */
|
|
316
|
+
messages?: OpenAIMessage[];
|
|
302
317
|
/** This is the provider that will be used for the model. */
|
|
303
318
|
provider: "openai";
|
|
304
319
|
/** This is the OpenAI model that will be used. */
|
|
305
320
|
model: "gpt-4" | "gpt-3.5-turbo";
|
|
306
321
|
/**
|
|
307
|
-
* This is the temperature that will be used for calls. Default is
|
|
322
|
+
* This is the temperature that will be used for calls. Default is 0 to leverage caching for lower latency.
|
|
308
323
|
* @min 0
|
|
309
324
|
* @max 2
|
|
310
325
|
*/
|
|
311
326
|
temperature?: number;
|
|
312
|
-
/** This is the starting state for the conversation. */
|
|
313
|
-
messages: object[];
|
|
314
327
|
/** These are the functions that the assistant can execute during the call. */
|
|
315
328
|
functions?: OpenAIFunction[];
|
|
316
329
|
/**
|
|
@@ -415,11 +428,6 @@ export interface CreateAssistantDTO {
|
|
|
415
428
|
* @example null
|
|
416
429
|
*/
|
|
417
430
|
forwardingPhoneNumber?: string;
|
|
418
|
-
/**
|
|
419
|
-
* This sets whether the user can interrupt the assistant while it's speaking. Defaults to true.
|
|
420
|
-
* @example true
|
|
421
|
-
*/
|
|
422
|
-
interruptionsEnabled?: boolean;
|
|
423
431
|
/**
|
|
424
432
|
* This sets whether the assistant's calls are recorded. Defaults to true.
|
|
425
433
|
* @example true
|
|
@@ -435,16 +443,21 @@ export interface CreateAssistantDTO {
|
|
|
435
443
|
* @default null
|
|
436
444
|
*/
|
|
437
445
|
dialKeypadFunctionEnabled?: boolean;
|
|
446
|
+
/**
|
|
447
|
+
* When this is enabled, no logs, recordings, or transcriptions will be stored. At the end of the call, you will still receive an end-of-call-report message to store on your server. Defaults to false.
|
|
448
|
+
* @example false
|
|
449
|
+
*/
|
|
450
|
+
hipaaEnabled?: boolean;
|
|
438
451
|
/**
|
|
439
452
|
* These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
|
|
440
453
|
* @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
|
|
441
454
|
*/
|
|
442
|
-
clientMessages?: "status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update";
|
|
455
|
+
clientMessages?: ("status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update")[];
|
|
443
456
|
/**
|
|
444
457
|
* These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
|
|
445
458
|
* @example ["end-of-call-report","status-update","hang","function-call"]
|
|
446
459
|
*/
|
|
447
|
-
serverMessages?: "status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update";
|
|
460
|
+
serverMessages?: ("status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update")[];
|
|
448
461
|
/**
|
|
449
462
|
* How many seconds of silence to wait before ending the call. Defaults to 30.
|
|
450
463
|
* @min 10
|
|
@@ -459,6 +472,13 @@ export interface CreateAssistantDTO {
|
|
|
459
472
|
* @example 0.4
|
|
460
473
|
*/
|
|
461
474
|
responseDelaySeconds?: number;
|
|
475
|
+
/**
|
|
476
|
+
* This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
|
|
477
|
+
* @min 10
|
|
478
|
+
* @max 3600
|
|
479
|
+
* @example 1800
|
|
480
|
+
*/
|
|
481
|
+
maxDurationSeconds?: number;
|
|
462
482
|
/**
|
|
463
483
|
* This is the name of the assistant. This is just for your own reference.
|
|
464
484
|
* @maxLength 100
|
|
@@ -489,6 +509,8 @@ export interface CreateAssistantDTO {
|
|
|
489
509
|
endCallMessage?: string;
|
|
490
510
|
/** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
|
|
491
511
|
endCallPhrases?: string[];
|
|
512
|
+
/** This is the metadata associated with the call. */
|
|
513
|
+
metadata?: object;
|
|
492
514
|
/**
|
|
493
515
|
* This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
|
|
494
516
|
*
|
|
@@ -522,11 +544,6 @@ export interface Assistant {
|
|
|
522
544
|
* @example null
|
|
523
545
|
*/
|
|
524
546
|
forwardingPhoneNumber?: string;
|
|
525
|
-
/**
|
|
526
|
-
* This sets whether the user can interrupt the assistant while it's speaking. Defaults to true.
|
|
527
|
-
* @example true
|
|
528
|
-
*/
|
|
529
|
-
interruptionsEnabled?: boolean;
|
|
530
547
|
/**
|
|
531
548
|
* This sets whether the assistant's calls are recorded. Defaults to true.
|
|
532
549
|
* @example true
|
|
@@ -542,16 +559,21 @@ export interface Assistant {
|
|
|
542
559
|
* @default null
|
|
543
560
|
*/
|
|
544
561
|
dialKeypadFunctionEnabled?: boolean;
|
|
562
|
+
/**
|
|
563
|
+
* When this is enabled, no logs, recordings, or transcriptions will be stored. At the end of the call, you will still receive an end-of-call-report message to store on your server. Defaults to false.
|
|
564
|
+
* @example false
|
|
565
|
+
*/
|
|
566
|
+
hipaaEnabled?: boolean;
|
|
545
567
|
/**
|
|
546
568
|
* These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
|
|
547
569
|
* @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
|
|
548
570
|
*/
|
|
549
|
-
clientMessages?: "status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update";
|
|
571
|
+
clientMessages?: ("status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update")[];
|
|
550
572
|
/**
|
|
551
573
|
* These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
|
|
552
574
|
* @example ["end-of-call-report","status-update","hang","function-call"]
|
|
553
575
|
*/
|
|
554
|
-
serverMessages?: "status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update";
|
|
576
|
+
serverMessages?: ("status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update")[];
|
|
555
577
|
/**
|
|
556
578
|
* How many seconds of silence to wait before ending the call. Defaults to 30.
|
|
557
579
|
* @min 10
|
|
@@ -566,6 +588,13 @@ export interface Assistant {
|
|
|
566
588
|
* @example 0.4
|
|
567
589
|
*/
|
|
568
590
|
responseDelaySeconds?: number;
|
|
591
|
+
/**
|
|
592
|
+
* This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
|
|
593
|
+
* @min 10
|
|
594
|
+
* @max 3600
|
|
595
|
+
* @example 1800
|
|
596
|
+
*/
|
|
597
|
+
maxDurationSeconds?: number;
|
|
569
598
|
/**
|
|
570
599
|
* This is the name of the assistant. This is just for your own reference.
|
|
571
600
|
* @maxLength 100
|
|
@@ -596,6 +625,8 @@ export interface Assistant {
|
|
|
596
625
|
endCallMessage?: string;
|
|
597
626
|
/** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
|
|
598
627
|
endCallPhrases?: string[];
|
|
628
|
+
/** This is the metadata associated with the call. */
|
|
629
|
+
metadata?: object;
|
|
599
630
|
/**
|
|
600
631
|
* This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
|
|
601
632
|
*
|
|
@@ -643,11 +674,6 @@ export interface UpdateAssistantDTO {
|
|
|
643
674
|
* @example null
|
|
644
675
|
*/
|
|
645
676
|
forwardingPhoneNumber?: string;
|
|
646
|
-
/**
|
|
647
|
-
* This sets whether the user can interrupt the assistant while it's speaking. Defaults to true.
|
|
648
|
-
* @example true
|
|
649
|
-
*/
|
|
650
|
-
interruptionsEnabled?: boolean;
|
|
651
677
|
/**
|
|
652
678
|
* This sets whether the assistant's calls are recorded. Defaults to true.
|
|
653
679
|
* @example true
|
|
@@ -663,16 +689,21 @@ export interface UpdateAssistantDTO {
|
|
|
663
689
|
* @default null
|
|
664
690
|
*/
|
|
665
691
|
dialKeypadFunctionEnabled?: boolean;
|
|
692
|
+
/**
|
|
693
|
+
* When this is enabled, no logs, recordings, or transcriptions will be stored. At the end of the call, you will still receive an end-of-call-report message to store on your server. Defaults to false.
|
|
694
|
+
* @example false
|
|
695
|
+
*/
|
|
696
|
+
hipaaEnabled?: boolean;
|
|
666
697
|
/**
|
|
667
698
|
* These are the messages that will be sent to the Client SDKs. Default is ['transcript', 'hang', 'function-call', 'speech-update', 'metadata', 'conversation-update']
|
|
668
699
|
* @example ["transcript","hang","function-call","speech-update","metadata","conversation-update"]
|
|
669
700
|
*/
|
|
670
|
-
clientMessages?: "status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update";
|
|
701
|
+
clientMessages?: ("status-update" | "speech-update" | "transcript" | "hang" | "function-call" | "metadata" | "conversation-update")[];
|
|
671
702
|
/**
|
|
672
703
|
* These are the messages that will be sent to your Server URL. Default is ['end-of-call-report', 'status-update', 'hang', 'function-call']
|
|
673
704
|
* @example ["end-of-call-report","status-update","hang","function-call"]
|
|
674
705
|
*/
|
|
675
|
-
serverMessages?: "status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update";
|
|
706
|
+
serverMessages?: ("status-update" | "transcript" | "hang" | "function-call" | "end-of-call-report" | "conversation-update")[];
|
|
676
707
|
/**
|
|
677
708
|
* How many seconds of silence to wait before ending the call. Defaults to 30.
|
|
678
709
|
* @min 10
|
|
@@ -687,6 +718,13 @@ export interface UpdateAssistantDTO {
|
|
|
687
718
|
* @example 0.4
|
|
688
719
|
*/
|
|
689
720
|
responseDelaySeconds?: number;
|
|
721
|
+
/**
|
|
722
|
+
* This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.
|
|
723
|
+
* @min 10
|
|
724
|
+
* @max 3600
|
|
725
|
+
* @example 1800
|
|
726
|
+
*/
|
|
727
|
+
maxDurationSeconds?: number;
|
|
690
728
|
/**
|
|
691
729
|
* This is the name of the assistant. This is just for your own reference.
|
|
692
730
|
* @maxLength 100
|
|
@@ -717,6 +755,8 @@ export interface UpdateAssistantDTO {
|
|
|
717
755
|
endCallMessage?: string;
|
|
718
756
|
/** This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive. */
|
|
719
757
|
endCallPhrases?: string[];
|
|
758
|
+
/** This is the metadata associated with the call. */
|
|
759
|
+
metadata?: object;
|
|
720
760
|
/**
|
|
721
761
|
* This is the URL Vapi will communicate with via HTTP GET and POST Requests. This is used for retrieving context, function calling, and end-of-call reports.
|
|
722
762
|
*
|
|
@@ -1372,6 +1412,22 @@ export interface UpdatePhoneNumberDTO {
|
|
|
1372
1412
|
*/
|
|
1373
1413
|
assistantId?: string;
|
|
1374
1414
|
}
|
|
1415
|
+
export interface Metrics {
|
|
1416
|
+
orgId: string;
|
|
1417
|
+
rangeStart: string;
|
|
1418
|
+
rangeEnd: string;
|
|
1419
|
+
bill: number;
|
|
1420
|
+
billWithinBillingLimit: boolean;
|
|
1421
|
+
billDailyBreakdown: object;
|
|
1422
|
+
callActive: string;
|
|
1423
|
+
callActiveWithinConcurrencyLimit: boolean;
|
|
1424
|
+
callMinutes: string;
|
|
1425
|
+
callMinutesDailyBreakdown: object;
|
|
1426
|
+
callMinutesAverage: string;
|
|
1427
|
+
callMinutesAverageDailyBreakdown: object;
|
|
1428
|
+
callCount: string;
|
|
1429
|
+
callCountDailyBreakdown: object;
|
|
1430
|
+
}
|
|
1375
1431
|
export type QueryParamsType = Record<string | number, any>;
|
|
1376
1432
|
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
|
1377
1433
|
export interface FullRequestParams extends Omit<RequestInit, "body"> {
|
|
@@ -1433,7 +1489,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
1433
1489
|
/**
|
|
1434
1490
|
* @title Vapi API
|
|
1435
1491
|
* @version 1.0
|
|
1436
|
-
* @baseUrl https://api.vapi.ai
|
|
1492
|
+
* @baseUrl https://west-api.vapi.ai
|
|
1437
1493
|
* @contact
|
|
1438
1494
|
*
|
|
1439
1495
|
* API for building voice assistants
|
|
@@ -1559,6 +1615,8 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1559
1615
|
* @secure
|
|
1560
1616
|
*/
|
|
1561
1617
|
callControllerFindAll: (query?: {
|
|
1618
|
+
/** This will return calls with the specified assistantId. */
|
|
1619
|
+
assistantId?: string;
|
|
1562
1620
|
/**
|
|
1563
1621
|
* This is the maximum number of items to return. Defaults to 100.
|
|
1564
1622
|
* @min 0
|
|
@@ -2027,5 +2085,32 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
2027
2085
|
*/
|
|
2028
2086
|
phoneNumberControllerRemove: (id: string, params?: RequestParams) => Promise<HttpResponse<PhoneNumber, any>>;
|
|
2029
2087
|
};
|
|
2088
|
+
metrics: {
|
|
2089
|
+
/**
|
|
2090
|
+
* No description
|
|
2091
|
+
*
|
|
2092
|
+
* @tags Metrics
|
|
2093
|
+
* @name MetricsControllerFindAll
|
|
2094
|
+
* @summary List Metrics
|
|
2095
|
+
* @request GET:/metrics
|
|
2096
|
+
* @secure
|
|
2097
|
+
*/
|
|
2098
|
+
metricsControllerFindAll: (query?: {
|
|
2099
|
+
/**
|
|
2100
|
+
* This will include calls with a createdAt timestamp greater than or equal to the specified value.
|
|
2101
|
+
*
|
|
2102
|
+
* If not provided, defaults to the org's current period start.
|
|
2103
|
+
* @format date-time
|
|
2104
|
+
*/
|
|
2105
|
+
rangeStart?: string;
|
|
2106
|
+
/**
|
|
2107
|
+
* This will include calls with a createdAt timestamp less than the specified value.
|
|
2108
|
+
*
|
|
2109
|
+
* If not provided, the default value will be the current timestamp.
|
|
2110
|
+
* @format date-time
|
|
2111
|
+
*/
|
|
2112
|
+
rangeEnd?: string;
|
|
2113
|
+
}, params?: RequestParams) => Promise<HttpResponse<Metrics[], any>>;
|
|
2114
|
+
};
|
|
2030
2115
|
}
|
|
2031
2116
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -19,7 +19,7 @@ var ContentType;
|
|
|
19
19
|
ContentType["Text"] = "text/plain";
|
|
20
20
|
})(ContentType || (exports.ContentType = ContentType = {}));
|
|
21
21
|
class HttpClient {
|
|
22
|
-
baseUrl = "https://api.vapi.ai";
|
|
22
|
+
baseUrl = "https://west-api.vapi.ai";
|
|
23
23
|
securityData = null;
|
|
24
24
|
securityWorker;
|
|
25
25
|
abortControllers = new Map();
|
|
@@ -51,7 +51,9 @@ class HttpClient {
|
|
|
51
51
|
const query = rawQuery || {};
|
|
52
52
|
const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]);
|
|
53
53
|
return keys
|
|
54
|
-
.map((key) =>
|
|
54
|
+
.map((key) => Array.isArray(query[key])
|
|
55
|
+
? this.addArrayQueryParam(query, key)
|
|
56
|
+
: this.addQueryParam(query, key))
|
|
55
57
|
.join("&");
|
|
56
58
|
}
|
|
57
59
|
addQueryParams(rawQuery) {
|
|
@@ -59,8 +61,12 @@ class HttpClient {
|
|
|
59
61
|
return queryString ? `?${queryString}` : "";
|
|
60
62
|
}
|
|
61
63
|
contentFormatters = {
|
|
62
|
-
[ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string")
|
|
63
|
-
|
|
64
|
+
[ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string")
|
|
65
|
+
? JSON.stringify(input)
|
|
66
|
+
: input,
|
|
67
|
+
[ContentType.Text]: (input) => input !== null && typeof input !== "string"
|
|
68
|
+
? JSON.stringify(input)
|
|
69
|
+
: input,
|
|
64
70
|
[ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => {
|
|
65
71
|
const property = input[key];
|
|
66
72
|
formData.append(key, property instanceof Blob
|
|
@@ -116,10 +122,16 @@ class HttpClient {
|
|
|
116
122
|
...requestParams,
|
|
117
123
|
headers: {
|
|
118
124
|
...(requestParams.headers || {}),
|
|
119
|
-
...(type && type !== ContentType.FormData
|
|
125
|
+
...(type && type !== ContentType.FormData
|
|
126
|
+
? { "Content-Type": type }
|
|
127
|
+
: {}),
|
|
120
128
|
},
|
|
121
|
-
signal: (cancelToken
|
|
122
|
-
|
|
129
|
+
signal: (cancelToken
|
|
130
|
+
? this.createAbortSignal(cancelToken)
|
|
131
|
+
: requestParams.signal) || null,
|
|
132
|
+
body: typeof body === "undefined" || body === null
|
|
133
|
+
? null
|
|
134
|
+
: payloadFormatter(body),
|
|
123
135
|
}).then(async (response) => {
|
|
124
136
|
const r = response;
|
|
125
137
|
r.data = null;
|
|
@@ -153,7 +165,7 @@ exports.HttpClient = HttpClient;
|
|
|
153
165
|
/**
|
|
154
166
|
* @title Vapi API
|
|
155
167
|
* @version 1.0
|
|
156
|
-
* @baseUrl https://api.vapi.ai
|
|
168
|
+
* @baseUrl https://west-api.vapi.ai
|
|
157
169
|
* @contact
|
|
158
170
|
*
|
|
159
171
|
* API for building voice assistants
|
|
@@ -527,5 +539,24 @@ class Api extends HttpClient {
|
|
|
527
539
|
...params,
|
|
528
540
|
}),
|
|
529
541
|
};
|
|
542
|
+
metrics = {
|
|
543
|
+
/**
|
|
544
|
+
* No description
|
|
545
|
+
*
|
|
546
|
+
* @tags Metrics
|
|
547
|
+
* @name MetricsControllerFindAll
|
|
548
|
+
* @summary List Metrics
|
|
549
|
+
* @request GET:/metrics
|
|
550
|
+
* @secure
|
|
551
|
+
*/
|
|
552
|
+
metricsControllerFindAll: (query, params = {}) => this.request({
|
|
553
|
+
path: `/metrics`,
|
|
554
|
+
method: "GET",
|
|
555
|
+
query: query,
|
|
556
|
+
secure: true,
|
|
557
|
+
format: "json",
|
|
558
|
+
...params,
|
|
559
|
+
}),
|
|
560
|
+
};
|
|
530
561
|
}
|
|
531
562
|
exports.Api = Api;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config = {
|
|
4
|
+
preset: 'ts-jest',
|
|
5
|
+
testEnvironment: 'node',
|
|
6
|
+
// Your Jest configuration options here
|
|
7
|
+
// For example, to match test files:
|
|
8
|
+
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
|
|
9
|
+
};
|
|
10
|
+
exports.default = config;
|
package/dist/vapi.d.ts
CHANGED
package/dist/vapi.js
CHANGED
|
@@ -121,7 +121,10 @@ class Vapi extends VapiEventEmitter {
|
|
|
121
121
|
subscribeToTracksAutomatically: false,
|
|
122
122
|
});
|
|
123
123
|
this.call.startRemoteParticipantsAudioLevelObserver(100);
|
|
124
|
-
this.call.on("remote-participants-audio-level", (e) =>
|
|
124
|
+
this.call.on("remote-participants-audio-level", (e) => {
|
|
125
|
+
if (e)
|
|
126
|
+
this.handleRemoteParticipantsAudioLevel(e);
|
|
127
|
+
});
|
|
125
128
|
this.call.on("app-message", (e) => this.onAppMessage(e));
|
|
126
129
|
this.call.updateInputSettings({
|
|
127
130
|
audio: {
|
|
@@ -146,8 +149,15 @@ class Vapi extends VapiEventEmitter {
|
|
|
146
149
|
if (e.data === "listening") {
|
|
147
150
|
return this.emit("call-start");
|
|
148
151
|
}
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
else {
|
|
153
|
+
try {
|
|
154
|
+
const parsedMessage = JSON.parse(e.data);
|
|
155
|
+
this.emit("message", parsedMessage);
|
|
156
|
+
}
|
|
157
|
+
catch (parseError) {
|
|
158
|
+
console.log("Error parsing message data: ", parseError);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
151
161
|
}
|
|
152
162
|
catch (e) {
|
|
153
163
|
console.error(e);
|
|
@@ -179,5 +189,27 @@ class Vapi extends VapiEventEmitter {
|
|
|
179
189
|
send(message) {
|
|
180
190
|
this.call?.sendAppMessage(JSON.stringify(message));
|
|
181
191
|
}
|
|
192
|
+
setMuted(mute) {
|
|
193
|
+
try {
|
|
194
|
+
if (!this.call) {
|
|
195
|
+
throw new Error("Call object is not available.");
|
|
196
|
+
}
|
|
197
|
+
this.call.setLocalAudio(!mute);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
isMuted() {
|
|
204
|
+
try {
|
|
205
|
+
if (!this.call) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return this.call.localAudio() === false;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
182
214
|
}
|
|
183
215
|
exports.default = Vapi;
|