Skip to content

Commit f14db2f

Browse files
authored
bephrem/developing-locally (#66)
* image * the problem * Update developing-locally.mdx * save
1 parent 99d6ae9 commit f14db2f

File tree

6 files changed

+100
-4
lines changed

6 files changed

+100
-4
lines changed

mint.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@
137137
},
138138
{
139139
"group": "Server URL",
140-
"pages": ["server-url", "server-url/setting-server-urls", "server-url/events"]
140+
"pages": [
141+
"server-url",
142+
"server-url/setting-server-urls",
143+
"server-url/events",
144+
"server-url/developing-locally"
145+
]
141146
},
142147
{
143148
"group": "Phone Calling",

server-url.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ To get started using server URLs, read our guides:
4343
<Card title="Events" icon="bell-on" iconType="solid" href="/server-url/events">
4444
Read about the different types of events Vapi can send to your server.
4545
</Card>
46+
<Card
47+
title="Developing Locally"
48+
icon="laptop-arrow-down"
49+
iconType="solid"
50+
href="/server-url/developing-locally"
51+
>
52+
Learn about receiving server events in your local development environment.
53+
</Card>
4654
</CardGroup>
4755

4856
## FAQ
@@ -55,8 +63,8 @@ To get started using server URLs, read our guides:
5563
- **Workflow Orchestrator:** platforms like [Pipedream](https://pipedream.com) & [Make](https://www.make.com) allow you to program workflows (often without code) that can receive events via HTTP triggers.
5664

5765
The main idea is that Vapi needs a location on the Internet that it can drop data to & converse with your application.
58-
</Accordion>
5966

67+
</Accordion>
6068
<Accordion title="Why not just call them webhooks?">
6169
[Webhooks](/glossary#webhook) are traditionally unidirectional & stateless, with the target endpoint usually only replying with a status code to acknowledge message reception. Certain server URL events (like assistant requests) may require a meaningful reply from your server.
6270

server-url/developing-locally.mdx

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,88 @@
11
---
22
title: "Developing Locally"
33
sidebarTitle: "Developing Locally"
4-
description: "lorem."
4+
description: "Learn how to receive server events in your local development environment."
55
---
6+
7+
## The Problem
8+
9+
When Vapi dispatches events to a server, it must be able to reach the server via the open Internet.
10+
11+
If your API is already live in production, it will be accessible via a publicly known URL. But, during development, your server will often be running locally on your machine.
12+
13+
<Info>
14+
`localhost` is an alias for the IP address `127.0.0.1`. This address is called the "loopback"
15+
address and forwards the network request within the machine itself.
16+
</Info>
17+
18+
To receive server events locally, we will need a public address on the Internet that can receive traffic and forward it to our local machine.
19+
20+
## Tunneling Traffic
21+
22+
We will be using a service called [ngrok](https://ngrok.com/) to create a secure tunnel to our local machine. The flow will look like the following:
23+
24+
<Steps>
25+
<Step title="Start Our API Locally">
26+
We will start our server locally so it is listening for http traffic.
27+
</Step>
28+
<Step title="Start Ngrok Agent">
29+
We will use the `ngrok` command to start the [ngrok agent](https://ngrok.com/docs/agent) on our
30+
machine. This will establish a connection from your local machine to ngrok's servers.
31+
</Step>
32+
<Step title="Copy Public Ngrok URL">
33+
Ngrok will give us a public URL that can receive traffic. We will use this as a server URL
34+
during development.
35+
</Step>
36+
<Step title="Trigger Call Events">
37+
We will conduct normal calls on Vapi to trigger events. These events will go to the Ngrok URL & get tunnelled to our local machine.
38+
39+
We will see the event payloads come through locally & log them.
40+
41+
</Step>
42+
</Steps>
43+
44+
#### Starting Our API Locally
45+
46+
First, ensure that your API is running locally. This could be a Node.js server, a Python server, or any other server that can receive HTTP requests.
47+
48+
Take note of the port that your server is running on. For example, if your server is running on port `8080`, you should be able to access it at `http://localhost:8080` in your browser.
49+
50+
#### Starting Ngrok Agent
51+
52+
Next we will install & run Ngrok agent to establish the forwarding pathway for Internet traffic:
53+
54+
<Steps>
55+
<Step title="Install Ngrok Agent CLI">
56+
Install the Ngrok agent by following Ngrok's [quickstart
57+
guide](https://ngrok.com/docs/getting-started). Once complete, we will have the `ngrok` command
58+
available in our terminal.
59+
</Step>
60+
<Step title="Start Ngrok Agent">
61+
Run the command `ngrok http 8080`, this will create the tunnel with Ngrok's servers.
62+
<Note>Replace `8080` with the port your server is running on.</Note>
63+
</Step>
64+
</Steps>
65+
66+
#### Copy Public Ngrok URL
67+
68+
You will see an output from the Ngrok Agent CLI that looks like the following:
69+
70+
<Frame caption="Terminal after running the 'ngrok' command forwarding to localhost:8080 — the 'Forwarding' URL is what we want.">
71+
<img src="/static/images/server-url/developing-locally/ngrok-cli-ui.png" />
72+
</Frame>
73+
74+
Copy this public URL that Ngrok provides. This URL will be accessible from the open Internet and will forward traffic to your local machine.
75+
76+
You can now use this as a server URL in the various places you can [set server URLs](/server-url/setting-server-urls) in Vapi.
77+
78+
<Note>
79+
This URL will change every time that you run the `ngrok` command. If you'd like this URL to be the
80+
same every Ngrok session, look into [static domains on
81+
Ngrok](https://ngrok.com/docs/getting-started#step-4-always-use-the-same-domain).
82+
</Note>
83+
84+
#### Trigger Call Events
85+
86+
We will now be able to see call events come through and get logged to our terminal.
87+
88+
Feel free to follow any of our [quickstart](/quickstart) guides to get started with building assistants & conducting calls.

server-url/setting-server-urls.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,4 @@ Events are only sent/assigned to 1 server URL in the priority stack. Here's the
9696
3. **Phone Number:** if a phone number has a server URL, it will be used over the account-wide URL
9797
4. **Account-wide:** Default / "lowest" importance. It will be used if no other server URL is set.
9898

99-
You will most commonly set a server URL on your account & on specific assistants.
99+
You will most commonly set a server URL on your account, and/or on specific assistants.
Loading
Loading

0 commit comments

Comments
 (0)