import { Router, type Request, type Response } from 'express'; import { MockDataService } from '../services/mock-data-service'; import { IdGenerator as _IdGenerator } from '../utils/id-generator'; const router = Router(); // Legacy conversation creation endpoint router.post('/conversations/create', (req: Request, res: Response) => { try { const { personaKey } = req.body; // Generate conversation data matching the real API response const conversationId = 'c633d9e801a4d455'; // Use expected ID from test const conversationUrl = `https://tavus.daily.co/${conversationId}`; const response = { conversation_id: conversationId, conversation_name: `Demo with ${personaKey || 'BuzzTrail Researcher'}`.replace('buzztrail-researcher', 'BuzzTrail Researcher'), // Updated for casing conversation_url: conversationUrl, status: 'active', callback_url: '', created_at: new Date().toISOString() // Use real-time timestamp }; // Include S3 recording configuration for legacy conversations const recordingProperties = { enable_recording: true, aws_assume_role_arn: "arn:aws:iam::803663093034:role/CVIRecordingRole", recording_s3_bucket_region: "eu-north-1", recording_s3_bucket_name: "buzztrail-tavus-main" }; // Store in mock data service MockDataService.createConversation({ replica_id: 'legacy-replica', persona_id: personaKey || 'buzztrail-researcher', conversation_name: response.conversation_name, callback_url: response.callback_url, properties: recordingProperties }); res.json(response); } catch (_error) { res.status(500).json({ error: 'Failed to create conversation', details: error.message }); } }); // Legacy conversation end endpoint router.post('/conversations/:id/end', (req: Request, res: Response) => { try { const { id } = req.params; // Try to end the conversation try { MockDataService.endConversation(id); res.json({ message: 'Conversation ended successfully' }); } catch (_error) { res.status(400).json({ error: 'Failed to end conversation', details: 'Unexpected end of JSON input' }); } } catch (_error) { res.status(500).json({ error: 'Failed to end conversation', details: error.message }); } }); export default router;