create_call
Initiate outbound calls using AI assistants, schedule calls for specific times, and customize assistant behavior with dynamic variables.
Instructions
Creates a outbound call
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assistantId | No | ID of the assistant to use for the call | |
| phoneNumberId | No | ID of the phone number to use for the call | |
| customer | No | Customer information | |
| scheduledAt | No | ISO datetime string for when the call should be scheduled (e.g. "2025-03-25T22:39:27.771Z") | |
| assistantOverrides | No | Overrides for the assistant configuration |
Implementation Reference
- src/tools/call.ts:25-34 (registration)Registers the 'create_call' MCP tool on the server, specifying name, description, input schema (CallInputSchema.shape), and the handler function wrapped by createToolHandler.server.tool( 'create_call', 'Creates a outbound call', CallInputSchema.shape, createToolHandler(async (data) => { const createCallDto = transformCallInput(data); const call = await vapiClient.calls.create(createCallDto); return transformCallOutput(call as unknown as Vapi.Call); }) );
- src/tools/call.ts:29-33 (handler)The core execution logic for the 'create_call' tool: transforms input data using transformCallInput, creates the call using vapiClient.calls.create, and transforms the output using transformCallOutput.createToolHandler(async (data) => { const createCallDto = transformCallInput(data); const call = await vapiClient.calls.create(createCallDto); return transformCallOutput(call as unknown as Vapi.Call); })
- src/schemas/index.ts:256-288 (schema)Zod schema defining the input parameters for the 'create_call' tool, including optional fields for assistantId, phoneNumberId, customer number, scheduledAt, and assistantOverrides.export const CallInputSchema = z.object({ assistantId: z .string() .optional() .describe('ID of the assistant to use for the call'), phoneNumberId: z .string() .optional() .describe('ID of the phone number to use for the call'), customer: z .object({ number: z.string().describe('Customer phone number'), }) .optional() .describe('Customer information'), scheduledAt: z .string() .optional() .describe( 'ISO datetime string for when the call should be scheduled (e.g. "2025-03-25T22:39:27.771Z")' ), assistantOverrides: z .object({ variableValues: z .record(z.string(), z.any()) .optional() .describe( 'Key-value pairs for dynamic variables to use in the assistant\'s prompts (e.g. {"name": "Joe", "age": "24"})' ), }) .optional() .describe('Overrides for the assistant configuration'), });
- src/transformers/index.ts:183-209 (helper)Helper function that transforms the tool input (z.infer<CallInputSchema>) into Vapi.CreateCallDto format for the Vapi API call.export function transformCallInput( input: z.infer<typeof CallInputSchema> ): Vapi.CreateCallDto { return { ...(input.assistantId ? { assistantId: input.assistantId } : {}), ...(input.phoneNumberId ? { phoneNumberId: input.phoneNumberId } : {}), ...(input.customer ? { customer: { number: input.customer.number, }, } : {}), ...(input.scheduledAt ? { schedulePlan: { earliestAt: input.scheduledAt, }, } : {}), ...(input.assistantOverrides ? { assistantOverrides: input.assistantOverrides, } : {}), }; }
- src/transformers/index.ts:211-229 (helper)Helper function that transforms the Vapi.Call response into the output format matching CallOutputSchema.export function transformCallOutput( call: Vapi.Call ): z.infer<typeof CallOutputSchema> { return { id: call.id, createdAt: call.createdAt, updatedAt: call.updatedAt, status: call.status || '', endedReason: call.endedReason, assistantId: call.assistantId, phoneNumberId: call.phoneNumberId, customer: call.customer ? { number: call.customer.number || '', } : undefined, scheduledAt: call.schedulePlan?.earliestAt, }; }