'use client'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { createWorkflowFromTemplateApiV1WorkflowCreateTemplatePost, createWorkflowRunApiV1WorkflowWorkflowIdRunsPost } from '@/client/sdk.gen'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader } from '@/components/ui/card'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { useAuth } from '@/lib/auth'; import logger from '@/lib/logger'; import { getRandomId } from '@/lib/utils'; export default function CreateWorkflowPage() { const router = useRouter(); const { user, getAccessToken } = useAuth(); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [showSuccessModal, setShowSuccessModal] = useState(false); const [workflowId, setWorkflowId] = useState(null); const [callType, setCallType] = useState<'INBOUND' | 'OUTBOUND'>('INBOUND'); const [useCase, setUseCase] = useState(''); const [activityDescription, setActivityDescription] = useState(''); const handleCreateWorkflow = async () => { if (!useCase || !activityDescription) { setError('Please fill in all fields'); return; } if (!user) { setError('You must be logged in to create a workflow'); return; } setIsLoading(true); setError(null); try { const accessToken = await getAccessToken(); // Call the API to create workflow from template const response = await createWorkflowFromTemplateApiV1WorkflowCreateTemplatePost({ body: { call_type: callType, use_case: useCase, activity_description: activityDescription, }, headers: { 'Authorization': `Bearer ${accessToken}`, }, }); if (response.data?.id) { setWorkflowId(String(response.data.id)); setShowSuccessModal(true); } } catch (err) { setError('Failed to create workflow. Please try again.'); logger.error(`Error creating workflow: ${err}`); } finally { setIsLoading(false); } }; const handleModalContinue = async () => { if (!workflowId || !user) return; try { const accessToken = await getAccessToken(); const workflowRunName = `WR-${getRandomId()}`; // Create a workflow run const response = await createWorkflowRunApiV1WorkflowWorkflowIdRunsPost({ path: { workflow_id: Number(workflowId), }, body: { mode: 'smallwebrtc', // Same mode as "Web Call" button name: workflowRunName }, headers: { 'Authorization': `Bearer ${accessToken}`, }, }); // Navigate to the workflow run page if (response.data?.id) { router.push(`/workflow/${workflowId}/run/${response.data.id}`); } } catch (err) { logger.error(`Error creating workflow run: ${err}`); // Fallback to workflow page if run creation fails router.push(`/workflow/${workflowId}`); } }; return (

Create Your Voice Agent Workflow

Tell us about your use case and we'll create a customized workflow for you
I want to create an voice agent
For the use case of setUseCase(e.target.value)} />
Which can