vapi_client/models/
assistant.rs

1/*
2 * Vapi API
3 *
4 * API for building voice assistants
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Assistant {
17    #[serde(rename = "transcriber", skip_serializing_if = "Option::is_none")]
18    pub transcriber: Option<models::CreateAssistantDtoTranscriber>,
19    #[serde(rename = "model", skip_serializing_if = "Option::is_none")]
20    pub model: Option<models::CreateAssistantDtoModel>,
21    #[serde(rename = "voice", skip_serializing_if = "Option::is_none")]
22    pub voice: Option<models::CreateAssistantDtoVoice>,
23    /// This is the first message that the assistant will say. This can also be a URL to a containerized audio file (mp3, wav, etc.).  If unspecified, assistant will wait for user to speak and use the model to respond once they speak.
24    #[serde(rename = "firstMessage", skip_serializing_if = "Option::is_none")]
25    pub first_message: Option<String>,
26    /// This is the mode for the first message. Default is 'assistant-speaks-first'.  Use: - 'assistant-speaks-first' to have the assistant speak first. - 'assistant-waits-for-user' to have the assistant wait for the user to speak first. - 'assistant-speaks-first-with-model-generated-message' to have the assistant speak first with a message generated by the model based on the conversation state. (`assistant.model.messages` at call start, `call.messages` at squad transfer points).  @default 'assistant-speaks-first'
27    #[serde(rename = "firstMessageMode", skip_serializing_if = "Option::is_none")]
28    pub first_message_mode: Option<FirstMessageMode>,
29    /// These are the settings to configure or disable voicemail detection. Alternatively, voicemail detection can be configured using the model.tools=[VoicemailTool]. This uses Twilio's built-in detection while the VoicemailTool relies on the model to detect if a voicemail was reached. You can use neither of them, one of them, or both of them. By default, Twilio built-in detection is enabled while VoicemailTool is not.
30    #[serde(rename = "voicemailDetection", skip_serializing_if = "Option::is_none")]
31    pub voicemail_detection: Option<serde_json::Value>,
32    /// These are the messages that will be sent to your Client SDKs. Default is conversation-update,function-call,hang,model-output,speech-update,status-update,transfer-update,transcript,tool-calls,user-interrupted,voice-input. You can check the shape of the messages in ClientMessage schema.
33    #[serde(rename = "clientMessages", skip_serializing_if = "Option::is_none")]
34    pub client_messages: Option<Vec<ClientMessages>>,
35    /// These are the messages that will be sent to your Server URL. Default is conversation-update,end-of-call-report,function-call,hang,speech-update,status-update,tool-calls,transfer-destination-request,user-interrupted. You can check the shape of the messages in ServerMessage schema.
36    #[serde(rename = "serverMessages", skip_serializing_if = "Option::is_none")]
37    pub server_messages: Option<Vec<ServerMessages>>,
38    /// How many seconds of silence to wait before ending the call. Defaults to 30.  @default 30
39    #[serde(
40        rename = "silenceTimeoutSeconds",
41        skip_serializing_if = "Option::is_none"
42    )]
43    pub silence_timeout_seconds: Option<f64>,
44    /// This is the maximum number of seconds that the call will last. When the call reaches this duration, it will be ended.  @default 600 (10 minutes)
45    #[serde(rename = "maxDurationSeconds", skip_serializing_if = "Option::is_none")]
46    pub max_duration_seconds: Option<f64>,
47    /// This is the background sound in the call. Default for phone calls is 'office' and default for web calls is 'off'.
48    #[serde(rename = "backgroundSound", skip_serializing_if = "Option::is_none")]
49    pub background_sound: Option<BackgroundSound>,
50    /// This enables filtering of noise and background speech while the user is talking.  Default `false` while in beta.  @default false
51    #[serde(
52        rename = "backgroundDenoisingEnabled",
53        skip_serializing_if = "Option::is_none"
54    )]
55    pub background_denoising_enabled: Option<bool>,
56    /// This determines whether the model's output is used in conversation history rather than the transcription of assistant's speech.  Default `false` while in beta.  @default false
57    #[serde(
58        rename = "modelOutputInMessagesEnabled",
59        skip_serializing_if = "Option::is_none"
60    )]
61    pub model_output_in_messages_enabled: Option<bool>,
62    /// These are the configurations to be passed to the transport providers of assistant's calls, like Twilio. You can store multiple configurations for different transport providers. For a call, only the configuration matching the call transport provider is used.
63    #[serde(
64        rename = "transportConfigurations",
65        skip_serializing_if = "Option::is_none"
66    )]
67    pub transport_configurations:
68        Option<Vec<models::CreateAssistantDtoTransportConfigurationsInner>>,
69    /// These are dynamic credentials that will be used for the assistant calls. By default, all the credentials are available for use in the call but you can supplement an additional credentials using this. Dynamic credentials override existing credentials.
70    #[serde(rename = "credentials", skip_serializing_if = "Option::is_none")]
71    pub credentials: Option<Vec<models::CreateAssistantDtoCredentialsInner>>,
72    /// This is the name of the assistant.  This is required when you want to transfer between assistants in a call.
73    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
74    pub name: Option<String>,
75    /// This is the message that the assistant will say if the call is forwarded to voicemail.  If unspecified, it will hang up.
76    #[serde(rename = "voicemailMessage", skip_serializing_if = "Option::is_none")]
77    pub voicemail_message: Option<String>,
78    /// This is the message that the assistant will say if it ends the call.  If unspecified, it will hang up without saying anything.
79    #[serde(rename = "endCallMessage", skip_serializing_if = "Option::is_none")]
80    pub end_call_message: Option<String>,
81    /// This list contains phrases that, if spoken by the assistant, will trigger the call to be hung up. Case insensitive.
82    #[serde(rename = "endCallPhrases", skip_serializing_if = "Option::is_none")]
83    pub end_call_phrases: Option<Vec<String>>,
84    #[serde(rename = "compliancePlan", skip_serializing_if = "Option::is_none")]
85    pub compliance_plan: Option<models::CompliancePlan>,
86    /// This is for metadata you want to store on the assistant.
87    #[serde(rename = "metadata", skip_serializing_if = "Option::is_none")]
88    pub metadata: Option<serde_json::Value>,
89    /// This is the plan for analysis of assistant's calls. Stored in `call.analysis`.
90    #[serde(rename = "analysisPlan", skip_serializing_if = "Option::is_none")]
91    pub analysis_plan: Option<models::AnalysisPlan>,
92    /// This is the plan for artifacts generated during assistant's calls. Stored in `call.artifact`.  Note: `recordingEnabled` is currently at the root level. It will be moved to `artifactPlan` in the future, but will remain backwards compatible.
93    #[serde(rename = "artifactPlan", skip_serializing_if = "Option::is_none")]
94    pub artifact_plan: Option<models::ArtifactPlan>,
95    /// This is the plan for static predefined messages that can be spoken by the assistant during the call, like `idleMessages`.  Note: `firstMessage`, `voicemailMessage`, and `endCallMessage` are currently at the root level. They will be moved to `messagePlan` in the future, but will remain backwards compatible.
96    #[serde(rename = "messagePlan", skip_serializing_if = "Option::is_none")]
97    pub message_plan: Option<models::MessagePlan>,
98    /// This is the plan for when the assistant should start talking.  You should configure this if you're running into these issues: - The assistant is too slow to start talking after the customer is done speaking. - The assistant is too fast to start talking after the customer is done speaking. - The assistant is so fast that it's actually interrupting the customer.
99    #[serde(rename = "startSpeakingPlan", skip_serializing_if = "Option::is_none")]
100    pub start_speaking_plan: Option<models::StartSpeakingPlan>,
101    /// This is the plan for when assistant should stop talking on customer interruption.  You should configure this if you're running into these issues: - The assistant is too slow to recognize customer's interruption. - The assistant is too fast to recognize customer's interruption. - The assistant is getting interrupted by phrases that are just acknowledgments. - The assistant is getting interrupted by background noises. - The assistant is not properly stopping -- it starts talking right after getting interrupted.
102    #[serde(rename = "stopSpeakingPlan", skip_serializing_if = "Option::is_none")]
103    pub stop_speaking_plan: Option<models::StopSpeakingPlan>,
104    /// This is the plan for real-time monitoring of the assistant's calls.  Usage: - To enable live listening of the assistant's calls, set `monitorPlan.listenEnabled` to `true`. - To enable live control of the assistant's calls, set `monitorPlan.controlEnabled` to `true`.  Note, `serverMessages`, `clientMessages`, `serverUrl` and `serverUrlSecret` are currently at the root level but will be moved to `monitorPlan` in the future. Will remain backwards compatible
105    #[serde(rename = "monitorPlan", skip_serializing_if = "Option::is_none")]
106    pub monitor_plan: Option<models::MonitorPlan>,
107    /// These are the credentials that will be used for the assistant calls. By default, all the credentials are available for use in the call but you can provide a subset using this.
108    #[serde(rename = "credentialIds", skip_serializing_if = "Option::is_none")]
109    pub credential_ids: Option<Vec<String>>,
110    /// This is where Vapi will send webhooks. You can find all webhooks available along with their shape in ServerMessage schema.  The order of precedence is:  1. assistant.server.url 2. phoneNumber.serverUrl 3. org.serverUrl
111    #[serde(rename = "server", skip_serializing_if = "Option::is_none")]
112    pub server: Option<models::Server>,
113    /// This is a set of actions that will be performed on certain events.
114    #[serde(rename = "hooks", skip_serializing_if = "Option::is_none")]
115    pub hooks: Option<Vec<models::AssistantHooks>>,
116    #[serde(rename = "keypadInputPlan", skip_serializing_if = "Option::is_none")]
117    pub keypad_input_plan: Option<models::KeypadInputPlan>,
118    /// This is the unique identifier for the assistant.
119    #[serde(rename = "id")]
120    pub id: String,
121    /// This is the unique identifier for the org that this assistant belongs to.
122    #[serde(rename = "orgId")]
123    pub org_id: String,
124    /// This is the ISO 8601 date-time string of when the assistant was created.
125    #[serde(rename = "createdAt")]
126    pub created_at: String,
127    /// This is the ISO 8601 date-time string of when the assistant was last updated.
128    #[serde(rename = "updatedAt")]
129    pub updated_at: String,
130}
131
132impl Assistant {
133    pub fn new(id: String, org_id: String, created_at: String, updated_at: String) -> Assistant {
134        Assistant {
135            transcriber: None,
136            model: None,
137            voice: None,
138            first_message: None,
139            first_message_mode: None,
140            voicemail_detection: None,
141            client_messages: None,
142            server_messages: None,
143            silence_timeout_seconds: None,
144            max_duration_seconds: None,
145            background_sound: None,
146            background_denoising_enabled: None,
147            model_output_in_messages_enabled: None,
148            transport_configurations: None,
149            credentials: None,
150            name: None,
151            voicemail_message: None,
152            end_call_message: None,
153            end_call_phrases: None,
154            compliance_plan: None,
155            metadata: None,
156            analysis_plan: None,
157            artifact_plan: None,
158            message_plan: None,
159            start_speaking_plan: None,
160            stop_speaking_plan: None,
161            monitor_plan: None,
162            credential_ids: None,
163            server: None,
164            hooks: None,
165            keypad_input_plan: None,
166            id,
167            org_id,
168            created_at,
169            updated_at,
170        }
171    }
172}
173/// This is the mode for the first message. Default is 'assistant-speaks-first'.  Use: - 'assistant-speaks-first' to have the assistant speak first. - 'assistant-waits-for-user' to have the assistant wait for the user to speak first. - 'assistant-speaks-first-with-model-generated-message' to have the assistant speak first with a message generated by the model based on the conversation state. (`assistant.model.messages` at call start, `call.messages` at squad transfer points).  @default 'assistant-speaks-first'
174#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
175pub enum FirstMessageMode {
176    #[serde(rename = "assistant-speaks-first")]
177    AssistantSpeaksFirst,
178    #[serde(rename = "assistant-speaks-first-with-model-generated-message")]
179    AssistantSpeaksFirstWithModelGeneratedMessage,
180    #[serde(rename = "assistant-waits-for-user")]
181    AssistantWaitsForUser,
182}
183
184impl Default for FirstMessageMode {
185    fn default() -> FirstMessageMode {
186        Self::AssistantSpeaksFirst
187    }
188}
189/// These are the messages that will be sent to your Client SDKs. Default is conversation-update,function-call,hang,model-output,speech-update,status-update,transfer-update,transcript,tool-calls,user-interrupted,voice-input. You can check the shape of the messages in ClientMessage schema.
190#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
191pub enum ClientMessages {
192    #[serde(rename = "conversation-update")]
193    ConversationUpdate,
194    #[serde(rename = "function-call")]
195    FunctionCall,
196    #[serde(rename = "function-call-result")]
197    FunctionCallResult,
198    #[serde(rename = "hang")]
199    Hang,
200    #[serde(rename = "language-changed")]
201    LanguageChanged,
202    #[serde(rename = "metadata")]
203    Metadata,
204    #[serde(rename = "model-output")]
205    ModelOutput,
206    #[serde(rename = "speech-update")]
207    SpeechUpdate,
208    #[serde(rename = "status-update")]
209    StatusUpdate,
210    #[serde(rename = "transcript")]
211    Transcript,
212    #[serde(rename = "tool-calls")]
213    ToolCalls,
214    #[serde(rename = "tool-calls-result")]
215    ToolCallsResult,
216    #[serde(rename = "transfer-update")]
217    TransferUpdate,
218    #[serde(rename = "user-interrupted")]
219    UserInterrupted,
220    #[serde(rename = "voice-input")]
221    VoiceInput,
222}
223
224impl Default for ClientMessages {
225    fn default() -> ClientMessages {
226        Self::ConversationUpdate
227    }
228}
229/// These are the messages that will be sent to your Server URL. Default is conversation-update,end-of-call-report,function-call,hang,speech-update,status-update,tool-calls,transfer-destination-request,user-interrupted. You can check the shape of the messages in ServerMessage schema.
230#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
231pub enum ServerMessages {
232    #[serde(rename = "conversation-update")]
233    ConversationUpdate,
234    #[serde(rename = "end-of-call-report")]
235    EndOfCallReport,
236    #[serde(rename = "function-call")]
237    FunctionCall,
238    #[serde(rename = "hang")]
239    Hang,
240    #[serde(rename = "language-changed")]
241    LanguageChanged,
242    #[serde(rename = "language-change-detected")]
243    LanguageChangeDetected,
244    #[serde(rename = "model-output")]
245    ModelOutput,
246    #[serde(rename = "phone-call-control")]
247    PhoneCallControl,
248    #[serde(rename = "speech-update")]
249    SpeechUpdate,
250    #[serde(rename = "status-update")]
251    StatusUpdate,
252    #[serde(rename = "transcript")]
253    Transcript,
254    #[serde(rename = "transcript[transcriptType=\"final\"]")]
255    TranscriptLeftSquareBracketTranscriptTypeEqualDoubleQuoteFinalDoubleQuoteRightSquareBracket,
256    #[serde(rename = "tool-calls")]
257    ToolCalls,
258    #[serde(rename = "transfer-destination-request")]
259    TransferDestinationRequest,
260    #[serde(rename = "transfer-update")]
261    TransferUpdate,
262    #[serde(rename = "user-interrupted")]
263    UserInterrupted,
264    #[serde(rename = "voice-input")]
265    VoiceInput,
266}
267
268impl Default for ServerMessages {
269    fn default() -> ServerMessages {
270        Self::ConversationUpdate
271    }
272}
273/// This is the background sound in the call. Default for phone calls is 'office' and default for web calls is 'off'.
274#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
275pub enum BackgroundSound {
276    #[serde(rename = "off")]
277    Off,
278    #[serde(rename = "office")]
279    Office,
280}
281
282impl Default for BackgroundSound {
283    fn default() -> BackgroundSound {
284        Self::Off
285    }
286}