Skip to content

Automation & agent integration

Two complete, copy-paste-able automations, followed by guidance for agent builders. Both use only the standard library / requests so they drop into any environment.

import requests
BASE = "https://dashboard.insightai.pro/api/v1" # or your own instance
MODEL = "llama3.2"
session = requests.Session()
def signin(email: str, password: str) -> None:
r = session.post(f"{BASE}/signin", json={"email": email, "password": password})
r.raise_for_status() # session now carries the auth cookie
def ask(question: str, chat_id: str | None = None, timeout: int = 300) -> tuple[str, str]:
"""Ask a question; returns (chat_id, answer). Reuse chat_id for follow-ups."""
if chat_id is None:
r = session.post(f"{BASE}/chats",
json={"model_name": MODEL, "message": question},
timeout=timeout)
r.raise_for_status()
chat = r.json()
return chat["id"], chat["messages"][-1]["content"]
r = session.post(f"{BASE}/chats/{chat_id}/followup",
json={"model_name": MODEL, "message": question},
timeout=timeout)
r.raise_for_status()
return chat_id, r.json()[-1]["content"]
signin("you@example.com", "YourPass123")
chat_id, answer = ask("What does our expense policy say about pre-approval?")
print(answer)
_, followup = ask("What's the receipt deadline?", chat_id)
print(followup)

Notes that matter in practice:

  • Generous timeouts. The blocking endpoints return only when the answer is fully generated. If you’d rather show progress, the streaming endpoints deliver the reply as NDJSON tokens.
  • Handle 401 by re-signing-in — tokens last 24 hours.
  • Answers are grounded in whatever indexed collections the account can access. Pass collection_ids when creating the chat (or PUT /chats/{id}/collections later) to narrow retrieval to specific collections.
  • The generating response carries a sources array — the retrieved chunks with file paths and similarity scores. Capture it then if you want citations: sources aren’t persisted, so re-reading the chat later returns them empty.

Content on a file share drifts; a nightly re-run keeps the knowledge base current. Pair this with cron:

import time, requests
BASE = "https://dashboard.insightai.pro/api/v1"
PIPELINE = "<pipeline_id>"
session = requests.Session()
session.post(f"{BASE}/signin",
json={"email": "svc@example.com", "password": ""}).raise_for_status()
r = session.post(f"{BASE}/data_pipelines/{PIPELINE}/ingest")
if r.status_code == 409:
raise SystemExit("a run is already in progress")
r.raise_for_status()
while True:
s = session.get(f"{BASE}/data_pipelines/{PIPELINE}/ingest/status").json()
if s["status"] == "completed":
print(f"done: {s['entities_processed']} files indexed")
break
if s["status"] == "failed":
raise SystemExit(f"failed: {s['error_message']}")
time.sleep(10)

Remember each run rebuilds the collection from scratch — schedule runs when a briefly incomplete index is acceptable, and don’t overlap pipelines that share a collection (they shouldn’t share one at all).

The chat endpoint makes Insight AI a natural tool for an agent: a “company knowledge” function the agent can call when a task needs internal context. The pattern:

  1. Expose one function to your agent, e.g. search_company_knowledge(question: str) -> str, implemented exactly like ask() above with a fresh chat per call (stateless) or a persistent chat_id per agent session (conversational memory on the Insight side).
  2. Describe it honestly in the tool description: “Answers questions using the organization’s indexed documents (policies, reports, shared drives).” Agents make better call decisions when the description matches reality. If your tool surfaces the sources array alongside the answer, say so — file paths and similarity scores give the agent something to cite and a way to judge retrieval quality.
  3. Pick a capable model for the model_name — the quality of tool results is bounded by the model answering them.
  4. Treat answers as evidence, not ground truth. Retrieval is best-effort similarity search; have the agent verify critical figures against the source documents where it matters.

For heavier integrations (ingest-on-demand, provisioning, model management), everything in the resource map is available — the dashboard has no private APIs.