'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 } 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'; 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) { 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