vapi4k-docs Help

Setup

Create a Vapi Account

Create a Vapi account by going here.

Get a Vapi Phone Number

  1. Go to the Vapi dashboard.

  2. 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

  1. Start IntelliJ.

  2. Select the IntelliJ IDEA Settings... menu options.

  3. Click on the Plugins option.

  4. Click on the Marketplace option and type EnvFile in the search field.

  5. Enable the EnvFile option.

  6. Restart IntelliJ.

Create a repository

Create a vapi4k-template repository

  1. Go to the vapi4k-template GitHub page.

  2. Click on the Use this template and Create a new repository options.

  3. Give the new repository a name.

  4. 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

  1. Go to your newly created vapi4k-template repository page on GitHub.

  2. Click on the Code option.

  3. Copy either the HTTPS or SSH repository URL.

  4. Open IntelliJ.

  5. Click on the File, New, Project from Version Control... options.

  6. 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:

ngrok http 8080

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

  1. Start IntelliJ.

  2. Open your vapi4k-template application.

  3. Ctrl-click on the /secrets folder.

  4. Choose the New, File options.

  5. 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:

VAPI_PRIVATE_KEY=f3ff6277-8d9b-8873-eec7-743786e2aa42 VAPI_PUBLIC_KEY=l9lf6233-9s9f-9173-egc1-433786e2aa98 VAPI_PHONE_NUMBER_ID=8b151b80-5fff-4df9-ad67-993189409d4c VAPI4K_BASE_URL=https://fdee-73-71-109-432.ngrok-free.app

Adjust Run Configuration

Adjust Run Configuration to use secrets.env

  1. Start IntelliJ.

  2. Open src/main/kotlin/com/myapp/Application.kt.

  3. Click on the green arrow to the left of fun main() to run the server.

  4. 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....

  5. Scroll down and check the Enable Env File option and assign the Server URL.

  6. Scroll down and click on the button, then click on .env file and then select the secrets.env created above.

  7. Restart the server and you should see the log saying the Vapi4kServer is started at with the ngrok VAPI4K_BASE_URL value.

  8. 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.

Last modified: 04 October 2024