Run the Template Applications
If you look at src/main/kotlin/com/myapp/Application.kt
, you will see that the Vapi4k plugin is used like any other Ktor plugin. The Vapi4k plugin has a Vapi4kConfig
context where you can define the desired applications.
The template includes three applications:
An inbound call application that uses an assistant to respond to incoming calls.
An outbound call application that calls a phone number and uses the assistant to respond.
A web application that uses the assistant to respond to a web page call button.
Verify the Applications
Before running the applications, verify that the assistant request responses and tool calls for each of the applications work correctly.
Verify the Applications
Start the Vapi4k server.
Click on the `VAPI4K_BASE_URL` value in the log to open the Vapi4k admin page.
Click on /vapi4k under InboundCall Applications.
The Assistant Response tab contains the JSON message generated for an inbound call using the /incomingCall/vapi4k path.
Click on Service Tools to see the weather tool.
Type some values for city and state, and click Invoke Tool to see the resulting JSON message.
Have a look at the /callCustomer and /talkApp serverPaths as well.
Inbound Call Application
Configure Vapi for an Inbound Call
Go to the Vapi dashboard.
Click on the green organization button on the lower left.
Click on the Settings option and assign the Server URL.
The Server URL is a combination of the VAPI4K_BASE_URL
value and a /inboundCall/serverPath
value.
The /inboundCall
indicates that the URL corresponds to a Vapi4k inboundCallApplication{}
declaration.
The serverPath
value is defined in the inboundCallApplication{}
declaration and defaults to /vapi4k
.
The Server URL should look something like this:
Run the Inbound Call Application
Start the Vapi4k server.
Call your Vapi phone number and you should see messages in the admin log.
To test a tool call, ask the assistant "What is the weather in Dallas, Texas?"
Outbound Call Application
Run the Outbound Call Application
Start the Vapi4k server.
Open src/main/kotlin/com/myapp/CallCustomer.kt and edit the phone number appropriately.
Click on the green arrow to the left of
fun main()
to create the call.You should now receive a phone call at the specified number.
Ask the assistant "What is the weather in Los Angeles, California?"
Web Application
Run the Web Application
Start the Vapi4k server.
Open the $VAPI4K_BASE_URL/talk URL in your browser.
Click on the talk button and ask the assistant "What is the weather in Miami, Florida?"