### startScreenSharing Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of starting screen sharing with display media options. ```typescript vapi.startScreenSharing({ video: { mandatory: { chromeMediaSource: 'screen' } } }); ``` -------------------------------- ### Start Method Examples Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Illustrates various ways to use the start() method, including with assistant IDs, assistant objects, overrides, and custom room settings. ```typescript // Start with assistant ID const call = await vapi.start('assistant-id-123'); // Start with assistant object const call = await vapi.start({ model: { provider: 'openai', model: 'gpt-3.5-turbo', messages: [ { role: 'system', content: 'You are a helpful assistant.' } ] }, voice: { provider: '11labs', voiceId: 'burt' } }); // Start with overrides to set variables const call = await vapi.start( 'assistant-id-123', { variableValues: { name: 'John', age: '30' }, recordingEnabled: false } ); // Start with custom room settings const call = await vapi.start( 'assistant-id-123', undefined, undefined, undefined, undefined, { roomDeleteOnUserLeaveEnabled: false } ); ``` -------------------------------- ### startAudioOff Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Whether to start with audio/microphone disabled. ```typescript const vapi = new Vapi('api-token', undefined, undefined, { startAudioOff: true // Start muted }); ``` -------------------------------- ### Example Usage of start() and reconnect() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Demonstrates how to start a new call and then reconnect to an existing call using the Vapi SDK. ```typescript // Store the call object during initial start let currentCall: Call | null = null; currentCall = await vapi.start('assistant-id', undefined, undefined, undefined, undefined, { roomDeleteOnUserLeaveEnabled: false }); // Later, reconnect to the same call if (currentCall) { await vapi.reconnect(currentCall as any); } ``` -------------------------------- ### Complete Type Usage Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md A comprehensive example showcasing the creation of an assistant, starting a call with overrides, and sending a typed message using the Vapi client SDK. ```typescript import Vapi, { client, CreateAssistantDTO, Assistant, CreateCallDTO, Call, AssistantOverrides, VapiClientToServerMessage } from '@vapi-ai/web'; // Create assistant type const assistantConfig: CreateAssistantDTO = { name: 'Support Bot', model: { provider: 'openai', model: 'gpt-4', messages: [] }, voice: { provider: '11labs', voiceId: 'adam' } }; // Create assistant const assistant: Assistant = await client.assistant.assistantControllerCreate( assistantConfig ); // Start call with overrides const overrides: AssistantOverrides = { variableValues: { name: 'John' } }; const vapi = new Vapi('api-key'); const call = await vapi.start(assistant.id, overrides); // Send typed message const msg: VapiClientToServerMessage = { type: 'say', message: 'Hello!' }; vapi.send(msg); ``` -------------------------------- ### Start a new call with assistant configuration Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md You can start a new call by calling the `start` method and passing an `assistant` object or `assistantId`. ```javascript vapi.start({ model: { provider: "openai", model: "gpt-3.5-turbo", messages: [ { role: "system", content: "You are an assistant.", }, ], }, voice: { provider: "11labs", voiceId: "burt", }, ... }); ``` -------------------------------- ### Example GET /v2/call/export Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/endpoints.md Example of how to export calls with specified format, async option, and limit. ```http GET /v2/call/export?format=csv&async=false&limit=1000 HTTP/1.1 Authorization: Bearer api_token ``` -------------------------------- ### Installation Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md You can install the package via npm. ```bash npm install @vapi-ai/web ``` -------------------------------- ### Pattern 1: Full Setup Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Import both the Vapi class and the client instance for a full setup. ```typescript import Vapi, { client } from '@vapi-ai/web'; const vapi = new Vapi('api-key'); const assistants = await client.assistant.assistantControllerFindAll(); ``` -------------------------------- ### Start a new call with assistant ID Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md You can start a new call by calling the `start` method and passing an `assistant` object or `assistantId`. ```javascript vapi.start('your-assistant-id'); ``` -------------------------------- ### List Assistants Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/endpoints.md Example query parameters for listing assistants. ```http GET /assistant?limit=50&createdAtGe=2024-01-01T00:00:00Z HTTP/1.1 Authorization: Bearer api_token ``` -------------------------------- ### Create Assistant Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/endpoints.md Example request body for creating a new assistant. ```typescript POST /assistant HTTP/1.1 Authorization: Bearer api_token Content-Type: application/json { "name": "Customer Support Bot", "firstMessage": "Hello, how can I help?", "model": { "provider": "openai", "model": "gpt-3.5-turbo", "messages": [ { "role": "system", "content": "You are a helpful assistant." } ] }, "voice": { "provider": "11labs", "voiceId": "burt" } } ``` -------------------------------- ### Recommended Practices: Do This Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Examples of recommended practices for configuring audio sources and permission prompts with Vapi. ```typescript // Use default audio const vapi = new Vapi('api-token', undefined, undefined, { audioSource: true }); // Use specific device await vapi.setInputDevicesAsync({ audioSource: { deviceId: deviceId } }); // Use microphone-required permission prompt const vapi = new Vapi('api-token', undefined, { alwaysIncludeMicInPermissionPrompt: true }); ``` -------------------------------- ### Authentication Setup Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Shows how to set the API token for authentication using the client SDK. ```typescript import { client } from '@vapi-ai/web'; // Set authentication client.setSecurityData('your-api-token'); // Now all requests include Authorization: Bearer ``` -------------------------------- ### runNetworkTestsStandalone Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of performing network connectivity tests. ```typescript const results = await Vapi.runNetworkTestsStandalone(); console.log('Network tests:', results); ``` -------------------------------- ### Event Examples Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Examples of how to listen to various Vapi events, including call lifecycle, progress tracking, messages, speech activity, errors, and network monitoring. ```typescript // Listen to call lifecycle vapi.on('call-start', () => { console.log('Call started!'); }); vapi.on('call-end', () => { console.log('Call ended'); }); // Track progress during initialization vapi.on('call-start-progress', (event) => { console.log(`${event.stage}: ${event.status}`, event.metadata); }); // Listen for assistant messages vapi.on('message', (message) => { console.log('Assistant said:', message); }); // Track speech activity vapi.on('speech-start', () => { console.log('User is speaking'); }); vapi.on('speech-end', () => { console.log('User stopped speaking'); }); vapi.on('volume-level', (volume) => { console.log(`Volume: ${Math.round(volume * 100)}%`); }); // Error handling vapi.on('error', (error) => { console.error('Error:', error); }); vapi.on('camera-error', (error) => { console.error('Camera error:', error); }); // Network monitoring vapi.on('network-quality-change', (event) => { console.log('Network quality:', event); }); ``` -------------------------------- ### increaseMicLevel Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of increasing the microphone level. ```typescript await vapi.increaseMicLevel(1.5); // Increase volume by 1.5x ``` -------------------------------- ### Constructor Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Demonstrates how to instantiate the Vapi class with and without custom configuration. ```typescript import Vapi from '@vapi-ai/web'; const vapi = new Vapi('your-public-api-key'); // With custom configuration const vapiCustom = new Vapi( 'your-public-api-key', 'https://api.vapi.ai', { alwaysIncludeMicInPermissionPrompt: true }, { audioSource: true, startAudioOff: false } ); ``` -------------------------------- ### Example Usage of setOutputDeviceAsync() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Shows how to set the audio output device using setOutputDeviceAsync(). ```typescript await vapi.setOutputDeviceAsync({ deviceId: 'speaker-device-id' }); ``` -------------------------------- ### Assistant Model Configuration Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Configures the language model for an assistant. ```typescript { provider: 'openai', model: 'gpt-4-turbo', messages: [ { role: 'system', content: 'You are a helpful support agent.' } ], temperature: 0.7, maxTokens: 1000 } ``` -------------------------------- ### Testing Changes Locally Source: https://github.com/vapiai/client-sdk-web/blob/main/RELEASE.md Commands to build, test, and run the example project locally, as well as clean build artifacts. ```bash npm run test:example npm run pack:local npm run dev:example npm run clean-builds ``` -------------------------------- ### Create Web Call Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/endpoints.md Example of creating a web call using a POST request. ```typescript POST /call/web HTTP/1.1 Authorization: Bearer api_token Content-Type: application/json { "assistantId": "assistant-123" } ``` -------------------------------- ### Stop Method Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md A simple example demonstrating how to stop the current call. ```typescript await vapi.stop(); ``` -------------------------------- ### audioSource Example - Use default microphone Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Specifies the audio input device. `true`: Use default microphone ```typescript const vapi = new Vapi('api-token', undefined, undefined, { audioSource: true }); ``` -------------------------------- ### audioSource Example - Use specific device Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Specifies the audio input device. `string`: Device ID from `enumerateDevices()` ```typescript // Use specific device const devices = await navigator.mediaDevices.enumerateDevices(); const micDevice = devices.find(d => d.kind === 'audioinput'); const vapi = new Vapi('api-token', undefined, undefined, { audioSource: { deviceId: micDevice.deviceId } }); ``` -------------------------------- ### Create Call Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/endpoints.md Example request body for creating a new call. ```typescript POST /call HTTP/1.1 Authorization: Bearer api_token Content-Type: application/json { "assistantId": "assistant-123", "customerNumber": "+1234567890", "phoneNumberId": "phone-456" } ``` -------------------------------- ### Example Usage of setInputDevicesAsync() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Demonstrates how to change the audio input device using setInputDevicesAsync(). ```typescript // Change to a specific audio device const devices = await navigator.mediaDevices.enumerateDevices(); const audioDevices = devices.filter(d => d.kind === 'audioinput'); if (audioDevices.length > 0) { await vapi.setInputDevicesAsync({ audioSource: { deviceId: audioDevices[0].deviceId } }); } ``` -------------------------------- ### safeSetLocalAudio Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Demonstrates the usage of safeSetLocalAudio for enabling and disabling the microphone. ```typescript import { safeSetLocalAudio } from '@vapi-ai/web'; const dailyCall = vapi.getDailyCallObject(); // Enable microphone safeSetLocalAudio(dailyCall, true); // Disable microphone (mute) safeSetLocalAudio(dailyCall, false); // Handle null safely try { safeSetLocalAudio(null, true); } catch (error) { console.error('No active call'); } ``` -------------------------------- ### Example Usage of safeSetInputDevicesAsync Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Demonstrates how to use `safeSetInputDevicesAsync` to manage audio input devices, including switching to a specific device and handling unsafe `audioSource: false` configurations. ```typescript import { safeSetInputDevicesAsync } from '@vapi-ai/web'; const dailyCall = vapi.getDailyCallObject(); // Get available audio devices const devices = await navigator.mediaDevices.enumerateDevices(); const audioDevices = devices.filter(d => d.kind === 'audioinput'); // Switch to specific device await safeSetInputDevicesAsync(dailyCall, { audioSource: { deviceId: audioDevices[0].deviceId } }); // Start with audio enabled (safe) await safeSetInputDevicesAsync(dailyCall, { audioSource: true }); // Try to disable audio (gets converted to safe default) await safeSetInputDevicesAsync(dailyCall, { audioSource: false // Warning logged, property removed }); // Console: "[Vapi] setInputDevicesAsync with audioSource:false detected. // This can cause Chrome 140+ issues. Using default device instead." ``` -------------------------------- ### audioSource Example - Use custom audio track Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Specifies the audio input device. `MediaStreamTrack`: Custom audio track ```typescript // Use custom audio track const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); const track = stream.getAudioTracks()[0]; const vapi = new Vapi('api-token', undefined, undefined, { audioSource: track }); ``` -------------------------------- ### Client Setup Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Initializes the Vapi API client with your API token and optionally sets the base URL. ```typescript import { client } from '@vapi-ai/web'; // Set the base URL (defaults to https://api.vapi.ai) client.baseUrl = 'https://api.vapi.ai'; // Set your API token for authentication client.setSecurityData('your-api-token'); ``` -------------------------------- ### createSafeDailyConfig Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Demonstrates the usage of createSafeDailyConfig with different inputs. ```typescript import { createSafeDailyConfig } from '@vapi-ai/web'; // Safe configuration const config1 = createSafeDailyConfig({ alwaysIncludeMicInPermissionPrompt: true, avoidEval: true }); // Returns: { alwaysIncludeMicInPermissionPrompt: true, avoidEval: true } // Unsafe configuration (false value) — auto-corrected const config2 = createSafeDailyConfig({ alwaysIncludeMicInPermissionPrompt: false }); // Logs warning and returns: { } // Console: "[Vapi] alwaysIncludeMicInPermissionPrompt:false detected. // This can cause Chrome 140+ issues. Removing the property." // No config const config3 = createSafeDailyConfig(); // Returns: { } ``` -------------------------------- ### Variable Substitution Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Demonstrates how to use `variableValues` to replace placeholders in assistant messages during a call. ```typescript const call = await vapi.start( 'assistant-id', { variableValues: { 'customer_name': 'John Doe', 'order_id': 'ORD-12345', 'account_balance': '$500.00' } } ); ``` -------------------------------- ### on Event Method Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of subscribing to a Vapi event. ```typescript on(event: E, listener: VapiEventListeners[E]): this ``` -------------------------------- ### stopScreenSharing Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of stopping the active screen share. ```typescript vapi.stopScreenSharing(); ``` -------------------------------- ### getDailyCallObject Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of retrieving the Daily.co call object. ```typescript const dailyCall = vapi.getDailyCallObject(); if (dailyCall) { // Use Daily.co API directly const participants = dailyCall.participants(); } ``` -------------------------------- ### Example Usage of say() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Demonstrates how to use the say() method to speak a message and optionally end the call. ```typescript vapi.say("Thank you for calling. Goodbye!", true); ``` -------------------------------- ### Basic Usage Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Initialize the Vapi SDK, listen to events, start a call, control it, and stop it. ```typescript import Vapi from '@vapi-ai/web'; // Initialize const vapi = new Vapi('your-public-api-key'); // Listen to events vapi.on('call-start', () => console.log('Call started')); vapi.on('speech-start', () => console.log('User speaking')); vapi.on('message', (msg) => console.log('Message:', msg)); vapi.on('error', (err) => console.error('Error:', err)); // Start a call const call = await vapi.start('assistant-id-or-object'); // Control the call vapi.setMuted(true); // Mute user vapi.say('Hello there!'); // Speak to user vapi.send({ // Send control message type: 'add-message', message: { role: 'system', content: 'User clicked button' } }); // Stop the call await vapi.stop(); ``` -------------------------------- ### Error Handling Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Demonstrates how to handle API errors using a try-catch block. ```typescript try { const assistant = await client.assistant.assistantControllerCreate({ model: { provider: 'openai', model: 'gpt-3.5-turbo' }, voice: { provider: '11labs', voiceId: 'burt' } }); } catch (error: any) { console.error('API Error:', error.response?.status, error.message); } ``` -------------------------------- ### Retry Logic for Starting a Call Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md This pattern demonstrates how to implement retry logic with exponential backoff when starting a call, to handle transient errors. ```typescript async function startWithRetry( assistantId: string, maxAttempts = 3 ) { let lastError; for (let i = 0; i < maxAttempts; i++) { try { return await vapi.start(assistantId); } catch (error) { lastError = error; // Exponential backoff await new Promise(resolve => setTimeout(resolve, Math.pow(2, i) * 1000) ); } } throw lastError; } // Usage try { const call = await startWithRetry('assistant-id'); } catch (error) { console.error('Failed after retries:', error); } ``` -------------------------------- ### LLM Error Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md An example structure for an LLM error, indicating a failure with the language model service. ```typescript { endedReason: 'pipeline-error-openai-401-unauthorized' // or other LLM errors } ``` -------------------------------- ### Example Usage of createSafeDailyFactoryOptions Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Illustrates how `createSafeDailyFactoryOptions` handles safe and unsafe audio source configurations, including auto-correction for `audioSource: false`. ```typescript import { createSafeDailyFactoryOptions } from '@vapi-ai/web'; // Safe options (true or device spec) const opts1 = createSafeDailyFactoryOptions({ audioSource: true, startAudioOff: false }); // Returns: { audioSource: true, startAudioOff: false } // Unsafe options (false value) — auto-corrected const opts2 = createSafeDailyFactoryOptions({ audioSource: false, startAudioOff: true }); // Logs warning and returns: { audioSource: true, startAudioOff: true } // Console: "[Vapi] audioSource:false detected in factory options. // This can cause Chrome 140+ issues. Defaulting to true." // Device ID (safe) const opts3 = createSafeDailyFactoryOptions({ audioSource: { deviceId: 'device-123' } }); // Returns: { audioSource: { deviceId: 'device-123' } } // No options const opts4 = createSafeDailyFactoryOptions(); // Returns: { } ``` -------------------------------- ### StartCallOptions Type Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/types.md Options for starting a call. ```typescript type StartCallOptions = { roomDeleteOnUserLeaveEnabled?: boolean; } ``` -------------------------------- ### Example Usage of send() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Illustrates how to use the send() method with different message types: adding a system message, controlling the assistant, using text-to-speech, and ending the call. ```typescript // Add a system message vapi.send({ type: 'add-message', message: { role: 'system', content: 'The user just clicked a button.' }, triggerResponseEnabled: true }); // Control the assistant vapi.send({ type: 'control', control: 'mute-assistant' }); // Use text-to-speech vapi.send({ type: 'say', message: 'Hello, how can I help you today?', endCallAfterSpoken: false, interruptionsEnabled: true }); // End the call vapi.send({ type: 'end-call' }); ``` -------------------------------- ### Recommended Practices: Don't Do This Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Examples of unsafe configurations to avoid when using Vapi, highlighting automatic corrections applied by the SDK. ```typescript // ❌ Disable audio via false (unsafe) const vapi = new Vapi('api-token', undefined, undefined, { audioSource: false // Converted to true automatically }); // ❌ Set permission prompt to false (unsafe) const vapi = new Vapi('api-token', undefined, { alwaysIncludeMicInPermissionPrompt: false // Removed automatically }); // ❌ Direct Daily.co call with unsafe values dailyCall.setInputDevicesAsync({ audioSource: false // Can cause issues - use safeSetInputDevicesAsync }); ``` -------------------------------- ### Import Organization Examples Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Illustrates different ways to import from the Vapi client SDK, including default imports, named exports, and type-only imports. ```typescript // Import default import Vapi from '@vapi-ai/web'; // Import named exports import { client, // Types Assistant, Call, // Utilities createSafeDailyConfig } from '@vapi-ai/web'; // Import types only (not at runtime) import type { CreateAssistantDTO, AssistantOverrides } from '@vapi-ai/web'; ``` -------------------------------- ### Recording Override Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Shows how to disable call recording for a specific call using `recordingEnabled` in the overrides. ```typescript const call = await vapi.start( 'assistant-id', { recordingEnabled: false // Disable recording for this call } ); ``` -------------------------------- ### avoidEval Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Disables `eval()` in Daily.co runtime. Recommended for security. ```typescript const vapi = new Vapi( 'api-token', undefined, { avoidEval: true } ); ``` -------------------------------- ### getCampaign() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Gets a specific campaign by ID. ```typescript client.campaign.campaignControllerFindOne(id: string): Promise ``` -------------------------------- ### Default Configuration Summary Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Provides a summary of the default configuration settings for the Vapi client SDK, including API base URL, Daily.co call configuration, and start call options. ```typescript { apiBaseUrl: 'https://api.vapi.ai', dailyCallConfig: {}, dailyCallObject: { audioSource: true, startAudioOff: false }, startCallOptions: { roomDeleteOnUserLeaveEnabled: true } } ``` -------------------------------- ### Error Recovery Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Handles call start failures by logging the error, waiting for 2 seconds, and then retrying to start the call. ```typescript vapi.on('call-start-failed', async (event) => { console.error(`Failed at ${event.stage}: ${event.error}`); // Retry logic await new Promise(r => setTimeout(r, 2000)); await vapi.start('assistant-id'); }); ``` -------------------------------- ### Progress Tracking Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Logs call start progress events and handles failures by logging and reporting them. It also analyzes failed stages when a call start fails. ```typescript const progressLog: CallStartProgressEvent[] = []; vapi.on('call-start-progress', (event) => { progressLog.push(event); if (event.status === 'failed') { console.error(`Failed at stage: ${event.stage}`, event); // Report to analytics reportFailure(event); } }); vapi.on('call-start-failed', (event) => { // Analyze where it failed const failedStages = progressLog.filter(e => e.status === 'failed'); console.error('Failed stages:', failedStages); }); ``` -------------------------------- ### Call Start Progress Event Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Logs the progress of call initialization stages. ```typescript vapi.on('call-start-progress', (event: CallStartProgressEvent) => { console.log(`Stage: ${event.stage}, Status: ${event.status}`); }); ``` -------------------------------- ### Example Usage of end() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Shows how to call the end() method to terminate the current call. ```typescript vapi.end(); ``` -------------------------------- ### Index Signatures Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Illustrates the use of index signatures for flexible properties in types like SerializedError and AssistantOverrides. ```typescript interface SerializedError { message: string; name?: string; [key: string]: any; // Allows additional properties } interface AssistantOverrides { variableValues?: Record; // Map of any variables } ``` -------------------------------- ### once Event Method Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of subscribing to a Vapi event that fires only once. ```typescript once(event: E, listener: VapiEventListeners[E]): this ``` -------------------------------- ### Nullable/Optional Properties Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Shows how response types often include optional properties to reflect potential nullability from the database, such as 'id', 'status', 'duration', and 'recordingUrl'. ```typescript interface Call { id?: string; // Optional ID from server status?: string; // Optional status duration?: number; // Optional duration recordingUrl?: string; // May not have recording // ... many optional properties } ``` -------------------------------- ### Call Start Failed Event Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Logs an error message when call initialization fails. ```typescript vapi.on('call-start-failed', (event: CallStartFailedEvent) => { console.error(`Failed at stage: ${event.stage}, Error: ${event.error}`); }); ``` -------------------------------- ### alwaysIncludeMicInPermissionPrompt Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Ensures microphone permission is always requested, even if audio is disabled initially. ```typescript const vapi = new Vapi( 'api-token', undefined, { alwaysIncludeMicInPermissionPrompt: true } ); ``` -------------------------------- ### Call Start Success Event Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Logs a message when the call initialization completes successfully. ```typescript vapi.on('call-start-success', (event: CallStartSuccessEvent) => { console.log('Call started successfully in', event.totalDuration, 'ms'); }); ``` -------------------------------- ### Conditional Types Example Usage Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Shows how type inference works with the 'on' method for different event types. ```typescript vapi.on('speech-start', () => { // Correct: listener is () => void }); vapi.on('volume-level', (volume: number) => { // Correct: listener is (volume: number) => void }); vapi.on('message', (msg: any) => { // Correct: listener is (msg: any) => void }); ``` -------------------------------- ### Get Assistant Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Retrieves a specific assistant by its ID. ```typescript client.assistant.assistantControllerFindOne(id: string): Promise ``` -------------------------------- ### Accessing the Daily.co Call Object Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Demonstrates how to retrieve the Daily.co call object to directly interact with its API for advanced customization, such as getting participant information or updating input settings. ```typescript const dailyCall = vapi.getDailyCallObject(); if (dailyCall) { // Use Daily.co API directly const participants = dailyCall.participants(); dailycall.updateInputSettings({ audio: { enabled: true } }); } ``` -------------------------------- ### Example Usage of setMuted() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Demonstrates how to mute and unmute the user's microphone using the setMuted() method. ```typescript vapi.setMuted(true); // Mute the microphone vapi.setMuted(false); // Unmute the microphone ``` -------------------------------- ### Vapi Constructor with API Key and URL Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Demonstrates how to initialize the Vapi SDK with an API key and API URL, falling back to environment variables or defaults. ```typescript const vapi = new Vapi( process.env.VAPI_API_KEY || 'default-key', process.env.VAPI_API_URL || 'https://api.vapi.ai' ); ``` -------------------------------- ### Example Usage of isMuted() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Shows how to retrieve the microphone's mute state using the isMuted() method. ```typescript const muted = vapi.isMuted(); console.log('Microphone is muted:', muted); ``` -------------------------------- ### Start call with assistant overrides Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md You can override existing assistant parameters or set variables with the `assistant_overrides` parameter. Assume the first message is `Hey, {{name}} how are you?` and you want to set the value of `name` to `John`: ```javascript const assistantOverrides = { recordingEnabled: false, variableValues: { name: 'John', }, }; vapi.start( 'your-assistant-id', assistantOverrides, ); ``` -------------------------------- ### Live Control Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Listens for speech start and end events to manage a speaking indicator and demonstrates how to send control messages like 'mute-assistant' during a call. ```typescript vapi.on('speech-start', () => { // User is speaking showSpeakingIndicator(); }); vapi.on('speech-end', () => { // User stopped speaking hideSpeakingIndicator(); }); // Control assistant during call if (needsIntervention) { vapi.send({ type: 'control', control: 'mute-assistant' // Silence the assistant }); } ``` -------------------------------- ### Discriminated Unions Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Shows how discriminated unions provide type-safe handling of messages, with TypeScript inferring the correct structure based on the 'type' property. ```typescript import type { VapiClientToServerMessage } from '@vapi-ai/web'; const msg: VapiClientToServerMessage = { type: 'say', // TypeScript infers correct structure message: 'Hello', endCallAfterSpoken: true }; // Type narrowing works if (msg.type === 'add-message') { // msg.message exists here const m = msg.message; } ``` -------------------------------- ### Network Tests for Call Startup Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Shows how to run standalone network connectivity tests before initiating a Vapi call to ensure a stable connection. ```typescript const results = await Vapi.runNetworkTestsStandalone(); if (results.networkConnectivity.result === 'success') { // Safe to start call await vapi.start('assistant-id'); } else { console.warn('Network connectivity issue:', results); } ``` -------------------------------- ### Transcription Error Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md An example structure for a transcription error, indicating a failure in the speech-to-text process. ```typescript { endedReason: 'pipeline-error-deepgram-transcriber-failed' // or other transcriber errors } ``` -------------------------------- ### Main Entry Point Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Import and initialize the main Vapi class. ```typescript import Vapi from '@vapi-ai/web'; // Initialize const vapi = new Vapi('api-key'); ``` -------------------------------- ### Voice/TTS Error Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md An example structure for a voice or text-to-speech error, indicating a failure with the TTS provider. ```typescript { endedReason: 'pipeline-error-eleven-labs-voice-failed' // or other voice provider errors } ``` -------------------------------- ### getChat() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Gets a specific chat by ID. ```typescript client.chat.chatControllerGetChat(id: string): Promise ``` -------------------------------- ### getSquad() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Gets a specific squad by ID. ```typescript client.squad.squadControllerFindOne(id: string): Promise ``` -------------------------------- ### Create Vapi instance Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md Then, create a new instance of the Vapi class, passing your Public Key as a parameter to the constructor. ```javascript const vapi = new Vapi('your-public-key'); ``` -------------------------------- ### Get Call Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Retrieves a specific call by its ID. ```typescript client.call.callControllerFindOne(id: string): Promise ``` -------------------------------- ### removeListener Event Method Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of removing an event listener. ```typescript removeListener(event: E, listener: VapiEventListeners[E]): this ``` -------------------------------- ### createCampaign() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a new campaign. ```typescript client.campaign.campaignControllerCreate(data: CreateCampaignDTO): Promise ``` -------------------------------- ### removeAllListeners Event Method Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md Example of removing all listeners for a specific event or all events. ```typescript removeAllListeners(event?: VapiEventNames): this ``` -------------------------------- ### createWebChat() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a web-based chat. ```typescript client.chat.chatControllerCreateWebChat(data: CreateWebChatDTO): Promise ``` -------------------------------- ### First Message Configuration Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Configures the initial message the assistant speaks or waits for, with options for immediate speech or waiting for user input. ```typescript firstMessage?: string; firstMessageMode?: 'speak-first-message' | 'wait-for-speech'; ``` ```typescript { firstMessage: 'Hello! How can I help you today?', firstMessageMode: 'speak-first-message' } ``` -------------------------------- ### Constructor Signature Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md The Vapi class accepts configuration parameters to customize call behavior and audio handling. ```typescript constructor( apiToken: string, apiBaseUrl?: string, dailyCallConfig?: Pick, dailyCallObject?: Pick ) ``` -------------------------------- ### Configuration Types Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Illustrates different configuration types available for Daily.co and Vapi factory options, as well as call options and assistant overrides. ```typescript DailyAdvancedConfig ├── avoidEval ├── alwaysIncludeMicInPermissionPrompt └── ... (other Daily.co options) DailyFactoryOptions ├── audioSource ├── startAudioOff └── ... (other factory options) StartCallOptions └── roomDeleteOnUserLeaveEnabled AssistantOverrides ├── recordingEnabled ├── variableValues ├── modelOverrides └── voiceOverrides ``` -------------------------------- ### listCampaigns() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Lists all campaigns. ```typescript client.campaign.campaignControllerFindAll(query?: { id?: string; status?: 'scheduled' | 'in-progress' | 'ended'; page?: number; limit?: number; // ... more filters }): Promise ``` -------------------------------- ### Import Vapi class Source: https://github.com/vapiai/client-sdk-web/blob/main/README.md First, import the Vapi class from the package. ```javascript import Vapi from '@vapi-ai/web'; ``` -------------------------------- ### createOpenAiWebChat() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a web chat using OpenAI-compatible API. ```typescript client.chat.chatControllerCreateOpenAiWebChat(data: OpenAIWebChatRequest): Promise ``` -------------------------------- ### List Assistant Versions Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Lists all versions of a specific assistant, with options for pagination. ```typescript client.assistant.assistantControllerFindVersions(id: string, query?: { page?: number; limit?: number; pageState?: string; }): Promise ``` -------------------------------- ### API Client Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Import and use the pre-configured API client instance. ```typescript import { client } from '@vapi-ai/web'; // Use the API client directly await client.assistant.assistantControllerCreate({...}); ``` -------------------------------- ### listWorkflows() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Lists all workflows. ```typescript client.workflow.workflowControllerFindAll(): Promise ``` -------------------------------- ### Create Assistant Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a new assistant using the API client. ```typescript client.assistant.assistantControllerCreate(data: CreateAssistantDTO): Promise ``` -------------------------------- ### Listen for Audio/Permissions Errors Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md This snippet shows how to specifically listen for errors related to accessing cameras or microphones. ```typescript vapi.on('camera-error', (error) => { console.error('Camera/Audio Error:', error); }); ``` -------------------------------- ### Call Recording Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Starts a call with recording enabled and listens for the 'recording-stopped' event to log the recording URL. ```typescript const call = await vapi.start('assistant-id', { recordingEnabled: true }); vapi.on('recording-stopped', (event) => { console.log('Recording URL:', event.recordingUrl); }); ``` -------------------------------- ### Event Types Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Demonstrates strongly-typed event handling using the event emitter with VapiClientToServerMessage. ```typescript import type { VapiClientToServerMessage } from '@vapi-ai/web'; // Valid message types type ValidMessages = | AddMessageMessage | ControlMessages | SayMessage | EndCallMessage; ``` -------------------------------- ### Variable Substitution Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Starts a call with predefined variable values that can be used for substitution within the assistant's prompts. ```typescript const call = await vapi.start('assistant-id', { variableValues: { 'customer_name': 'Alice', 'account_id': 'ACC-123', 'balance': '$500' } }); // If assistant says "Hello {{customer_name}}", // it becomes "Hello Alice" ``` -------------------------------- ### Use Browser DevTools Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Demonstrates how to use browser console methods like `console.table` to inspect Vapi events for debugging. ```typescript // In browser console vapi.on('error', (e) => console.table(e)); vapi.on('call-start-progress', (e) => console.table(e)); ``` -------------------------------- ### Source Code Organization Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Directory structure of the client-sdk-web project. ```bash client-sdk-web/ ├── vapi.ts # Main Vapi class (1640 lines) ├── api.ts # Generated API client (46K+ lines) ├── client.ts # API client setup (19 lines) ├── daily-guards.ts # Safety utilities (82 lines) ├── __tests__/ # Test files ├── example/ # Example application ├── package.json # Dependencies └── tsconfig.json # TypeScript config ``` -------------------------------- ### Network Diagnostics Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/README.md Runs network tests before starting a call to check for connectivity issues and displays an error message if the network is poor. ```typescript // Before starting calls const results = await Vapi.runNetworkTestsStandalone(); if (results.networkConnectivity.result === 'error') { showErrorMessage('Poor network connection detected'); } else { await vapi.start('assistant-id'); } ``` -------------------------------- ### Chrome 140+ Compatibility Fixes Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Illustrates how the Vapi SDK automatically corrects known issues for Chrome 140+ regarding `audioSource` and `alwaysIncludeMicInPermissionPrompt` configurations. ```typescript // Auto-fixed: audioSource: false → audioSource: true const vapi = new Vapi( 'api-token', undefined, undefined, { audioSource: false } // Automatically corrected to true ); // Auto-fixed: alwaysIncludeMicInPermissionPrompt: false → removed const vapi = new Vapi( 'api-token', undefined, { alwaysIncludeMicInPermissionPrompt: false } // Automatically handled ); ``` -------------------------------- ### Create Web Call Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a web call. ```typescript client.call.callControllerCreateWebCall(data: CreateWebCallDTO): Promise ``` -------------------------------- ### createOpenAiChat() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a chat using OpenAI-compatible API. ```typescript client.chat.chatControllerCreateOpenAiChat(data: OpenAIResponsesRequest): Promise ``` -------------------------------- ### VideoPlan Configuration Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Configuration object for video-related settings, such as enabling video recording. ```typescript videoPlan?: { videoRecordingEnabled?: boolean; // ... video-specific settings } ``` -------------------------------- ### createWorkflow() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a new workflow. ```typescript client.workflow.workflowControllerCreate(data: CreateWorkflowDTO): Promise ``` -------------------------------- ### Handling Input Validation Errors Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Demonstrates how to catch and handle specific input validation errors, such as attempting to start a call when one is already in progress or when required parameters are missing. ```typescript try { await vapi.start(assistantId); } catch (error) { if (error.message.includes('already started')) { // Stop current call first await vapi.stop(); await vapi.start(assistantId); } else if (error.message.includes('must be provided')) { console.error('Valid assistant ID is required'); } } ``` -------------------------------- ### Integration with Vapi Class Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Illustrates how the Vapi class internally utilizes safety functions for Daily.co configuration and method calls. ```typescript // In vapi.ts constructor this.dailyCallConfig = createSafeDailyConfig(dailyCallConfig); this.dailyCallObject = createSafeDailyFactoryOptions(dailyCallObject); // During call setup safeSetLocalAudio(this.call, !mute); // For device changes await safeSetInputDevicesAsync(this.call, options); ``` -------------------------------- ### roomDeleteOnUserLeaveEnabled Example Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Controls room lifecycle when user leaves. `true`: Room is deleted when user leaves, preventing reconnection. `false`: Room persists, allowing reconnection via `reconnect()` ```typescript // Allow reconnection const call = await vapi.start( 'assistant-id', undefined, undefined, undefined, undefined, { roomDeleteOnUserLeaveEnabled: false } ); // Later, reconnect to the same call await vapi.reconnect(call); ``` -------------------------------- ### Partial Types for DTOs Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Demonstrates how to use the `Partial` utility type to allow partial updates for DTOs, specifically for updating an assistant. ```typescript type UpdateAssistantDTO = Partial; // Allows updating only some fields: await client.assistant.assistantControllerUpdate('id', { name: 'New Name' // Don't need to provide model, voice, etc. }); ``` -------------------------------- ### Enable Detailed Logging Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Sets up listeners for various Vapi events and logs them with timestamps to an array. It also provides a function to export the log as a JSON string. ```typescript // Track all events for debugging const eventLog: Array<{ event: string; data: any; time: Date }> = []; const events = [ 'call-start', 'call-end', 'speech-start', 'speech-end', 'message', 'error', 'camera-error', 'call-start-progress', 'call-start-failed', 'network-quality-change' ]; events.forEach(event => { vapi.on(event as any, (data: any) => { eventLog.push({ event, data, time: new Date() }); console.log(`[${event}]`, data); }); }); // Export log for analysis function exportLog() { return JSON.stringify(eventLog, null, 2); } ``` -------------------------------- ### Pattern 3: API-First Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/modules.md Use the API client directly without the high-level Vapi class. ```typescript import { client } from '@vapi-ai/web'; // Use API directly without the high-level Vapi class const call = await client.call.callControllerCreate({ assistantId: 'assistant-123', customerNumber: '+1234567890', phoneNumberId: 'phone-456' }); ``` -------------------------------- ### SafeDailyFactoryOptions Interface Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Type-safe wrapper for Daily.co factory options with audio source validation. ```typescript interface SafeDailyFactoryOptions extends Omit { audioSource?: string | boolean | MediaStreamTrack; } ``` -------------------------------- ### createChat() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a new chat conversation. ```typescript client.chat.chatControllerCreateChat(data: CreateChatDTO): Promise ``` -------------------------------- ### Manual Release (Emergency) Source: https://github.com/vapiai/client-sdk-web/blob/main/RELEASE.md Commands to manually publish a release if the automated process fails. ```bash npm ci npm run build npm test npm publish --access public ``` -------------------------------- ### List paginated assistants Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md List paginated assistants ```typescript client.v2.assistantControllerFindAllPaginated(query?: { page?: number; // Page number (min 1) sortOrder?: 'ASC' | 'DESC'; // Sort order limit?: number; // Items per page (0-1000) // ... date filters }): Promise ``` -------------------------------- ### setOutputDeviceAsync() Method Signature Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/vapi-class.md The signature for the setOutputDeviceAsync() method, used to asynchronously set the audio output device. ```typescript setOutputDeviceAsync(options: Parameters[0]): void ``` -------------------------------- ### List Assistants Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Lists all assistants with optional filtering and pagination. ```typescript client.assistant.assistantControllerFindAll(query?: { limit?: number; createdAtGt?: string; createdAtLt?: string; createdAtGe?: string; createdAtLe?: string; updatedAtGt?: string; updatedAtLt?: string; updatedAtGe?: string; updatedAtLe?: string; }): Promise ``` -------------------------------- ### createSquad() Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/api-client.md Creates a new squad (group of assistants). ```typescript client.squad.squadControllerCreate(data: CreateSquadDTO): Promise ``` -------------------------------- ### Permission Handling Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/errors.md Handles camera and microphone permission errors. It displays user-friendly messages when permissions are denied. ```typescript vapi.on('camera-error', (error) => { console.error('Camera permission error:', error); // Show user-friendly message showDialog('Camera access denied. Please check your browser permissions.'); }); vapi.on('error', (error) => { if (error?.error?.message?.includes('NotAllowedError')) { showDialog('Microphone permission is required to use this feature.'); } }); ``` -------------------------------- ### Function Tool Configuration Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/configuration.md Specifies the configuration for a function tool, including its name, description, parameters, and a server webhook URL for execution. ```typescript { type: 'function', function: { name: 'get_weather', description: 'Get current weather', parameters: { type: 'object', properties: { location: { type: 'string', description: 'City name' } }, required: ['location'] } }, server: { url: 'https://your-api.com/webhook', secret: 'webhook-secret' } } ``` -------------------------------- ### safeSetInputDevicesAsync Function Signature Source: https://github.com/vapiai/client-sdk-web/blob/main/_autodocs/api-reference/daily-guards.md Safely sets input devices (microphone/audio source) with validation to prevent Chrome 140+ issues. ```typescript async function safeSetInputDevicesAsync( call: DailyCall | null, options: Parameters[0] ): Promise ```