
No Comments Yet
Be the first to share your thoughts and start the conversation.
Vapi has updated how Workflows are used. Be sure to review the latest implementation below!
Set up a Global Prompt:
Modify the first Conversation Node:
Modify the condition bubble to say something like “If user provided all the variables.” - you can click on the yellow bubble or the green edge to get it's condition in the right-side menu.
Add a new node - API request, and configure it exactly the same as shown in the video. Remember about adding the userid variable along the ones extracted from the conversation!
You can also configure custom messages for the current API Call status - request sent, recievied success response, and request failed:
Add a Hang-Up node below.
The final Workflow should look like this:
Save the Workflow, and copy it's ID. Paste it in the .env.local as NEXT_PUBLIC_VAPI_WORKFLOW_ID - same as in the video.
Later in the course, when implementing vapi.start() method, instead of passing workflow's ID to the method as the first variable, we have to modify it a bit. vapi.start() checks if Agent was defined, and then falls back to Workflow if necessary, so we have to explicitly say that Agent is undefined - here is the updated handleCall method:
const handleCall = async () => {
setCallStatus(CallStatus.CONNECTING);
if (type === "generate") {
await vapi.start(
undefined,
undefined,
undefined,
process.env.NEXT_PUBLIC_VAPI_WORKFLOW_ID!,
{
variableValues: {
username: userName,
userid: userId,
},
}
);
} else {
let formattedQuestions = "";
if (questions) {
formattedQuestions = questions
.map((question) => `- ${question}`)
.join("\n");
}
await vapi.start(interviewer, {
variableValues: {
questions: formattedQuestions,
},
});
}
};
Be the first to share your thoughts and start the conversation.