Migrate a Voice Agent from Vapi to Micdrop
A Vapi assistant is a JSON configuration that runs on Vapi’s platform, which calls your server URL for tools and events. With Micdrop, the assistant is TypeScript code on your own Node.js server: the same server runs the call, executes the tools and receives the end of call report. Your phone numbers stay at your telephony provider, which streams each call to that server, and you pay each AI provider directly with your own keys.
This page maps each Vapi concept to its place in a Micdrop project. Field names come from the Vapi documentation.
Start from the phone template
The phone template is a working agent on Twilio, Telnyx, Vonage or Plivo, with a first message, the end call tool, transfers, recording and an end of call report already wired:
npm create micdrop@latest my-agent -- --template phone --telephony twilioThe rest of this page points to the files of that project. Templates describes it, and the AI providers it can start with.
Concepts side by side
| Vapi | Micdrop |
|---|---|
| Assistant | The options of MicdropServer, in src/server.ts |
model.messages, the system message | systemPrompt of the agent |
model.provider and model.model | The agent class and its model, in src/ai.ts |
transcriber | stt, a speech to text provider |
voice | tts, a text to speech provider |
| A speech to speech model | realtime, a realtime model in place of the three |
firstMessage | firstMessage |
Function tools and the tool-calls event | Tools with an execute function |
endCall tool | endCallTool() |
transferCall tool | transferCallTool() |
dtmf events from the keypad | dtmfInput() |
end-of-call-report | The End event of MicdropServer |
artifactPlan.recordingEnabled | MicdropRecorder |
Dynamic variables, {{name}} | Call parameters, read with waitForParams |
| Phone numbers | The webhook of your number, at your telephony provider |
@vapi-ai/web | @micdrop/web, and @micdrop/react-native on a phone |
Assistant
The model, the transcriber and the voice of an assistant become three
providers, built in src/ai.ts. The system message of model.messages becomes
systemPrompt:
new MicdropServer(transport, { turns: { vad: 'silero' }, firstMessage: 'Hello, thanks for calling. How can I help you?', stt: new GladiaSTT({ apiKey: process.env.GLADIA_API_KEY! }), agent: new OpenaiAgent({ apiKey: process.env.OPENAI_API_KEY!, model: 'gpt-5.2', systemPrompt: 'You answer the phone for a small company.', tools: [endCallTool()], }), tts: new ElevenLabsTTS({ apiKey: process.env.ELEVENLABS_API_KEY!, voiceId: process.env.ELEVENLABS_VOICE_ID!, }),})turns: { vad: 'silero' } has the server find the turns of the caller, since a
phone line streams its audio continuously. AI providers lists
every provider, and a fallback switches to another one
when the first fails.
First message
firstMessage takes the sentence the assistant says as the call connects,
like firstMessageMode: "assistant-speaks-first". The other modes map to:
firstMessageMode | Micdrop |
|---|---|
assistant-speaks-first | firstMessage: 'Hello…' |
assistant-speaks-first-with-model-generated-message | firstMessage: { generate: true } |
assistant-waits-for-user | Leave firstMessage out |
Tools
A Vapi function tool declares its parameters as JSON Schema, and Vapi posts a
tool-calls message to your server URL, which answers with results. A
Micdrop tool declares its parameters with Zod and runs in the process of the
call, so its result goes straight back to the model:
import { z } from 'zod'
const tools = [ endCallTool(), { name: 'book_appointment', description: 'Books an appointment for the caller', inputSchema: z.object({ date: z.string(), time: z.string() }), execute: async ({ date, time }) => bookAppointment(date, time), },]The execute function receives typed arguments and returns any value, which
the agent hands to the model. The same tools work with a realtime model.
End call
The endCall tool of Vapi maps to endCallTool(). The model calls it once
the caller says goodbye, and the call ends after the goodbye has played. Its
description option tells the model when to call it, which covers what
endCallMessage and the tool messages set on Vapi:
endCallTool({ description: 'Call this tool once the caller has said goodbye, after saying goodbye yourself',})To end the call on phrases the assistant says, as endCallPhrases does,
listen to its messages and call endCall() on the agent:
agent.on('Message', (message) => { if (message.role === 'assistant' && /have a nice day/i.test(message.content)) { agent.endCall() }})maxDurationSeconds becomes a timer of your own that calls agent.endCall().
Transfers
The transferCall tool of Vapi with a destination of type: "number" maps to
transferCallTool(), which the phone template
adds when TRANSFER_NUMBER is set in .env. The agent transfers the caller
when they ask for a person, after announcing it, through the API of the
telephony provider.
TRANSFER_MODE=cold, the default, is the blind transfer of Vapi.
TRANSFER_MODE=warm matches its warm transfers that speak a summary: the
person reached hears a summary the model wrote, then the caller joins them.
Phone numbers
Vapi routes a number to an assistant with its assistantId, or asks your
server with an assistant-request. With Micdrop, the number points its voice
webhook to your server, and that webhook decides which agent answers:
| Provider | Webhook of the phone template |
|---|---|
| Twilio | https://<host>/twilio/voice |
| Telnyx | https://<host>/telnyx/webhook |
| Vonage | https://<host>/vonage/answer |
| Plivo | https://<host>/plivo/answer |
A number you imported into Vapi from Twilio or Telnyx already lives in your account at that provider: change its webhook, and it rings your server. A free number of Vapi stays on Vapi, so buy one at your telephony provider.
To answer several numbers with different assistants, read transport.call.to,
the number called, and pick the system prompt and the tools from it.
For an outbound call, ask your provider to dial the number with the same
document the webhook returns. With Twilio, create the call with the TwiML of
twilioStreamTwiml():
import { twilioStreamTwiml } from '@micdrop/telephony'
await fetch( `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Calls.json`, { method: 'POST', headers: { Authorization: `Basic ${Buffer.from(`${accountSid}:${authToken}`).toString('base64')}`, 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ To: '+14155550100', From: yourTwilioNumber, Twiml: twilioStreamTwiml({ url: `wss://${host}/twilio/stream` }), }), })Dynamic variables
Vapi fills {{name}} in the prompt from assistantOverrides.variableValues.
With Micdrop, the webhook passes parameters to the stream, waitForParams
hands them to the call, and the prompt is a template literal:
const params = await waitForParams(transport, (value) => value)
createAi({ systemPrompt: `You answer the phone for Acme. The caller's number is ${params.caller}.`,})The phone template passes the number of the caller this way. Validate the
parameters with a Zod schema in place of (value) => value, as
Auth and parameters shows.
Server events and the end of call report
Vapi posts events to your server URL. With Micdrop, the call runs in your process, so the events are listeners:
| Vapi event | Micdrop |
|---|---|
end-of-call-report | server.on('End', ({ conversation, duration }) => …) |
conversation-update, transcript | server.on('Message', (item) => …) |
status-update with ended | The End event |
tool-calls | The execute function of each tool |
assistant-request | The webhook of your number |
The phone template logs the conversation in its End listener. Replace the
log with a write to your database or a request to your CRM.
Recording
artifactPlan.recordingEnabled maps to MicdropRecorder, which collects the
audio of each message with its text. The phone template writes them to
RECORDINGS_DIR, one WAV file per message and the transcript, in
src/recording.ts. Replace the writes with an upload to your storage.
Web calls
A call from a page goes through your server too. Where @vapi-ai/web starts
an assistant with vapi.start(assistantId) and a public key, @micdrop/web
connects to your WebSocket, so the keys of the providers stay on the server:
import { Micdrop } from '@micdrop/web'
await Micdrop.start({ url: 'wss://example.com/call' })Micdrop.on('StateChange', (state) => console.log(state.conversation))The call-start, call-end and speech-start events of the Vapi SDK are
fields of the call state: isStarted,
isAssistantSpeaking and isUserSpeaking. The Next.js, Vite and Expo
templates start from a working page or app.
What you run yourself
Your server now holds the call for its whole length, so deploy it where a
process keeps a WebSocket open, close to the media region of your telephony
provider. Check the signature of the webhooks and streams of your provider, as
Telephony explains for each of them. Call history,
dashboards and analytics are yours to build from the End event and the
recorder.