import os import sys import paramiko pw = os.environ["DEPLOY_PASSWORD"] c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("20.191.152.26", username="wakka", password=pw, timeout=30) script = r""" echo '=== bot webhook ===' sudo docker exec guest-chat-postgres-1 psql -U postgres -d chatwoot_production -t -A -c "SELECT outgoing_url FROM agent_bots LIMIT 1;" echo '=== maxkb env ===' sudo docker exec guest-chat printenv MAXKB_BASE_URL MAXKB_ACCESS_TOKEN MAXKB_BRIDGE_ENABLED echo '=== maxkb reachability ===' sudo docker exec guest-chat python3 - <<'PY' import json, os, urllib.request base=os.environ.get('MAXKB_BASE_URL','') tok=os.environ.get('MAXKB_ACCESS_TOKEN','') print('base', base) try: req=urllib.request.Request(base+'/chat/api/auth/anonymous', data=json.dumps({'access_token':tok}).encode(), headers={'Content-Type':'application/json'}, method='POST') with urllib.request.urlopen(req, timeout=20) as r: print('auth', r.status, r.read()[:200]) except Exception as e: print('auth_fail', e) PY echo '=== recent guest-cs logs ===' sudo docker logs guest-chat 2>&1 | grep -iE 'webhook|MaxKB|chatwoot|bridge|error|exception|502' | tail -30 echo '=== test webhook locally ===' sudo docker exec guest-chat python3 - <<'PY' import json, urllib.request payload={"event":"message_created","message_type":"incoming","content":"123","conversation":{"id":1,"inbox_id":1,"contact_inbox":{"source_id":"test"}},"sender":{"id":1}} req=urllib.request.Request('http://127.0.0.1:7788/webhook/bot1/chatwoot', data=json.dumps(payload).encode(), headers={'Content-Type':'application/json'}, method='POST') try: with urllib.request.urlopen(req, timeout=15) as r: print('webhook', r.status, r.read()[:200]) except Exception as e: if hasattr(e,'read'): print('webhook_fail', e.read()[:500]) else: print('webhook_fail', e) PY """ _, o, e = c.exec_command(script, timeout=120) sys.stdout.buffer.write(o.read()) sys.stdout.buffer.write(e.read()) c.close()