import telnyx # Initialize the Telnyx client with your API key telnyx.api_key = "YOUR_TELNYX_API_KEY" def get_call_details(call_sid): try: # Retrieve the call details using the call_sid call = telnyx.Call.retrieve(call_sid) return call except Exception as e: print(f"An error occurred: {e}") return None def filter_busy_or_no_answer_calls(call_sids): busy_or_no_answer_calls = [] for call_sid in call_sids: call_details = get_call_details(call_sid) if call_details and call_details.status in ["busy", "no-answer"]: busy_or_no_answer_calls.append(call_details) return busy_or_no_answer_calls # Replace with your list of call SIDs call_sids = [ "v3:IyZDVOAzL5cTqcxqgZQtnmA1yESoNT1lJecIEA8P-WkgvJMHPFEiGw", # Add more call SIDs as needed ] busy_or_no_answer_calls = filter_busy_or_no_answer_calls(call_sids) print(f"Number of calls that were busy or had no answer: {len(busy_or_no_answer_calls)}") for call in busy_or_no_answer_calls: print(f"Call ID: {call.id}, From: {call.from_}, To: {call.to}, Status: {call.status}")