Python integration (HTTP)
Use requests or httpx against the same dashboard and workflow APIs as the CLI and TypeScript SDK—no separate PyPI package in this repo.
Python integration (HTTP)
There is no published wisebotai Python package in this monorepo. Integrations use requests, httpx, or urllib against the same HTTPS contracts as:
- Wisebot CLI and HTTP API —
GET /api/v1/…andwisebot workflow trigger - TypeScript SDK —
POST /api/v1/agents, streaming/api/chat/agent,POST /api/v1/flow/{id}
Use environment variables the same way as the CLI: WISEBOTAI_BASE_URL + WISEBOT_ACCESS_TOKEN / WISE_KEY for dashboard APIs, and WISEBOT_WORKFLOW_TRIGGER_ORIGIN + WISEBOT_WORKFLOW_SECRET for workflow POST (see two contexts).
pip install requests
# or: pip install httpxDashboard API examples (requests)
Set:
import os
import requests
BASE = os.environ["WISEBOTAI_BASE_URL"].rstrip("/")
TOKEN = os.environ.get("WISEBOT_ACCESS_TOKEN") or os.environ["WISE_KEY"]
H = {"Authorization": f"Bearer {TOKEN}"}GET /api/v1/status (same as wisebot status)
r = requests.get(f"{BASE}/api/v1/status", headers=H, timeout=60)
r.raise_for_status()
print(r.json())GET /api/v1/agents (same as wisebot agents list)
r = requests.get(f"{BASE}/api/v1/agents", headers=H, timeout=60)
r.raise_for_status()
print(r.json())GET /api/v1/activity (same as wisebot logs --tail)
Optional query: limit between 1 and 50 (default 15 if omitted). The CLI currently uses limit=20.
r = requests.get(f"{BASE}/api/v1/activity", params={"limit": 20}, headers=H, timeout=60)
r.raise_for_status()
data = r.json()
for line in data.get("lines") or []:
print(line)GET /api/v1/api-keys (same as wisebot api-keys list)
Requires a dashboard JWT — wb_live_ API keys return 401.
r = requests.get(f"{BASE}/api/v1/api-keys", headers=H, timeout=60)
r.raise_for_status()
print(r.json())GET /api/v1/webhooks (same as wisebot webhooks list)
r = requests.get(f"{BASE}/api/v1/webhooks", headers=H, timeout=60)
r.raise_for_status()
print(r.json())POST /api/v1/agents (create agent — same contract as TypeScript SDK)
Body: name, model, optional tools array (e.g. image_search, knowledge_base with label, MCP connector stubs).
body = {
"name": "Python-created agent",
"model": "gpt-4o-mini",
"tools": [{"type": "image_search"}],
}
r = requests.post(
f"{BASE}/api/v1/agents",
headers={**H, "Content-Type": "application/json"},
json=body,
timeout=120,
)
r.raise_for_status()
print(r.json())GET /api/v1/knowledge-files (list — same as client.knowledge.list)
r = requests.get(
f"{BASE}/api/v1/knowledge-files",
params={"limit": 25},
headers=H,
timeout=60,
)
r.raise_for_status()
for f in r.json().get("files") or []:
print(f["name"], f.get("status"))POST /api/v1/knowledge-files (upload — same as client.knowledge.upload)
with open("refund-policy.pdf", "rb") as fh:
r = requests.post(
f"{BASE}/api/v1/knowledge-files",
headers=H,
files={"file": ("refund-policy.pdf", fh, "application/pdf")},
data={"folderPath": "Legal"},
timeout=300,
)
r.raise_for_status()
print(r.json()) # name, urlPOST /api/v1/agents with knowledge by filename
Use label (filename), not internal ids — the server resolves before create:
body = {
"name": "Support bot",
"model": "gpt-4o-mini",
"tools": [
{"type": "knowledge_base", "config": {"label": "refund-policy.pdf"}},
],
}
r = requests.post(
f"{BASE}/api/v1/agents",
headers={**H, "Content-Type": "application/json"},
json=body,
timeout=120,
)
r.raise_for_status()POST /api/v1/flow/{workflow_id} (dashboard API — same as client.workflows.run)
Auth: JWT or wb_live_ key. Body: { "inputs": { "fieldName": "value" } } — keys match Input steps.
workflow_id = "your_workflow_id"
r = requests.post(
f"{BASE}/api/v1/flow/{workflow_id}",
headers={**H, "Content-Type": "application/json"},
json={"inputs": {"message": "from Python"}},
timeout=300,
)
r.raise_for_status()
print(r.json()) # ok, runId, result, errorGET /api/v1/knowledge-files/resolve (advanced / debug only)
Prefer attaching knowledge by label (filename) at agent create time.
label = "my-doc.pdf"
r = requests.get(
f"{BASE}/api/v1/knowledge-files/resolve",
params={"label": label},
headers=H,
timeout=60,
)
r.raise_for_status()
print(r.json()) # fileId, matchedByPlayground endpoints (/api/v1/playground/*) require a dashboard JWT. Use wisebot playground … commands — see Wisebot CLI.
POST /api/v1/chat/sessions (visitor session — same as client.chat.createSession)
Creates or resumes a billable visitor session for server integrations. Auth: JWT or wb_live_ API key.
body = {
"externalUserId": "user_42",
"name": "Jane Doe", # optional
# "agentId": "...", # optional
# "forceNew": True, # optional
}
r = requests.post(
f"{BASE}/api/v1/chat/sessions",
headers={**H, "Content-Type": "application/json"},
json=body,
timeout=60,
)
r.raise_for_status()
session = r.json()
# session: contactSessionId, conversationId, threadId, greetingMessageResume: GET /api/v1/chat/sessions?externalUserId=user_42 → { "session": … } or 404.
Streaming chat (POST /api/chat/agent, SSE)
The widget and TypeScript SDK use Server-Sent Events (text/event-stream). In Python, stream the body and parse data: lines until [DONE].
import json
import requests
body = {
"prompt": "Hello!",
"threadId": "<thread-uuid>",
"contactSessionId": "<session-uuid>",
}
with requests.post(
f"{BASE}/api/chat/agent",
headers={**H, "Content-Type": "application/json"},
json=body,
stream=True,
timeout=120,
) as r:
r.raise_for_status()
for line in r.iter_lines(decode_unicode=True):
if not line or not line.startswith("data:"):
continue
data = line[5:].strip()
if data == "[DONE]":
break
try:
evt = json.loads(data)
if evt.get("type") == "finish":
print(evt.get("fullText"))
if evt.get("type") == "error":
print("error:", evt.get("message"))
except json.JSONDecodeError:
passFor production, prefer httpx streaming or a small SSE library; the important part is the URL, JSON body, and Bearer header.
Workflow webhook (POST /workflows/trigger)
Same as Triggering workflows and wisebot workflow trigger: different origin and secret, not WISEBOTAI_BASE_URL.
import os
import requests
ORIGIN = os.environ["WISEBOT_WORKFLOW_TRIGGER_ORIGIN"].rstrip("/")
SECRET = os.environ["WISEBOT_WORKFLOW_SECRET"]
WF_ID = "your_workflow_id"
url = f"{ORIGIN}/workflows/trigger"
params = {"workflowId": WF_ID}
payload = {"message": "from Python"} # keys must match Input steps
r = requests.post(
url,
params=params,
headers={
"Authorization": f"Bearer {SECRET}",
"Content-Type": "application/json",
},
json=payload,
timeout=120,
)
r.raise_for_status()
print(r.text)Related
- Wisebot CLI and HTTP API — Full
wisebotcommand reference (every subcommand) - TypeScript SDK (
@wisebotai/sdk) — Typed helpers for agents, chat stream, playground, workflows - Triggering workflows (HTTPS & CLI) — Webhook
POST, dashboard/api/v1/flow, and CLI