import urllib.request
import json

API_KEY = "KEY019BE7A3A2D749FCA8681CFF8448A7F0_vTMM1n77CtQxLDT2ra3P1z"
BASE = "https://api.telnyx.com/v2"

def get(path):
    req = urllib.request.Request(
        f"{BASE}{path}",
        headers={"Authorization": f"Bearer {API_KEY}"}
    )
    try:
        resp = urllib.request.urlopen(req, timeout=10)
        return json.loads(resp.read())
    except Exception as e:
        return {"error": str(e)}

# The connection ID from 4377
conn_id = "2895419033639715995"

# Check what this connection is
print("=== Connection Details ===")
r = get(f"/ai/assistants?page[size]=50")
assistants = r.get("data", [])

# Find main assistant and George's assistant
print(f"Total assistants found: {len(assistants)}")
print("\nLooking for George's assistant or main ReceptionistAI assistant...")
for a in assistants:
    aid = a.get("id", "")
    name = a.get("name", "")
    # Check if this is the known assistants
    if "9c42d3ce" in aid or "6f6f4ca2" in aid:
        print(f"\n*** FOUND KNOWN ASSISTANT ***")
        print(f"ID: {aid}")
        print(f"Name: {name}")
        print(json.dumps(a, indent=2))

# Also check connection directly  
print("\n=== Checking connection 2895419033639715995 ===")
r2 = get(f"/connections/{conn_id}")
print(json.dumps(r2, indent=2))
