Setup
Create a Vapi Account
Create a Vapi account by going here.
Get a Vapi Phone Number
Go to the Vapi dashboard.
Click on Platform, Phone Numbers, and then Buy Number to get a phone number.
Install IntelliJ
To develop Vapi4k applications, you need to install IntelliJ on your machine. You can download the Community Edition from the JetBrains Toolbox App.
Configure IntelliJ
The EnvFile plugin allows you to load environment variables from a file when running your applications. It simplifies local development with ngrok
.
Install the EnvFile plugin
Start IntelliJ.
Select the IntelliJ IDEA Settings... menu options.
Click on the Plugins option.
Click on the Marketplace option and type EnvFile in the search field.
Enable the EnvFile option.
Restart IntelliJ.
Create a repository
Create a vapi4k-template repository
Go to the vapi4k-template GitHub page.
Click on the Use this template and Create a new repository options.
Give the new repository a name.
Click on the Create repository option.
Clone your repository
You can now clone your new vapi4k-template repository to your local machine from within IntelliJ or using git clone <repository-url>
on the command line.
Clone the vapi4k-template repository within IntelliJ
Go to your newly created vapi4k-template repository page on GitHub.
Click on the Code option.
Copy either the HTTPS or SSH repository URL.
Open IntelliJ.
Click on the File, New, Project from Version Control... options.
Paste the repository URL and choose the desired Directory.
Install ngrok
The ngrok proxy allows you to expose your local Vapi4k Ktor server to the internet. It is very useful for developing Vapi4k apps because it greatly decreases your iteration time. It is also useful for watching the traffic between your app and the Vapi platform. To install ngrok, go to the ngrok download page and follow the instructions for your operating system.
Run ngrok
To run ngrok, open a terminal window and type:
Copy the ngrok Web Interface
URL and paste it into your browser. You will see the ngrok dashboard and all messages exchanged between your app and the Vapi platform.
Copy the ngrok Forwarding
URL to your clipboard. You will need this URL in the next step.
Create a secrets file
The Vapi4k server requires some environment variables to be defined to connect to the Vapi platform.
Create a secrets.env file
Start IntelliJ.
Open your vapi4k-template application.
Ctrl-click on the /secrets folder.
Choose the New, File options.
Create a file named secrets.env.
The secrets.env
file should contain values for these environment variables:
VAPI_PRIVATE_KEY
VAPI_PUBLIC_KEY
VAPI_PHONE_NUMBER_ID
VAPI4K_BASE_URL
The first three values can be found on the Vapi dashboard. The keys are found by clicking on the organization button on the lower left, and the phone number ID is found in the Platform
Phone Number
section.
The VAPI4K_BASE_URL value is the ngrok Forwarding
URL.
The secrets/secrets.env
should look something like this:
Adjust Run Configuration
Adjust Run Configuration to use secrets.env
Start IntelliJ.
Open src/main/kotlin/com/myapp/Application.kt.
Click on the green arrow to the left of
fun main()
to run the server.Now run the server with the secrets.env by clicking on the three vertical dots in the Run panel and click on Modify Run Configuration....
Scroll down and check the Enable Env File option and assign the Server URL.
Scroll down and click on the ➕ button, then click on .env file and then select the secrets.env created above.
Restart the server and you should see the log saying the Vapi4kServer is started at with the ngrok VAPI4K_BASE_URL value.
Click on the VAPI4K_BASE_URL value in the log to open the Vapi4k admin page. Use the username/password values of admin/admin.
You are now ready to run a Vapi4k application.