Bot & Automation

jorgasisten

/root/hermes-projects/jorgasisten

create_instance.py text
import http.client
import json

conn = http.client.HTTPConnection("localhost", 8082)
payload = json.dumps({
    "instanceName": "jorgasisten-wa",
    "token": "TokenUnikJorgAsistenWA",
    "qrcode": True,
    "integration": "WHATSAPP-BAILEYS"
})
headers = {
    'apikey': 'ApiKeyJorgAsisten2026',
    'Content-Type': 'application/json'
}
try:
    conn.request("POST", "/instance/create", payload, headers)
    res = conn.getresponse()
    data = res.read()
    response_json = json.loads(data.decode("utf-8"))
    
    # Check if there is a QR code in the response
    qrcode_data = response_json.get("qrcode", {})
    base64_str = qrcode_data.get("base64")
    if base64_str:
        # Save base64 to a file
        with open("/root/hermes-projects/jorgasisten/data/qrcode.txt", "w") as f:
            f.write(base64_str)
        print("SUCCESS: QR code base64 saved to data/qrcode.txt")
    else:
        # Check if instance already exists or returns something else
        print("RESPONSE:", json.dumps(response_json, indent=2))
except Exception as e:
    print("ERROR:", str(e))