from .webhook_manager import WebhookManager import logging from datetime import datetime import uuid logger = logging.getLogger(__name__) class CallProcessor: def __init__(self, customer): self.customer = customer self.webhook_manager = WebhookManager(customer) def process_and_send_call(self, audio_file, caller_number, called_number): """Process call and send results to customer's webhook""" try: # Generate a unique call ID call_id = str(uuid.uuid4()) # Process the call (transcription, summary, sentiment) # This is where you would integrate with your existing call processing logic # For now, we'll use placeholder data call_data = { 'id': call_id, 'caller_number': caller_number, 'called_number': called_number, 'transcription': "Sample transcription...", # Replace with actual transcription 'summary': "Sample summary...", # Replace with actual summary 'sentiment': "positive", # Replace with actual sentiment 'keywords': "sample, keywords" # Replace with actual keywords } # Send to customer's webhook success = self.webhook_manager.send_call_results(call_data) if success: logger.info(f"Successfully processed and sent call {call_id} for customer {self.customer.id}") return call_data else: logger.warning(f"Failed to send call results to webhook for customer {self.customer.id}") return None except Exception as e: logger.error(f"Failed to process and send call for customer {self.customer.id}: {str(e)}") raise def get_call_details(self, call_id): """Get call details from customer's database""" try: return self.db_manager.get_call_record(call_id) except Exception as e: logger.error(f"Failed to get call details for call {call_id}: {str(e)}") raise def search_calls(self, filters=None): """Search calls in customer's database""" try: return self.db_manager.search_call_records(filters) except Exception as e: logger.error(f"Failed to search calls for customer {self.customer.id}: {str(e)}") raise