'use client'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { createWorkflowFromTemplateApiV1WorkflowCreateTemplatePost } from '@/client/sdk.gen'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Textarea } from '@/components/ui/textarea'; import { useAuth } from '@/lib/auth'; import logger from '@/lib/logger'; 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 = () => { if (!workflowId) return; router.push(`/workflow/${workflowId}?onboarding=web_call`); }; return (

Create Voice Agent

Tell us about your use case and we'll create a customized voice agent for you

Agent Details Configure your voice agent settings

Choose whether users will call your AI or your AI will call users

setUseCase(e.target.value)} />

Describe the primary purpose of your voice agent