Files
call-center/test_get_summary.py
T

29 lines
1.2 KiB
Python

import urllib.request
import json
import traceback
try:
req = urllib.request.Request(
'http://92.38.48.166:8080/proxy/auth/auth/login',
data=json.dumps({'username': 'admin', 'password': 'admin123'}).encode('utf-8'),
headers={'Content-Type': 'application/json'}
)
token = json.loads(urllib.request.urlopen(req).read().decode()).get('access_token')
headers = {'Authorization': f'Bearer {token}'}
req = urllib.request.Request('http://92.38.48.166:8080/proxy/asterisk-bridge/asterisk/events?limit=250', headers=headers)
events = json.loads(urllib.request.urlopen(req).read().decode())
cids = []
for e in events:
if e['call_id'] not in cids: cids.append(e['call_id'])
for cid in cids[:1]:
summ_req = urllib.request.Request(f'http://92.38.48.166:8080/proxy/asterisk-bridge/asterisk/live-calls/{cid}/ai-summary', headers=headers)
summ = json.loads(urllib.request.urlopen(summ_req).read().decode())
print('Call ID:', cid)
print('Voice Session ID:', summ.get('voice_session_id'))
for t in summ.get('interaction_transcript', []):
print(f"[{t.get('sequence_no', '')}] {t['speaker']}: {t['text']}")
except Exception as e:
traceback.print_exc()