A simple example API project demonstrating how to integrate with Vapi.
- Install dependencies:
npm install
- Configure environment variables:
Copy
.env.example
to.env
and update the values:
cp .env.example .env
- Start the development server:
npm run dev
Tip: Use
npm start
instead ofnpm run dev
to avoid auto-reloading and URL changes during development.
The API will be available at http://localhost:4000
This project includes optional ngrok integration for exposing your local server to the internet. To enable ngrok:
- Sign up for a free ngrok account at https://ngrok.com
- Get your authtoken from https://dashboard.ngrok.com/get-started/your-authtoken
- Update your
.env
file:- Set
ENABLE_NGROK=true
- Add your
NGROK_AUTH_TOKEN
from step 2
- Set
- Start the server with
npm run dev
- The server will print the Server Messages URL in the console (e.g.,
Server Messages URL: https://xxxx-xxxx-xxxx.ngrok.app/messages
) - Copy this URL and update the Server URL in your Vapi dashboard:
- Go to the Vapi dashboard at https://dashboard.vapi.ai/assistants
- Navigate to the Advanced Tab in the Messaging Section
- Paste the Server Messages URL from the console
Note: If you're using a free ngrok account, the URL will change each time you restart the server or modify your code (which triggers a server reload). You'll need to update the Server URL in your Vapi dashboard with the new URL each time. To avoid this during development, use
npm start
instead ofnpm run dev
.
POST /messages
- Receive server messages from Vapi