Public
Remixed
Make an AI phone call with one fetch to Vapi
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

What's the simplest way to make an AI phone call?

This val serves a tiny form: you type a phone number, Vapi rings it, and an AI has a conversation with whoever answers. Vapi hosts the telephony and the live audio bridge to the model, so the whole demo is one POST to https://api.vapi.ai/call — one file, about seventy lines, no imports.

Setup

  1. Remix this val to get your own copy.

  2. Get a Vapi API key — sign up at dashboard.vapi.ai and copy your private key, then paste it as an env var in your val:

    👉 Add VAPI_API_KEY here

  3. Create a phone number in the Vapi dashboard (free Vapi numbers work for testing) and copy its ID:

    👉 Add VAPI_PHONE_NUMBER_ID here

Test it

Open the HTTP endpoint of main.ts, type your own number in E.164 format (+15551234567), and hit Call me. Your phone rings and the AI speaks first. Without the env vars set, the page shows a setup reminder instead of erroring.

Files

  • main.ts — the form, and the one fetch that places the call

Notes

  • FIRST_MESSAGE, SYSTEM_PROMPT, MODEL, and VOICE at the top of main.ts control what the AI opens with, how it behaves, and how it sounds.
  • Free Vapi numbers are US-only and meant for testing.
  • From here you can add tool calls, transcripts, and post-call analysis — see docs.vapi.ai.
  • Only call numbers you have consent to call — automated calls without consent violate TCPA/FCC rules.