In this example, weโll be using the Web SDK to create an assistant that can take a pizza order. Since all the Client SDKs have equivalent functionality, you can use this example as a guide for any Vapi client. We want to add a button to the page to start a call, update our UI with the call status, and display what the userโs saying while they say it. When the user mentions a topping, we should add it to the pizza. When theyโre done, we should redirect them to checkout.Documentation Index
Fetch the complete documentation index at: https://vapi-bephrem-11labs-in-quickstart.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Create an assistant
Weโll start by taking a look at the Assistant API
reference and define our
assistant:Letโs break this down:
model- Weโre using the OpenAI GPT-4 model, which is better at function calling.messages- Weโre defining the assistantโs instructions for how to run the call.functions- Weโre providing a addTopping function with a topping parameter. The assistant can call this during the conversation to add a topping. Weโre also adding goToCheckout, with an empty parameters object. The assistant can call this to redirect the user to checkout.firstMessage- This is the first message the assistant will say when the user starts the call.
Set up the Web SDK
Weโll follow the
README for the Web SDK to get it installed.Weโll then get our Public Key from the Vapi Dashboard and initialize the SDK:Handle transcription events
All messages send to the Server URL, including
transcript and function-call messages, are also sent to the client as message events. Weโll need to check the type of the message to see what type it is.
