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.
