update_assistant
Modify an existing Vapi assistant's configuration, including its name, instructions, AI model, voice settings, and tools to adapt its behavior.
Instructions
Updates an existing Vapi assistant
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assistantId | Yes | ID of the assistant to update | |
| name | No | New name for the assistant | |
| instructions | No | New instructions for the assistant | |
| llm | No | New LLM configuration | |
| toolIds | No | New IDs of tools to use with this assistant | |
| transcriber | No | New transcription configuration | |
| voice | No | New voice configuration | |
| firstMessage | No | First message to say to the user | |
| firstMessageMode | No | This determines who speaks first, either assistant or user |
Implementation Reference
- src/tools/assistant.ts:67-90 (handler)Core execution logic for the update_assistant tool: validates assistant existence, transforms input parameters, performs the Vapi API update, handles errors, and returns transformed output.createToolHandler(async (data) => { const assistantId = data.assistantId; try { // First check if the assistant exists const existingAssistant = await vapiClient.assistants.get(assistantId); if (!existingAssistant) { throw new Error(`Assistant with ID ${assistantId} not found`); } // Transform the update data const updateAssistantDto = transformUpdateAssistantInput(data); // Update the assistant const updatedAssistant = await vapiClient.assistants.update( assistantId, updateAssistantDto ); return transformAssistantOutput(updatedAssistant); } catch (error: any) { console.error(`Error updating assistant: ${error.message}`); throw error; } })
- src/schemas/index.ts:201-252 (schema)Zod schema defining the input parameters for the update_assistant tool, including assistantId (required) and optional fields for name, instructions, LLM, tools, transcriber, voice, firstMessage, and firstMessageMode.export const UpdateAssistantInputSchema = z.object({ assistantId: z.string().describe('ID of the assistant to update'), name: z.string().optional().describe('New name for the assistant'), instructions: z .string() .optional() .describe('New instructions for the assistant'), llm: z .union([ LLMSchema, z.string().transform((str) => { try { return JSON.parse(str); } catch (e) { throw new Error(`Invalid LLM JSON string: ${str}`); } }), ]) .optional() .describe('New LLM configuration'), toolIds: z .array(z.string()) .optional() .describe('New IDs of tools to use with this assistant'), transcriber: z .object({ provider: z.string().describe('Provider to use for transcription'), model: z.string().describe('Transcription model to use'), }) .optional() .describe('New transcription configuration'), voice: z .object({ provider: VoiceProviderSchema.describe('Provider to use for voice'), voiceId: z.string().describe('Voice ID to use'), model: z.string().optional().describe('Voice model to use'), }) .optional() .describe('New voice configuration'), firstMessage: z .string() .optional() .describe('First message to say to the user'), firstMessageMode: z .enum([ 'assistant-speaks-first', 'assistant-waits-for-user', 'assistant-speaks-first-with-model-generated-message', ]) .optional() .describe('This determines who speaks first, either assistant or user'), });
- src/tools/assistant.ts:63-91 (registration)Registers the 'update_assistant' MCP tool with server.tool, providing name, description, input schema shape, and wrapped handler function within registerAssistantTools.server.tool( 'update_assistant', 'Updates an existing Vapi assistant', UpdateAssistantInputSchema.shape, createToolHandler(async (data) => { const assistantId = data.assistantId; try { // First check if the assistant exists const existingAssistant = await vapiClient.assistants.get(assistantId); if (!existingAssistant) { throw new Error(`Assistant with ID ${assistantId} not found`); } // Transform the update data const updateAssistantDto = transformUpdateAssistantInput(data); // Update the assistant const updatedAssistant = await vapiClient.assistants.update( assistantId, updateAssistantDto ); return transformAssistantOutput(updatedAssistant); } catch (error: any) { console.error(`Error updating assistant: ${error.message}`); throw error; } }) );
- src/tools/assistant.ts:64-131 (helper)Helper function to transform the tool's input parameters (z.infer<typeof UpdateAssistantInputSchema>) into the Vapi SDK's UpdateAssistantDto format for the API update call.'update_assistant', 'Updates an existing Vapi assistant', UpdateAssistantInputSchema.shape, createToolHandler(async (data) => { const assistantId = data.assistantId; try { // First check if the assistant exists const existingAssistant = await vapiClient.assistants.get(assistantId); if (!existingAssistant) { throw new Error(`Assistant with ID ${assistantId} not found`); } // Transform the update data const updateAssistantDto = transformUpdateAssistantInput(data); // Update the assistant const updatedAssistant = await vapiClient.assistants.update( assistantId, updateAssistantDto ); return transformAssistantOutput(updatedAssistant); } catch (error: any) { console.error(`Error updating assistant: ${error.message}`); throw error; } }) ); };