@vapi-ai/web 1.0.28 → 1.0.29
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 +3 -3
- package/api.ts +71 -106
- package/dist/api.d.ts +62 -97
- package/dist/api.js +27 -27
- package/dist/vapi.d.ts +2 -2
- package/dist/vapi.js +3 -3
- package/package.json +1 -1
- package/vapi.ts +4 -5
package/README.md
CHANGED
|
@@ -21,10 +21,10 @@ import Vapi from '@vapi-ai/web';
|
|
|
21
21
|
Then, create a new instance of the Vapi class, passing your Client Token as a parameter to the constructor:
|
|
22
22
|
|
|
23
23
|
```javascript
|
|
24
|
-
const vapi = new Vapi('your-
|
|
24
|
+
const vapi = new Vapi('your-web-token');
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
You can start a new call by calling the `start` method and passing an `
|
|
27
|
+
You can start a new call by calling the `start` method and passing an `assistant` object or `assistantId`:
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
30
|
vapi.start({
|
|
@@ -34,7 +34,7 @@ vapi.start({
|
|
|
34
34
|
});
|
|
35
35
|
```
|
|
36
36
|
```javascript
|
|
37
|
-
vapi.start('your-
|
|
37
|
+
vapi.start('your-assistant-id');
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
The `start` method will initiate a new call.
|
package/api.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
export interface PhoneCallParams {
|
|
13
13
|
callSid?: string;
|
|
14
|
+
status?: string;
|
|
14
15
|
customerPhoneNumber: string;
|
|
15
16
|
twilioPhoneNumber: string;
|
|
16
17
|
twilioAccountSid: string;
|
|
@@ -23,7 +24,7 @@ export interface Call {
|
|
|
23
24
|
orgId: string;
|
|
24
25
|
createdAt: string;
|
|
25
26
|
updatedAt: string;
|
|
26
|
-
|
|
27
|
+
assistantId?: string;
|
|
27
28
|
customerId?: string;
|
|
28
29
|
phoneNumberId?: string;
|
|
29
30
|
startedAt: string;
|
|
@@ -32,7 +33,7 @@ export interface Call {
|
|
|
32
33
|
recordingUrl?: string;
|
|
33
34
|
cost?: number;
|
|
34
35
|
summary?: string;
|
|
35
|
-
|
|
36
|
+
assistantParams?: object;
|
|
36
37
|
callParams?: PhoneCallParams;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -55,7 +56,7 @@ export interface OpenAIFunction {
|
|
|
55
56
|
parameters: OpenAIFunctionParamaters;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
export interface
|
|
59
|
+
export interface CreateAssistantDTO {
|
|
59
60
|
/** This is the OpenAI model that will be used. */
|
|
60
61
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
61
62
|
/**
|
|
@@ -83,37 +84,25 @@ export interface CreateAgentDTO {
|
|
|
83
84
|
| "steffan"
|
|
84
85
|
| "sara"
|
|
85
86
|
| "jason";
|
|
86
|
-
/** This is the
|
|
87
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
87
88
|
name?: string;
|
|
88
89
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
89
90
|
context?: string;
|
|
90
|
-
/** These are the functions that the
|
|
91
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
91
92
|
functions?: OpenAIFunction[];
|
|
92
|
-
/**
|
|
93
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
94
|
-
*
|
|
95
|
-
* Function Calling POST Request:
|
|
96
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
97
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
98
|
-
*
|
|
99
|
-
* End-of-Call Report POST Request:
|
|
100
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
101
|
-
*
|
|
102
|
-
* Context Retrieval GET Request:
|
|
103
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
104
|
-
*/
|
|
93
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
105
94
|
callbackUrl?: string;
|
|
106
|
-
/** This is the number the
|
|
95
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
107
96
|
forwardingPhoneNumber?: string;
|
|
108
97
|
/** Whether the AI should talk first when the call is connected. */
|
|
109
98
|
startTalking?: boolean;
|
|
110
99
|
}
|
|
111
100
|
|
|
112
101
|
export interface CreateOutboundCallDto {
|
|
113
|
-
/** This is the
|
|
114
|
-
|
|
115
|
-
/** This is the
|
|
116
|
-
|
|
102
|
+
/** This is the assistant that will be used for the call. To create a transient assistant, use `assistant` instead. */
|
|
103
|
+
assistantId?: string;
|
|
104
|
+
/** This is the assistant that will be used for the call. To use an existing assistant, use `assistantId` instead. */
|
|
105
|
+
assistant?: CreateAssistantDTO;
|
|
117
106
|
/** This is the phone number that will be used for the call. */
|
|
118
107
|
phoneNumberId: string;
|
|
119
108
|
/** This is the number that will be called. */
|
|
@@ -121,10 +110,10 @@ export interface CreateOutboundCallDto {
|
|
|
121
110
|
}
|
|
122
111
|
|
|
123
112
|
export interface CreateWebCallDto {
|
|
124
|
-
/** This is the
|
|
125
|
-
|
|
126
|
-
/** This is the
|
|
127
|
-
|
|
113
|
+
/** This is the assistant that will be used for the call. To create a transient assistant, use `assistant` instead. */
|
|
114
|
+
assistantId?: string;
|
|
115
|
+
/** This is the assistant that will be used for the call. To use an existing assistant, use `assistantId` instead. */
|
|
116
|
+
assistant?: CreateAssistantDTO;
|
|
128
117
|
}
|
|
129
118
|
|
|
130
119
|
export interface WebCallResponseDto {
|
|
@@ -132,7 +121,7 @@ export interface WebCallResponseDto {
|
|
|
132
121
|
callId: string;
|
|
133
122
|
}
|
|
134
123
|
|
|
135
|
-
export interface
|
|
124
|
+
export interface Assistant {
|
|
136
125
|
/** This is the OpenAI model that will be used. */
|
|
137
126
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
138
127
|
/**
|
|
@@ -160,41 +149,29 @@ export interface Agent {
|
|
|
160
149
|
| "steffan"
|
|
161
150
|
| "sara"
|
|
162
151
|
| "jason";
|
|
163
|
-
/** Unique identifier for the
|
|
152
|
+
/** Unique identifier for the assistant. */
|
|
164
153
|
id: string;
|
|
165
|
-
/** Unique identifier for the organization that this
|
|
154
|
+
/** Unique identifier for the organization that this assistant belongs to. */
|
|
166
155
|
orgId: string;
|
|
167
|
-
/** ISO 8601 date-time string of when the
|
|
156
|
+
/** ISO 8601 date-time string of when the assistant was created. */
|
|
168
157
|
createdAt: string;
|
|
169
|
-
/** ISO 8601 date-time string of when the
|
|
158
|
+
/** ISO 8601 date-time string of when the assistant was last updated. */
|
|
170
159
|
updatedAt: string;
|
|
171
|
-
/** This is the
|
|
160
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
172
161
|
name?: string;
|
|
173
162
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
174
163
|
context?: string;
|
|
175
|
-
/** These are the functions that the
|
|
164
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
176
165
|
functions?: OpenAIFunction[];
|
|
177
|
-
/**
|
|
178
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
179
|
-
*
|
|
180
|
-
* Function Calling POST Request:
|
|
181
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
182
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
183
|
-
*
|
|
184
|
-
* End-of-Call Report POST Request:
|
|
185
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
186
|
-
*
|
|
187
|
-
* Context Retrieval GET Request:
|
|
188
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
189
|
-
*/
|
|
166
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
190
167
|
callbackUrl?: string;
|
|
191
|
-
/** This is the number the
|
|
168
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
192
169
|
forwardingPhoneNumber?: string;
|
|
193
170
|
/** Whether the AI should talk first when the call is connected. */
|
|
194
171
|
startTalking?: boolean;
|
|
195
172
|
}
|
|
196
173
|
|
|
197
|
-
export interface
|
|
174
|
+
export interface UpdateAssistantDTO {
|
|
198
175
|
/** This is the OpenAI model that will be used. */
|
|
199
176
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
200
177
|
/**
|
|
@@ -222,27 +199,15 @@ export interface UpdateAgentDTO {
|
|
|
222
199
|
| "steffan"
|
|
223
200
|
| "sara"
|
|
224
201
|
| "jason";
|
|
225
|
-
/** This is the
|
|
202
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
226
203
|
name?: string;
|
|
227
204
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
228
205
|
context?: string;
|
|
229
|
-
/** These are the functions that the
|
|
206
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
230
207
|
functions?: OpenAIFunction[];
|
|
231
|
-
/**
|
|
232
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
233
|
-
*
|
|
234
|
-
* Function Calling POST Request:
|
|
235
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
236
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
237
|
-
*
|
|
238
|
-
* End-of-Call Report POST Request:
|
|
239
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
240
|
-
*
|
|
241
|
-
* Context Retrieval GET Request:
|
|
242
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
243
|
-
*/
|
|
208
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
244
209
|
callbackUrl?: string;
|
|
245
|
-
/** This is the number the
|
|
210
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
246
211
|
forwardingPhoneNumber?: string;
|
|
247
212
|
/** Whether the AI should talk first when the call is connected. */
|
|
248
213
|
startTalking?: boolean;
|
|
@@ -251,7 +216,7 @@ export interface UpdateAgentDTO {
|
|
|
251
216
|
export interface BuyPhoneNumberDto {
|
|
252
217
|
/** This is the area code of the phone number to purchase. */
|
|
253
218
|
areaCode: string;
|
|
254
|
-
|
|
219
|
+
assistantId?: string;
|
|
255
220
|
}
|
|
256
221
|
|
|
257
222
|
export interface PhoneNumber {
|
|
@@ -261,7 +226,7 @@ export interface PhoneNumber {
|
|
|
261
226
|
orgId: string;
|
|
262
227
|
stripeSubscriptionId?: string;
|
|
263
228
|
number: string;
|
|
264
|
-
|
|
229
|
+
assistantId?: string;
|
|
265
230
|
twilioAccountSid: string;
|
|
266
231
|
twilioAuthToken: string;
|
|
267
232
|
}
|
|
@@ -271,12 +236,12 @@ export interface ImportTwilioPhoneNumberDto {
|
|
|
271
236
|
twilioAccountSid: string;
|
|
272
237
|
twilioAuthToken: string;
|
|
273
238
|
twilioPhoneNumber: string;
|
|
274
|
-
|
|
239
|
+
assistantId?: string;
|
|
275
240
|
}
|
|
276
241
|
|
|
277
242
|
export interface UpdatePhoneNumberDto {
|
|
278
|
-
/** This is the
|
|
279
|
-
|
|
243
|
+
/** This is the assistant that will be used to handle inbound calls to this phone number. */
|
|
244
|
+
assistantId?: string;
|
|
280
245
|
}
|
|
281
246
|
|
|
282
247
|
export type QueryParamsType = Record<string | number, any>;
|
|
@@ -494,7 +459,7 @@ export class HttpClient<SecurityDataType = unknown> {
|
|
|
494
459
|
* @version 1.0
|
|
495
460
|
* @contact
|
|
496
461
|
*
|
|
497
|
-
* API for
|
|
462
|
+
* API for making voice assistants
|
|
498
463
|
*/
|
|
499
464
|
export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
|
500
465
|
call = {
|
|
@@ -566,18 +531,18 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
566
531
|
...params,
|
|
567
532
|
}),
|
|
568
533
|
};
|
|
569
|
-
|
|
534
|
+
assistant = {
|
|
570
535
|
/**
|
|
571
536
|
* No description
|
|
572
537
|
*
|
|
573
|
-
* @tags
|
|
574
|
-
* @name
|
|
575
|
-
* @summary Create
|
|
576
|
-
* @request POST:/
|
|
538
|
+
* @tags Assistants
|
|
539
|
+
* @name AssistantControllerCreate
|
|
540
|
+
* @summary Create Assistant
|
|
541
|
+
* @request POST:/assistant
|
|
577
542
|
*/
|
|
578
|
-
|
|
579
|
-
this.request<
|
|
580
|
-
path: `/
|
|
543
|
+
assistantControllerCreate: (data: CreateAssistantDTO, params: RequestParams = {}) =>
|
|
544
|
+
this.request<Assistant, any>({
|
|
545
|
+
path: `/assistant`,
|
|
581
546
|
method: "POST",
|
|
582
547
|
body: data,
|
|
583
548
|
type: ContentType.Json,
|
|
@@ -588,14 +553,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
588
553
|
/**
|
|
589
554
|
* No description
|
|
590
555
|
*
|
|
591
|
-
* @tags
|
|
592
|
-
* @name
|
|
593
|
-
* @summary List
|
|
594
|
-
* @request GET:/
|
|
556
|
+
* @tags Assistants
|
|
557
|
+
* @name AssistantControllerFindAll
|
|
558
|
+
* @summary List Assistants
|
|
559
|
+
* @request GET:/assistant
|
|
595
560
|
*/
|
|
596
|
-
|
|
597
|
-
this.request<
|
|
598
|
-
path: `/
|
|
561
|
+
assistantControllerFindAll: (params: RequestParams = {}) =>
|
|
562
|
+
this.request<Assistant[], any>({
|
|
563
|
+
path: `/assistant`,
|
|
599
564
|
method: "GET",
|
|
600
565
|
format: "json",
|
|
601
566
|
...params,
|
|
@@ -604,14 +569,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
604
569
|
/**
|
|
605
570
|
* No description
|
|
606
571
|
*
|
|
607
|
-
* @tags
|
|
608
|
-
* @name
|
|
609
|
-
* @summary Get
|
|
610
|
-
* @request GET:/
|
|
572
|
+
* @tags Assistants
|
|
573
|
+
* @name AssistantControllerFindOne
|
|
574
|
+
* @summary Get Assistant
|
|
575
|
+
* @request GET:/assistant/{id}
|
|
611
576
|
*/
|
|
612
|
-
|
|
613
|
-
this.request<
|
|
614
|
-
path: `/
|
|
577
|
+
assistantControllerFindOne: (id: string, params: RequestParams = {}) =>
|
|
578
|
+
this.request<Assistant, any>({
|
|
579
|
+
path: `/assistant/${id}`,
|
|
615
580
|
method: "GET",
|
|
616
581
|
format: "json",
|
|
617
582
|
...params,
|
|
@@ -620,14 +585,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
620
585
|
/**
|
|
621
586
|
* No description
|
|
622
587
|
*
|
|
623
|
-
* @tags
|
|
624
|
-
* @name
|
|
625
|
-
* @summary Update
|
|
626
|
-
* @request PATCH:/
|
|
588
|
+
* @tags Assistants
|
|
589
|
+
* @name AssistantControllerUpdate
|
|
590
|
+
* @summary Update Assistant
|
|
591
|
+
* @request PATCH:/assistant/{id}
|
|
627
592
|
*/
|
|
628
|
-
|
|
629
|
-
this.request<
|
|
630
|
-
path: `/
|
|
593
|
+
assistantControllerUpdate: (id: string, data: UpdateAssistantDTO, params: RequestParams = {}) =>
|
|
594
|
+
this.request<Assistant, any>({
|
|
595
|
+
path: `/assistant/${id}`,
|
|
631
596
|
method: "PATCH",
|
|
632
597
|
body: data,
|
|
633
598
|
type: ContentType.Json,
|
|
@@ -638,14 +603,14 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
|
|
|
638
603
|
/**
|
|
639
604
|
* No description
|
|
640
605
|
*
|
|
641
|
-
* @tags
|
|
642
|
-
* @name
|
|
643
|
-
* @summary Delete
|
|
644
|
-
* @request DELETE:/
|
|
606
|
+
* @tags Assistants
|
|
607
|
+
* @name AssistantControllerRemove
|
|
608
|
+
* @summary Delete Assistant
|
|
609
|
+
* @request DELETE:/assistant/{id}
|
|
645
610
|
*/
|
|
646
|
-
|
|
611
|
+
assistantControllerRemove: (id: string, params: RequestParams = {}) =>
|
|
647
612
|
this.request<void, any>({
|
|
648
|
-
path: `/
|
|
613
|
+
path: `/assistant/${id}`,
|
|
649
614
|
method: "DELETE",
|
|
650
615
|
...params,
|
|
651
616
|
}),
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface PhoneCallParams {
|
|
2
2
|
callSid?: string;
|
|
3
|
+
status?: string;
|
|
3
4
|
customerPhoneNumber: string;
|
|
4
5
|
twilioPhoneNumber: string;
|
|
5
6
|
twilioAccountSid: string;
|
|
@@ -11,7 +12,7 @@ export interface Call {
|
|
|
11
12
|
orgId: string;
|
|
12
13
|
createdAt: string;
|
|
13
14
|
updatedAt: string;
|
|
14
|
-
|
|
15
|
+
assistantId?: string;
|
|
15
16
|
customerId?: string;
|
|
16
17
|
phoneNumberId?: string;
|
|
17
18
|
startedAt: string;
|
|
@@ -20,7 +21,7 @@ export interface Call {
|
|
|
20
21
|
recordingUrl?: string;
|
|
21
22
|
cost?: number;
|
|
22
23
|
summary?: string;
|
|
23
|
-
|
|
24
|
+
assistantParams?: object;
|
|
24
25
|
callParams?: PhoneCallParams;
|
|
25
26
|
}
|
|
26
27
|
export interface OpenAIFunctionParamaters {
|
|
@@ -40,7 +41,7 @@ export interface OpenAIFunction {
|
|
|
40
41
|
*/
|
|
41
42
|
parameters: OpenAIFunctionParamaters;
|
|
42
43
|
}
|
|
43
|
-
export interface
|
|
44
|
+
export interface CreateAssistantDTO {
|
|
44
45
|
/** This is the OpenAI model that will be used. */
|
|
45
46
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
46
47
|
/**
|
|
@@ -51,52 +52,40 @@ export interface CreateAgentDTO {
|
|
|
51
52
|
* Basic Voices: davis, jenny, aria, steffan, sara, and jason.
|
|
52
53
|
*/
|
|
53
54
|
voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
|
|
54
|
-
/** This is the
|
|
55
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
55
56
|
name?: string;
|
|
56
57
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
57
58
|
context?: string;
|
|
58
|
-
/** These are the functions that the
|
|
59
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
59
60
|
functions?: OpenAIFunction[];
|
|
60
|
-
/**
|
|
61
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
62
|
-
*
|
|
63
|
-
* Function Calling POST Request:
|
|
64
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
65
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
66
|
-
*
|
|
67
|
-
* End-of-Call Report POST Request:
|
|
68
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
69
|
-
*
|
|
70
|
-
* Context Retrieval GET Request:
|
|
71
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
72
|
-
*/
|
|
61
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
73
62
|
callbackUrl?: string;
|
|
74
|
-
/** This is the number the
|
|
63
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
75
64
|
forwardingPhoneNumber?: string;
|
|
76
65
|
/** Whether the AI should talk first when the call is connected. */
|
|
77
66
|
startTalking?: boolean;
|
|
78
67
|
}
|
|
79
68
|
export interface CreateOutboundCallDto {
|
|
80
|
-
/** This is the
|
|
81
|
-
|
|
82
|
-
/** This is the
|
|
83
|
-
|
|
69
|
+
/** This is the assistant that will be used for the call. To create a transient assistant, use `assistant` instead. */
|
|
70
|
+
assistantId?: string;
|
|
71
|
+
/** This is the assistant that will be used for the call. To use an existing assistant, use `assistantId` instead. */
|
|
72
|
+
assistant?: CreateAssistantDTO;
|
|
84
73
|
/** This is the phone number that will be used for the call. */
|
|
85
74
|
phoneNumberId: string;
|
|
86
75
|
/** This is the number that will be called. */
|
|
87
76
|
customerPhoneNumber: string;
|
|
88
77
|
}
|
|
89
78
|
export interface CreateWebCallDto {
|
|
90
|
-
/** This is the
|
|
91
|
-
|
|
92
|
-
/** This is the
|
|
93
|
-
|
|
79
|
+
/** This is the assistant that will be used for the call. To create a transient assistant, use `assistant` instead. */
|
|
80
|
+
assistantId?: string;
|
|
81
|
+
/** This is the assistant that will be used for the call. To use an existing assistant, use `assistantId` instead. */
|
|
82
|
+
assistant?: CreateAssistantDTO;
|
|
94
83
|
}
|
|
95
84
|
export interface WebCallResponseDto {
|
|
96
85
|
url: string;
|
|
97
86
|
callId: string;
|
|
98
87
|
}
|
|
99
|
-
export interface
|
|
88
|
+
export interface Assistant {
|
|
100
89
|
/** This is the OpenAI model that will be used. */
|
|
101
90
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
102
91
|
/**
|
|
@@ -107,40 +96,28 @@ export interface Agent {
|
|
|
107
96
|
* Basic Voices: davis, jenny, aria, steffan, sara, and jason.
|
|
108
97
|
*/
|
|
109
98
|
voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
|
|
110
|
-
/** Unique identifier for the
|
|
99
|
+
/** Unique identifier for the assistant. */
|
|
111
100
|
id: string;
|
|
112
|
-
/** Unique identifier for the organization that this
|
|
101
|
+
/** Unique identifier for the organization that this assistant belongs to. */
|
|
113
102
|
orgId: string;
|
|
114
|
-
/** ISO 8601 date-time string of when the
|
|
103
|
+
/** ISO 8601 date-time string of when the assistant was created. */
|
|
115
104
|
createdAt: string;
|
|
116
|
-
/** ISO 8601 date-time string of when the
|
|
105
|
+
/** ISO 8601 date-time string of when the assistant was last updated. */
|
|
117
106
|
updatedAt: string;
|
|
118
|
-
/** This is the
|
|
107
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
119
108
|
name?: string;
|
|
120
109
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
121
110
|
context?: string;
|
|
122
|
-
/** These are the functions that the
|
|
111
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
123
112
|
functions?: OpenAIFunction[];
|
|
124
|
-
/**
|
|
125
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
126
|
-
*
|
|
127
|
-
* Function Calling POST Request:
|
|
128
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
129
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
130
|
-
*
|
|
131
|
-
* End-of-Call Report POST Request:
|
|
132
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
133
|
-
*
|
|
134
|
-
* Context Retrieval GET Request:
|
|
135
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
136
|
-
*/
|
|
113
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
137
114
|
callbackUrl?: string;
|
|
138
|
-
/** This is the number the
|
|
115
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
139
116
|
forwardingPhoneNumber?: string;
|
|
140
117
|
/** Whether the AI should talk first when the call is connected. */
|
|
141
118
|
startTalking?: boolean;
|
|
142
119
|
}
|
|
143
|
-
export interface
|
|
120
|
+
export interface UpdateAssistantDTO {
|
|
144
121
|
/** This is the OpenAI model that will be used. */
|
|
145
122
|
model?: "gpt-4-32k" | "gpt-4" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo";
|
|
146
123
|
/**
|
|
@@ -151,27 +128,15 @@ export interface UpdateAgentDTO {
|
|
|
151
128
|
* Basic Voices: davis, jenny, aria, steffan, sara, and jason.
|
|
152
129
|
*/
|
|
153
130
|
voice?: "burt" | "phillip" | "steve" | "joseph" | "myra" | "paula" | "ryan" | "drew" | "paul" | "mrb" | "matilda" | "davis" | "jenny" | "aria" | "steffan" | "sara" | "jason";
|
|
154
|
-
/** This is the
|
|
131
|
+
/** This is the assistant’s name, just for your own reference. */
|
|
155
132
|
name?: string;
|
|
156
133
|
/** This is the system prompt, which sets the objective and background before the call. */
|
|
157
134
|
context?: string;
|
|
158
|
-
/** These are the functions that the
|
|
135
|
+
/** These are the functions that the assistant can execute during the call. */
|
|
159
136
|
functions?: OpenAIFunction[];
|
|
160
|
-
/**
|
|
161
|
-
* This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber, botPhoneNumber, and all the agent parameters.
|
|
162
|
-
*
|
|
163
|
-
* Function Calling POST Request:
|
|
164
|
-
* When the agent wants to call a function, we'll POST your callbackURL with `name` and `arguments`.
|
|
165
|
-
* Respond with a JSON object of the result. For example: `{ result: "Hello world!" }` or `{ result: { temperature: "38 degrees" } }`. If empty, return `{}.
|
|
166
|
-
*
|
|
167
|
-
* End-of-Call Report POST Request:
|
|
168
|
-
* You'll get `transcript`, `recordingUrl` and `summary` of the call.
|
|
169
|
-
*
|
|
170
|
-
* Context Retrieval GET Request:
|
|
171
|
-
* If the agent's context isn't set, it'll ask for context before starting the call. Respond with `{ context: "You are an assistant..." }`
|
|
172
|
-
*/
|
|
137
|
+
/** This is the URL Vapi will send GET / POST requests for retrieving context, function calling, and end-of-call reports. All requests will be sent with customerPhoneNumber and all the assistant parameters. You can find more details in the Function Calling documentation. */
|
|
173
138
|
callbackUrl?: string;
|
|
174
|
-
/** This is the number the
|
|
139
|
+
/** This is the number the assistant will transfer to if it runs into any issues. */
|
|
175
140
|
forwardingPhoneNumber?: string;
|
|
176
141
|
/** Whether the AI should talk first when the call is connected. */
|
|
177
142
|
startTalking?: boolean;
|
|
@@ -179,7 +144,7 @@ export interface UpdateAgentDTO {
|
|
|
179
144
|
export interface BuyPhoneNumberDto {
|
|
180
145
|
/** This is the area code of the phone number to purchase. */
|
|
181
146
|
areaCode: string;
|
|
182
|
-
|
|
147
|
+
assistantId?: string;
|
|
183
148
|
}
|
|
184
149
|
export interface PhoneNumber {
|
|
185
150
|
id: string;
|
|
@@ -188,7 +153,7 @@ export interface PhoneNumber {
|
|
|
188
153
|
orgId: string;
|
|
189
154
|
stripeSubscriptionId?: string;
|
|
190
155
|
number: string;
|
|
191
|
-
|
|
156
|
+
assistantId?: string;
|
|
192
157
|
twilioAccountSid: string;
|
|
193
158
|
twilioAuthToken: string;
|
|
194
159
|
}
|
|
@@ -197,11 +162,11 @@ export interface ImportTwilioPhoneNumberDto {
|
|
|
197
162
|
twilioAccountSid: string;
|
|
198
163
|
twilioAuthToken: string;
|
|
199
164
|
twilioPhoneNumber: string;
|
|
200
|
-
|
|
165
|
+
assistantId?: string;
|
|
201
166
|
}
|
|
202
167
|
export interface UpdatePhoneNumberDto {
|
|
203
|
-
/** This is the
|
|
204
|
-
|
|
168
|
+
/** This is the assistant that will be used to handle inbound calls to this phone number. */
|
|
169
|
+
assistantId?: string;
|
|
205
170
|
}
|
|
206
171
|
export type QueryParamsType = Record<string | number, any>;
|
|
207
172
|
export type ResponseFormat = keyof Omit<Body, "body" | "bodyUsed">;
|
|
@@ -266,7 +231,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
|
|
|
266
231
|
* @version 1.0
|
|
267
232
|
* @contact
|
|
268
233
|
*
|
|
269
|
-
* API for
|
|
234
|
+
* API for making voice assistants
|
|
270
235
|
*/
|
|
271
236
|
export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
|
272
237
|
call: {
|
|
@@ -307,52 +272,52 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
307
272
|
*/
|
|
308
273
|
callControllerCreateWebCall: (data: CreateWebCallDto, params?: RequestParams) => Promise<HttpResponse<WebCallResponseDto, any>>;
|
|
309
274
|
};
|
|
310
|
-
|
|
275
|
+
assistant: {
|
|
311
276
|
/**
|
|
312
277
|
* No description
|
|
313
278
|
*
|
|
314
|
-
* @tags
|
|
315
|
-
* @name
|
|
316
|
-
* @summary Create
|
|
317
|
-
* @request POST:/
|
|
279
|
+
* @tags Assistants
|
|
280
|
+
* @name AssistantControllerCreate
|
|
281
|
+
* @summary Create Assistant
|
|
282
|
+
* @request POST:/assistant
|
|
318
283
|
*/
|
|
319
|
-
|
|
284
|
+
assistantControllerCreate: (data: CreateAssistantDTO, params?: RequestParams) => Promise<HttpResponse<Assistant, any>>;
|
|
320
285
|
/**
|
|
321
286
|
* No description
|
|
322
287
|
*
|
|
323
|
-
* @tags
|
|
324
|
-
* @name
|
|
325
|
-
* @summary List
|
|
326
|
-
* @request GET:/
|
|
288
|
+
* @tags Assistants
|
|
289
|
+
* @name AssistantControllerFindAll
|
|
290
|
+
* @summary List Assistants
|
|
291
|
+
* @request GET:/assistant
|
|
327
292
|
*/
|
|
328
|
-
|
|
293
|
+
assistantControllerFindAll: (params?: RequestParams) => Promise<HttpResponse<Assistant[], any>>;
|
|
329
294
|
/**
|
|
330
295
|
* No description
|
|
331
296
|
*
|
|
332
|
-
* @tags
|
|
333
|
-
* @name
|
|
334
|
-
* @summary Get
|
|
335
|
-
* @request GET:/
|
|
297
|
+
* @tags Assistants
|
|
298
|
+
* @name AssistantControllerFindOne
|
|
299
|
+
* @summary Get Assistant
|
|
300
|
+
* @request GET:/assistant/{id}
|
|
336
301
|
*/
|
|
337
|
-
|
|
302
|
+
assistantControllerFindOne: (id: string, params?: RequestParams) => Promise<HttpResponse<Assistant, any>>;
|
|
338
303
|
/**
|
|
339
304
|
* No description
|
|
340
305
|
*
|
|
341
|
-
* @tags
|
|
342
|
-
* @name
|
|
343
|
-
* @summary Update
|
|
344
|
-
* @request PATCH:/
|
|
306
|
+
* @tags Assistants
|
|
307
|
+
* @name AssistantControllerUpdate
|
|
308
|
+
* @summary Update Assistant
|
|
309
|
+
* @request PATCH:/assistant/{id}
|
|
345
310
|
*/
|
|
346
|
-
|
|
311
|
+
assistantControllerUpdate: (id: string, data: UpdateAssistantDTO, params?: RequestParams) => Promise<HttpResponse<Assistant, any>>;
|
|
347
312
|
/**
|
|
348
313
|
* No description
|
|
349
314
|
*
|
|
350
|
-
* @tags
|
|
351
|
-
* @name
|
|
352
|
-
* @summary Delete
|
|
353
|
-
* @request DELETE:/
|
|
315
|
+
* @tags Assistants
|
|
316
|
+
* @name AssistantControllerRemove
|
|
317
|
+
* @summary Delete Assistant
|
|
318
|
+
* @request DELETE:/assistant/{id}
|
|
354
319
|
*/
|
|
355
|
-
|
|
320
|
+
assistantControllerRemove: (id: string, params?: RequestParams) => Promise<HttpResponse<void, any>>;
|
|
356
321
|
};
|
|
357
322
|
phoneNumber: {
|
|
358
323
|
/**
|
package/dist/api.js
CHANGED
|
@@ -158,7 +158,7 @@ exports.HttpClient = HttpClient;
|
|
|
158
158
|
* @version 1.0
|
|
159
159
|
* @contact
|
|
160
160
|
*
|
|
161
|
-
* API for
|
|
161
|
+
* API for making voice assistants
|
|
162
162
|
*/
|
|
163
163
|
class Api extends HttpClient {
|
|
164
164
|
constructor() {
|
|
@@ -201,52 +201,52 @@ class Api extends HttpClient {
|
|
|
201
201
|
*/
|
|
202
202
|
callControllerCreateWebCall: (data, params = {}) => this.request(Object.assign({ path: `/call/web`, method: "POST", body: data, type: ContentType.Json, format: "json" }, params)),
|
|
203
203
|
};
|
|
204
|
-
this.
|
|
204
|
+
this.assistant = {
|
|
205
205
|
/**
|
|
206
206
|
* No description
|
|
207
207
|
*
|
|
208
|
-
* @tags
|
|
209
|
-
* @name
|
|
210
|
-
* @summary Create
|
|
211
|
-
* @request POST:/
|
|
208
|
+
* @tags Assistants
|
|
209
|
+
* @name AssistantControllerCreate
|
|
210
|
+
* @summary Create Assistant
|
|
211
|
+
* @request POST:/assistant
|
|
212
212
|
*/
|
|
213
|
-
|
|
213
|
+
assistantControllerCreate: (data, params = {}) => this.request(Object.assign({ path: `/assistant`, method: "POST", body: data, type: ContentType.Json, format: "json" }, params)),
|
|
214
214
|
/**
|
|
215
215
|
* No description
|
|
216
216
|
*
|
|
217
|
-
* @tags
|
|
218
|
-
* @name
|
|
219
|
-
* @summary List
|
|
220
|
-
* @request GET:/
|
|
217
|
+
* @tags Assistants
|
|
218
|
+
* @name AssistantControllerFindAll
|
|
219
|
+
* @summary List Assistants
|
|
220
|
+
* @request GET:/assistant
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
assistantControllerFindAll: (params = {}) => this.request(Object.assign({ path: `/assistant`, method: "GET", format: "json" }, params)),
|
|
223
223
|
/**
|
|
224
224
|
* No description
|
|
225
225
|
*
|
|
226
|
-
* @tags
|
|
227
|
-
* @name
|
|
228
|
-
* @summary Get
|
|
229
|
-
* @request GET:/
|
|
226
|
+
* @tags Assistants
|
|
227
|
+
* @name AssistantControllerFindOne
|
|
228
|
+
* @summary Get Assistant
|
|
229
|
+
* @request GET:/assistant/{id}
|
|
230
230
|
*/
|
|
231
|
-
|
|
231
|
+
assistantControllerFindOne: (id, params = {}) => this.request(Object.assign({ path: `/assistant/${id}`, method: "GET", format: "json" }, params)),
|
|
232
232
|
/**
|
|
233
233
|
* No description
|
|
234
234
|
*
|
|
235
|
-
* @tags
|
|
236
|
-
* @name
|
|
237
|
-
* @summary Update
|
|
238
|
-
* @request PATCH:/
|
|
235
|
+
* @tags Assistants
|
|
236
|
+
* @name AssistantControllerUpdate
|
|
237
|
+
* @summary Update Assistant
|
|
238
|
+
* @request PATCH:/assistant/{id}
|
|
239
239
|
*/
|
|
240
|
-
|
|
240
|
+
assistantControllerUpdate: (id, data, params = {}) => this.request(Object.assign({ path: `/assistant/${id}`, method: "PATCH", body: data, type: ContentType.Json, format: "json" }, params)),
|
|
241
241
|
/**
|
|
242
242
|
* No description
|
|
243
243
|
*
|
|
244
|
-
* @tags
|
|
245
|
-
* @name
|
|
246
|
-
* @summary Delete
|
|
247
|
-
* @request DELETE:/
|
|
244
|
+
* @tags Assistants
|
|
245
|
+
* @name AssistantControllerRemove
|
|
246
|
+
* @summary Delete Assistant
|
|
247
|
+
* @request DELETE:/assistant/{id}
|
|
248
248
|
*/
|
|
249
|
-
|
|
249
|
+
assistantControllerRemove: (id, params = {}) => this.request(Object.assign({ path: `/assistant/${id}`, method: "DELETE" }, params)),
|
|
250
250
|
};
|
|
251
251
|
this.phoneNumber = {
|
|
252
252
|
/**
|
package/dist/vapi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { CreateAssistantDTO } from "./api";
|
|
3
3
|
import EventEmitter from "events";
|
|
4
4
|
export default class Vapi extends EventEmitter {
|
|
5
5
|
private started;
|
|
@@ -7,7 +7,7 @@ export default class Vapi extends EventEmitter {
|
|
|
7
7
|
private mediaRecorder;
|
|
8
8
|
private player;
|
|
9
9
|
constructor(apiToken: string);
|
|
10
|
-
start(
|
|
10
|
+
start(assistant: CreateAssistantDTO | string): void;
|
|
11
11
|
private startRecording;
|
|
12
12
|
private onMessage;
|
|
13
13
|
clear(): void;
|
package/dist/vapi.js
CHANGED
|
@@ -18,7 +18,7 @@ class Vapi extends events_1.default {
|
|
|
18
18
|
this.player.on("speech-start", () => this.emit("speech-start"));
|
|
19
19
|
this.player.on("speech-end", () => this.emit("speech-end"));
|
|
20
20
|
}
|
|
21
|
-
start(
|
|
21
|
+
start(assistant) {
|
|
22
22
|
if (this.started) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -26,8 +26,8 @@ class Vapi extends events_1.default {
|
|
|
26
26
|
this.player.start();
|
|
27
27
|
client_1.client.call
|
|
28
28
|
.callControllerCreateWebCall({
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
assistant: typeof assistant === "string" ? undefined : assistant,
|
|
30
|
+
assistantId: typeof assistant === "string" ? assistant : undefined,
|
|
31
31
|
})
|
|
32
32
|
.then(({ data }) => {
|
|
33
33
|
const { callId, url } = data;
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Agent, CreateAgentDTO } from "./api";
|
|
2
|
-
|
|
3
1
|
import { ContinuousPlayer } from "./player";
|
|
2
|
+
import { CreateAssistantDTO } from "./api";
|
|
4
3
|
import EventEmitter from "events";
|
|
5
4
|
import { client } from "./client";
|
|
6
5
|
import { decode } from "base64-arraybuffer";
|
|
@@ -20,7 +19,7 @@ export default class Vapi extends EventEmitter {
|
|
|
20
19
|
this.player.on("speech-end", () => this.emit("speech-end"));
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
start(
|
|
22
|
+
start(assistant: CreateAssistantDTO | string): void {
|
|
24
23
|
if (this.started) {
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
@@ -30,8 +29,8 @@ export default class Vapi extends EventEmitter {
|
|
|
30
29
|
|
|
31
30
|
client.call
|
|
32
31
|
.callControllerCreateWebCall({
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
assistant: typeof assistant === "string" ? undefined : assistant,
|
|
33
|
+
assistantId: typeof assistant === "string" ? assistant : undefined,
|
|
35
34
|
})
|
|
36
35
|
.then(({ data }) => {
|
|
37
36
|
const { callId, url } = data;
|