|
1 | 1 | ---
|
2 | 2 | title: Local webhook testing
|
3 |
| -description: Test webhooks locally without ngrok using vapi listen |
| 3 | +description: Forward webhooks to your local development server with vapi listen |
4 | 4 | slug: cli/webhook
|
5 | 5 | ---
|
6 | 6 |
|
7 | 7 | ## Overview
|
8 | 8 |
|
9 |
| -The `vapi listen` command enables real-time webhook testing on your local development server without external tunneling services like ngrok. This dramatically speeds up development by letting you test webhook integrations instantly. |
| 9 | +The `vapi listen` command provides a webhook forwarding service that receives events from Vapi and forwards them to your local development server. This helps you debug webhook integrations without deploying your code. |
10 | 10 |
|
11 | 11 | **In this guide, you'll learn to:**
|
12 | 12 | - Set up local webhook forwarding
|
13 | 13 | - Debug webhook events in real-time
|
14 | 14 | - Configure advanced forwarding options
|
15 | 15 | - Handle different webhook types
|
16 | 16 |
|
| 17 | +<Info> |
| 18 | +**Note on tunneling:** Currently, `vapi listen` requires you to manually update your webhook URLs in Vapi. Automatic tunnel creation (like Stripe CLI) is coming in a future update. |
| 19 | +</Info> |
| 20 | + |
17 | 21 | ## Quick start
|
18 | 22 |
|
19 |
| -Forward Vapi webhooks to your local server: |
| 23 | +<Steps> |
| 24 | + <Step title="Start the webhook listener"> |
| 25 | + ```bash |
| 26 | + vapi listen --forward-to localhost:3000/webhook |
| 27 | + ``` |
| 28 | + |
| 29 | + Note the public URL provided in the output (e.g., `https://webhook-proxy.vapi.ai/wh_abc123def456`) |
| 30 | + </Step> |
| 31 | + |
| 32 | + <Step title="Update your webhook URLs"> |
| 33 | + Go to your Vapi Dashboard and update your webhook URLs to point to the URL from step 1: |
| 34 | + - Assistant webhook URL |
| 35 | + - Phone number webhook URL |
| 36 | + - Or any other webhook configuration |
| 37 | + </Step> |
| 38 | + |
| 39 | + <Step title="Test your webhooks"> |
| 40 | + Trigger webhook events (make calls, etc.) and see them forwarded to your local server in real-time |
| 41 | + </Step> |
| 42 | +</Steps> |
20 | 43 |
|
21 |
| -```bash |
22 |
| -vapi listen --forward-to localhost:3000/webhook |
23 |
| -``` |
| 44 | +## How it works |
24 | 45 |
|
25 |
| -That's it! All webhook events from Vapi will be forwarded to your local endpoint in real-time. |
| 46 | +<Note> |
| 47 | +**Current implementation:** The `vapi listen` command currently acts as a local webhook forwarder. Unlike tools like Stripe CLI, it doesn't yet create an automatic tunnel to update your Vapi webhook URLs. You'll need to manually configure your webhook URL in Vapi to point to the CLI's endpoint. |
26 | 48 |
|
27 |
| -## How it works |
| 49 | +**Coming soon:** Automatic tunneling that updates your Vapi webhook configuration is planned for a future release. |
| 50 | +</Note> |
28 | 51 |
|
29 | 52 | <Steps>
|
30 | 53 | <Step title="Local server starts">
|
31 | 54 | The CLI starts a webhook server on port 4242 (configurable)
|
32 | 55 | </Step>
|
33 | 56 |
|
34 |
| - <Step title="Secure tunnel created"> |
35 |
| - A secure tunnel is established between Vapi and your local server |
| 57 | + <Step title="Configure webhook URL"> |
| 58 | + Update your Vapi webhook URL to point to the CLI's public endpoint (provided when you start the listener) |
36 | 59 | </Step>
|
37 | 60 |
|
38 | 61 | <Step title="Events forwarded">
|
39 |
| - All webhook events are forwarded to your specified endpoint |
| 62 | + All webhook events are forwarded to your specified local endpoint |
40 | 63 | </Step>
|
41 | 64 |
|
42 | 65 | <Step title="Real-time logging">
|
@@ -87,10 +110,11 @@ When you run `vapi listen`, you'll see:
|
87 | 110 | $ vapi listen --forward-to localhost:3000/webhook
|
88 | 111 |
|
89 | 112 | 🎧 Vapi Webhook Listener
|
90 |
| -📡 Listening on: https://vapi-webhooks.ngrok.io/abc123 |
| 113 | +📡 Listening on: https://webhook-proxy.vapi.ai/wh_abc123def456 |
91 | 114 | 📍 Forwarding to: http://localhost:3000/webhook
|
92 | 115 |
|
93 |
| -✓ Webhook URL configured in your Vapi account |
| 116 | +⚠️ Please update your webhook URL in Vapi to: |
| 117 | + https://webhook-proxy.vapi.ai/wh_abc123def456 |
94 | 118 |
|
95 | 119 | Waiting for webhook events...
|
96 | 120 |
|
@@ -150,6 +174,18 @@ X-Webhook-Timestamp: 1705331445
|
150 | 174 |
|
151 | 175 | Your server receives the exact webhook payload from Vapi with these additional headers for debugging.
|
152 | 176 |
|
| 177 | +### Manual webhook configuration |
| 178 | + |
| 179 | +Since automatic tunneling isn't available yet, you'll need to: |
| 180 | + |
| 181 | +1. Start the webhook listener and note the public URL |
| 182 | +2. Go to your Vapi Dashboard or use the API to update webhook URLs |
| 183 | +3. Set the webhook URL to the one provided by `vapi listen` |
| 184 | + |
| 185 | +<Tip> |
| 186 | +**Future enhancement:** We're working on automatic webhook URL updates, similar to how Stripe CLI works. This will eliminate the manual configuration step. |
| 187 | +</Tip> |
| 188 | + |
153 | 189 | ### Filtering events
|
154 | 190 |
|
155 | 191 | Filter specific event types (coming soon):
|
|
0 commit comments