import os, httpx
API_KEY = os.environ["ONTORA_API_KEY"]
client = httpx.Client(
base_url="https://api.ontora.com",
headers={"X-API-Key": API_KEY},
timeout=30.0,
)
# 1. Create the campaign
campaign = client.post("/v1/interviews", json={
"name": "Q2 facility-ops interviews",
"goal": "Map current scheduling workflows",
"channel": "in_app_chat",
"topics": [
{
"name": "Daily scheduling",
"goal": "Understand how shifts are assigned",
"priority": "high",
"questions": [
"Walk me through how this morning's shift assignment happened.",
],
},
],
}).raise_for_status().json()
interview_id = campaign["id"]
print(f"Created campaign {interview_id}")
# 2. Add contacts
client.post(f"/v1/interviews/{interview_id}/contacts/bulk", json={
"contacts": [
{"name": "Sam Rivera", "email": "sam@example.com", "department": "Operations"},
{"name": "Jess Thompson", "email": "jess@example.com", "department": "Operations"},
],
}).raise_for_status()
# 3. Start the campaign
client.post(f"/v1/interviews/{interview_id}/start").raise_for_status()
print("Campaign started — sit back and wait for synthesis.completed")