-
Notifications
You must be signed in to change notification settings - Fork 244
Update Vapi SDK and implement new way to handle Workflows #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { CreateAssistantDTO } from "@vapi-ai/web/dist/api"; | ||
| import { CreateAssistantDTO, CreateWorkflowDTO } from "@vapi-ai/web/dist/api"; | ||
| import { z } from "zod"; | ||
|
|
||
| export const mappings = { | ||
|
|
@@ -97,6 +97,200 @@ export const mappings = { | |
| "aws amplify": "amplify", | ||
| }; | ||
|
|
||
| export const generator: CreateWorkflowDTO = { | ||
| name: "Generate Interview", | ||
| nodes: [ | ||
| { | ||
| name: "start", | ||
| type: "conversation", | ||
| isStart: true, | ||
| metadata: { | ||
| position: { | ||
| x: 0, | ||
| y: 0, | ||
| }, | ||
| }, | ||
| prompt: | ||
| "Speak first. Greet the user and help them create a new AI Interviewer", | ||
| voice: { | ||
| model: "aura-2", | ||
| voiceId: "thalia", | ||
| provider: "deepgram", | ||
| }, | ||
| variableExtractionPlan: { | ||
| output: [ | ||
| { | ||
| title: "level", | ||
| description: "The job experience level.", | ||
| type: "string", | ||
| enum: ["entry", "mid", "senior"], | ||
| }, | ||
| { | ||
| title: "amount", | ||
| description: "How many questions would you like to generate?", | ||
| type: "number", | ||
| enum: [], | ||
| }, | ||
| { | ||
| title: "techstack", | ||
| description: | ||
| "A list of technologies to cover during the job interview. For example, React, Next.js, Express.js, Node and so on...", | ||
| type: "string", | ||
| enum: [], | ||
| }, | ||
| { | ||
| title: "role", | ||
| description: | ||
| "What role should would you like to train for? For example Frontend, Backend, Fullstack, Design, UX?", | ||
| type: "string", | ||
| enum: [], | ||
| }, | ||
| { | ||
| title: "type", | ||
| description: "What type of the interview should it be? ", | ||
| type: "string", | ||
| enum: ["behavioural", "technical", "mixed"], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| name: "apiRequest_1747470739045", | ||
| type: "apiRequest", | ||
| metadata: { | ||
| position: { | ||
| x: -16.075937072883846, | ||
| y: 703.623428447121, | ||
| }, | ||
| }, | ||
| method: "POST", | ||
| url: `${process.env.NEXT_PUBLIC_BASE_URL}/api/vapi/generate`, | ||
| headers: { | ||
| type: "object", | ||
| properties: {}, | ||
| }, | ||
| body: { | ||
| type: "object", | ||
| properties: { | ||
| role: { | ||
| type: "string", | ||
| description: "", | ||
| value: "{{ role }}", | ||
| }, | ||
| level: { | ||
| type: "string", | ||
| description: "", | ||
| value: "{{ level }}", | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| description: "", | ||
| value: "{{ type }}", | ||
| }, | ||
| amount: { | ||
| type: "number", | ||
| description: "", | ||
| value: "{{ amount }}", | ||
| }, | ||
| userid: { | ||
| type: "string", | ||
| description: "", | ||
| value: "{{ userid }}", | ||
| }, | ||
|
Comment on lines
+195
to
+199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify user ID handling in the API request. The workflow passes 🏁 Script executed: #!/bin/bash
# Check how the API validates user IDs
fd "api/vapi/generate" --type f | xargs rg -A 10 -B 5 "userid"Length of output: 3671 Add proper validation and authentication for The handler in const { type, role, level, techstack, amount, userid } = await request.json();
// …
const interview = {
// …
userId: userid,
// …
};
await db.collection("interviews").add(interview);There’s no check that
Files to update:
Please implement these checks before persisting any interview data. 🤖 Prompt for AI Agents |
||
| techstack: { | ||
| type: "string", | ||
| description: "", | ||
| value: "{{ techstack }}", | ||
| }, | ||
| }, | ||
| }, | ||
| output: { | ||
| type: "object", | ||
| properties: {}, | ||
| }, | ||
| mode: "blocking", | ||
| hooks: [], | ||
| }, | ||
| { | ||
| name: "conversation_1747721261435", | ||
| type: "conversation", | ||
| metadata: { | ||
| position: { | ||
| x: -17.547788169718615, | ||
| y: 1003.3409337989506, | ||
| }, | ||
| }, | ||
| prompt: | ||
| "Thank the user for the conversation and inform them that the interview was generated successfully.", | ||
| voice: { | ||
| provider: "deepgram", | ||
| voiceId: "thalia", | ||
| model: "aura-2", | ||
| }, | ||
| }, | ||
| { | ||
| name: "conversation_1747744490967", | ||
| type: "conversation", | ||
| metadata: { | ||
| position: { | ||
| x: -11.165436030430953, | ||
| y: 484.94857971060617, | ||
| }, | ||
| }, | ||
| prompt: "Say that the Interview will be generated shortly.", | ||
| voice: { | ||
| provider: "deepgram", | ||
| voiceId: "thalia", | ||
| model: "aura-2", | ||
| }, | ||
| }, | ||
| { | ||
| name: "hangup_1747744730181", | ||
| type: "hangup", | ||
| metadata: { | ||
| position: { | ||
| x: 76.01267674000721, | ||
| y: 1272.0665127156606, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| edges: [ | ||
| { | ||
| from: "apiRequest_1747470739045", | ||
| to: "conversation_1747721261435", | ||
| condition: { | ||
| type: "ai", | ||
| prompt: "", | ||
| }, | ||
| }, | ||
| { | ||
| from: "start", | ||
| to: "conversation_1747744490967", | ||
| condition: { | ||
| type: "ai", | ||
| prompt: "If user provided all the required variables", | ||
| }, | ||
| }, | ||
| { | ||
| from: "conversation_1747744490967", | ||
| to: "apiRequest_1747470739045", | ||
| condition: { | ||
| type: "ai", | ||
| prompt: "", | ||
| }, | ||
| }, | ||
| { | ||
| from: "conversation_1747721261435", | ||
| to: "hangup_1747744730181", | ||
| condition: { | ||
| type: "ai", | ||
| prompt: "", | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export const interviewer: CreateAssistantDTO = { | ||
| name: "Interviewer", | ||
| firstMessage: | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Ensure environment variable is properly defined.
The API URL uses
${process.env.NEXT_PUBLIC_BASE_URL}- make sure this environment variable is properly defined in all environments where this code will run.🏁 Script executed:
Length of output: 132
Define and Configure
NEXT_PUBLIC_BASE_URLin All EnvironmentsWe’ve only located the usage at
constants/index.ts:167and no committed definitions forNEXT_PUBLIC_BASE_URL. To prevent runtime errors:NEXT_PUBLIC_BASE_URLto your environment files (e.g.,•
.env.development•
.env.production•
.env.examplePlease update your .env files and deployment settings accordingly.
🤖 Prompt for AI Agents