-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvapi.types.ts
More file actions
194 lines (173 loc) · 4.51 KB
/
vapi.types.ts
File metadata and controls
194 lines (173 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
ChatCompletionCreateParams,
ChatCompletionMessageParam,
FunctionDefinition,
} from "openai/resources";
export interface Model {
model: string;
systemPrompt?: string;
temperature?: number;
functions?: {
name: string;
async?: boolean;
description?: string;
parameters?: FunctionDefinition | any;
}[];
provider: string;
url?: string;
}
const PLAY_HT_EMOTIONS = [
"female_happy",
"female_sad",
"female_angry",
"female_fearful",
"female_disgust",
"female_surprised",
] as const;
type PlayHTEmotion = (typeof PLAY_HT_EMOTIONS)[number];
interface Voice {
provider: string;
voiceId: string;
speed?: number;
stability?: number;
similarityBoost?: number;
style?: number;
useSpeakerBoost?: boolean;
temperature?: number;
emotion?: PlayHTEmotion;
voiceGuidance?: number;
styleGuidance?: number;
textGuidance?: number;
}
export interface Assistant {
// Properties from AssistantUserEditable
name?: string;
transcriber?: {
provider: "deepgram";
model?: string;
keywords?: string[];
};
model?: Model;
voice?: Voice;
language?: string;
forwardingPhoneNumber?: string;
firstMessage?: string;
voicemailMessage?: string;
endCallMessage?: string;
endCallPhrases?: string[];
interruptionsEnabled?: boolean;
recordingEnabled?: boolean;
endCallFunctionEnabled?: boolean;
dialKeypadFunctionEnabled?: boolean;
fillersEnabled?: boolean;
clientMessages?: any[];
serverMessages?: any[];
silenceTimeoutSeconds?: number;
responseDelaySeconds?: number;
liveTranscriptsEnabled?: boolean;
keywords?: string[];
parentId?: string;
serverUrl?: string;
serverUrlSecret?: string;
// Properties from AssistantPrivileged
id?: string;
orgId?: string;
createdAt?: Date;
updatedAt?: Date;
}
export const VAPI_CALL_STATUSES = [
"queued",
"ringing",
"in-progress",
"forwarding",
"ended",
] as const;
export type VapiCallStatus = (typeof VAPI_CALL_STATUSES)[number];
export enum VapiWebhookEnum {
ASSISTANT_REQUEST = "assistant-request",
FUNCTION_CALL = "function-call",
STATUS_UPDATE = "status-update",
END_OF_CALL_REPORT = "end-of-call-report",
HANG = "hang",
SPEECH_UPDATE = "speech-update",
TRANSCRIPT = "transcript",
}
export interface ConversationMessage {
role: "user" | "system" | "bot" | "function_call" | "function_result";
message?: string;
name?: string;
args?: string;
result?: string;
time: number;
endTime?: number;
secondsFromStart: number;
}
interface BaseVapiPayload {
call: VapiCall;
}
export interface AssistantRequestPayload extends BaseVapiPayload {
type: VapiWebhookEnum.ASSISTANT_REQUEST;
}
export interface StatusUpdatePayload extends BaseVapiPayload {
type: VapiWebhookEnum.STATUS_UPDATE;
status: VapiCallStatus;
messages?: ChatCompletionMessageParam[];
}
export interface FunctionCallPayload extends BaseVapiPayload {
type: VapiWebhookEnum.FUNCTION_CALL;
functionCall: ChatCompletionCreateParams.Function;
}
export interface EndOfCallReportPayload extends BaseVapiPayload {
type: VapiWebhookEnum.END_OF_CALL_REPORT;
endedReason: string;
transcript: string;
messages: ConversationMessage[];
summary: string;
recordingUrl?: string;
}
export interface HangPayload extends BaseVapiPayload {
type: VapiWebhookEnum.HANG;
}
export interface SpeechUpdatePayload extends BaseVapiPayload {
type: VapiWebhookEnum.SPEECH_UPDATE;
status: "started" | "stopped";
role: "assistant" | "user";
}
export interface TranscriptPayload {
type: VapiWebhookEnum.TRANSCRIPT;
role: "assistant" | "user";
transcriptType: "partial" | "final";
transcript: string;
}
export interface VapiCall {}
export type VapiPayload =
| AssistantRequestPayload
| StatusUpdatePayload
| FunctionCallPayload
| EndOfCallReportPayload
| SpeechUpdatePayload
| TranscriptPayload
| HangPayload;
export type FunctionCallMessageResponse =
| {
result: string;
}
| any;
export interface AssistantRequestMessageResponse {
assistant?: Assistant;
error?: string;
}
export interface StatusUpdateMessageResponse {}
export interface SpeechUpdateMessageResponse {}
export interface TranscriptMessageResponse {}
export interface HangMessageResponse {}
export interface EndOfCallReportMessageResponse {}
export type VapiResponse =
| AssistantRequestMessageResponse
| FunctionCallMessageResponse
| EndOfCallReportMessageResponse
| HangMessageResponse
| StatusUpdateMessageResponse
| SpeechUpdateMessageResponse
| TranscriptMessageResponse;