Watch a sector
You will build: a job that runs every hour, reads the sector outlooks, and posts to a Slack (or any webhook) channel when a sector’s risk level changes or its direction turns to rising.
You need: a key with intel:read, and a webhook URL for your channel.
What an outlook gives you
Section titled “What an outlook gives you”GET /outlooks returns one reading per sector your workspace follows:
{ "sector": "energy_power", "name": "Energy and power", "quiet": false, "risk_score": 48, "risk_level": "elevated", "previous_score": 61, "direction": "easing", "verdict": "No new Hormuz attack or Tarali ruling emerged in the last 24 hours; …", "drivers": [ { "story_id": 300584, "label": "How Hormuz oil shock is India's chance to reset its energy future", "why": "IEA flags Hormuz disruption as a major supply shock with India central to demand growth" } ]}direction already compares the reading with the one before, so you could post on direction == "rising" alone. Keeping the last level you saw also catches a jump in level that came in two steps between your polls.
A quiet sector had too little reporting to read: its score, level, direction and verdict are null. Skip it.
The job
Section titled “The job”"""Post sector turns to a webhook. Run hourly."""import jsonimport osfrom pathlib import Path
import requests
API = "https://dash.alethman.com/api/v1"HOOK = os.environ["WEBHOOK_URL"]SEEN = Path("outlooks-seen.json")WATCH = {"energy_power", "public_order_unrest"} # empty set: every sector
r = requests.get(f"{API}/outlooks", headers={"Authorization": f"Bearer {os.environ['ALETHMAN_KEY']}"}, timeout=30)r.raise_for_status()seen = json.loads(SEEN.read_text()) if SEEN.exists() else {}
for o in r.json()["data"]: if o["quiet"] or (WATCH and o["sector"] not in WATCH): continue before = seen.get(o["sector"]) turned = before is not None and before != o["risk_level"] if turned or o["direction"] == "rising": drivers = "\n".join(f"• {d['label']}: {d['why']}" for d in o["drivers"][:3]) text = f"*{o['name']}*: {before or '?'} → *{o['risk_level']}* ({o['direction']})\n{o['verdict']}\n{drivers}" requests.post(HOOK, json={"text": text}, timeout=30) seen[o["sector"]] = o["risk_level"]
SEEN.write_text(json.dumps(seen))// Post sector turns to a webhook. Run hourly.import { existsSync, readFileSync, writeFileSync } from "node:fs";
const API = "https://dash.alethman.com/api/v1";const SEEN = "outlooks-seen.json";const WATCH = new Set(["energy_power", "public_order_unrest"]); // empty: every sector
const res = await fetch(`${API}/outlooks`, { headers: { Authorization: `Bearer ${process.env.ALETHMAN_KEY}` } });if (!res.ok) throw new Error((await res.json()).error.message);const seen = existsSync(SEEN) ? JSON.parse(readFileSync(SEEN, "utf8")) : {};
for (const o of (await res.json()).data) { if (o.quiet || (WATCH.size && !WATCH.has(o.sector))) continue; const before = seen[o.sector]; const turned = before !== undefined && before !== o.risk_level; if (turned || o.direction === "rising") { const drivers = o.drivers.slice(0, 3).map((d) => `• ${d.label}: ${d.why}`).join("\n"); const text = `*${o.name}*: ${before ?? "?"} → *${o.risk_level}* (${o.direction})\n${o.verdict}\n${drivers}`; await fetch(process.env.WEBHOOK_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text }) }); } seen[o.sector] = o.risk_level;}writeFileSync(SEEN, JSON.stringify(seen));The first run only records what it sees (except sectors already rising); after that, it posts on change.
Going further
Section titled “Going further”- Link the drivers. Each driver’s
story_idopens withGET /stories/{id}, or in the dashboard. - Add the forecasts.
open_forecastscounts the sector’s open forecasts;GET /forecasts?sector=…&status=openlists them. - Watch states as well as sectors. Poll
GET /stories?state=…&order=risk&hours=24and post stories athighor above that you have not posted before (keep their ids).