mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-04 12:52:43 +02:00
simplify workflow version mgmt
This commit is contained in:
parent
1b19a9bcba
commit
23681d8b4d
49 changed files with 385 additions and 4767 deletions
|
|
@ -1,9 +1,8 @@
|
|||
import { getResponse } from "@/app/lib/agents";
|
||||
import { agentWorkflowsCollection, twilioConfigsCollection, twilioInboundCallsCollection } from "@/app/lib/mongodb";
|
||||
import { projectsCollection, twilioConfigsCollection, twilioInboundCallsCollection } from "@/app/lib/mongodb";
|
||||
import { collectProjectTools } from "@/app/lib/project_tools";
|
||||
import { PrefixLogger } from "@/app/lib/utils";
|
||||
import VoiceResponse from "twilio/lib/twiml/VoiceResponse";
|
||||
import { ObjectId } from "mongodb";
|
||||
import { z } from "zod";
|
||||
import { TwilioInboundCall } from "@/app/lib/types/voice_types";
|
||||
import { hangup, reject, XmlResponse, ZStandardRequestParams } from "../utils";
|
||||
|
|
@ -63,16 +62,19 @@ export async function POST(request: Request) {
|
|||
return reject('rejected');
|
||||
}
|
||||
|
||||
// extract workflow and project id and fetch workflow from db
|
||||
// fetch project and extract live workflow
|
||||
// if workflow not found, reject the call
|
||||
const projectId = twilioConfig.project_id;
|
||||
const workflowId = twilioConfig.workflow_id;
|
||||
const workflow = await agentWorkflowsCollection.findOne({
|
||||
projectId: projectId,
|
||||
_id: new ObjectId(workflowId),
|
||||
const project = await projectsCollection.findOne({
|
||||
_id: projectId,
|
||||
});
|
||||
if (!project) {
|
||||
logger.log(`Project ${projectId} not found`);
|
||||
return reject('rejected');
|
||||
}
|
||||
const workflow = project.liveWorkflow;
|
||||
if (!workflow) {
|
||||
logger.log(`Workflow ${workflowId} not found for project ${projectId}`);
|
||||
logger.log(`Workflow not found for project ${projectId}`);
|
||||
return reject('rejected');
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +83,7 @@ export async function POST(request: Request) {
|
|||
|
||||
// this is the first turn, get the initial assistant response
|
||||
// and validate it
|
||||
const { messages } = await getResponse(workflow, projectTools, []);
|
||||
const { messages } = await getResponse(projectId, workflow, projectTools, []);
|
||||
if (messages.length === 0) {
|
||||
logger.log('Agent response is empty');
|
||||
return hangup();
|
||||
|
|
@ -98,7 +100,6 @@ export async function POST(request: Request) {
|
|||
to: data.To,
|
||||
from: data.From,
|
||||
projectId,
|
||||
workflowId,
|
||||
messages,
|
||||
createdAt: recvdAt.toISOString(),
|
||||
lastUpdatedAt: new Date().toISOString(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue