-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_api.py
More file actions
71 lines (60 loc) · 1.82 KB
/
stop_api.py
File metadata and controls
71 lines (60 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# stop_api.py
# Stop the conversational AI agent
import base64
import requests
import sys
from config import CUSTOMER_KEY, CUSTOMER_SECRET, APP_ID
# ==========================
# AGENT ID (Update this!)
# ==========================
# Copy the agent_id from join_api.py output
AGENT_ID = "A42AC47HM54EV67MM93MC94VN86NR36T"
# ==========================
# Base64 encode credentials
# ==========================
raw = f"{CUSTOMER_KEY}:{CUSTOMER_SECRET}"
BASIC = base64.b64encode(raw.encode()).decode()
# ==========================
# Stop Agent URL
# ==========================
url = f"https://api.agora.io/api/conversational-ai-agent/v2/projects/{APP_ID}/agents/{AGENT_ID}/leave"
headers = {
"Authorization": f"Basic {BASIC}",
"Content-Type": "application/json"
}
# ==========================
# Validation
# ==========================
if AGENT_ID == "YOUR_AGENT_ID_HERE":
print("=" * 50)
print("❌ ERROR: Please update AGENT_ID first!")
print("=" * 50)
print("\n📝 Steps:")
print("1. Run join_api.py")
print("2. Copy the agent_id from the output")
print("3. Paste it in stop_api.py (line 11)")
print("4. Run stop_api.py again")
print("=" * 50)
sys.exit(1)
# ==========================
# SEND REQUEST
# ==========================
print("=" * 50)
print("🛑 Stopping AI Agent...")
print("=" * 50)
print(f"Agent ID: {AGENT_ID}")
print("=" * 50)
response = requests.post(url, headers=headers)
print("\n📊 Response:")
print("-" * 50)
print("Status Code:", response.status_code)
if response.status_code == 200:
print("\n✅ SUCCESS!")
print("Agent stopped and left the channel")
else:
print("\n❌ FAILED!")
try:
print("Error:", response.json())
except:
print("Error:", response.text)
print("\n" + "=" * 50)