# OpenBot

<!-- description: Connect Herald to OpenBot: an agent with Herald's MCP tools, a daily delivery routine, and a signed webhook event each time a briefing is published. -->

Status: **MCP verified** (2026-11-29, OpenBot v0.81.1, streamable HTTP with a bearer header).
Webhook push: **documented** (Standard Webhooks signing; follows the official docs, not yet run
against a real install).

Official docs used (OpenBot's docs live in its repository):
[webhooks](https://github.com/nightly-labs/openbot/blob/main/docs/webhooks.md),
[integrations](https://github.com/nightly-labs/openbot/blob/main/docs/architecture/integrations.md),
[glossary](https://github.com/nightly-labs/openbot/blob/main/docs/glossary.md),
[releases](https://github.com/nightly-labs/openbot/releases).

## What you get

- **Pull:** an OpenBot agent with Herald's MCP tools answers questions about today's briefing,
  one category of it or past stories, and can change what you follow.
- **Daily delivery:** an OpenBot routine runs at a fixed time, asks for the briefing and sends
  the answer where you choose.
- **Push:** when Herald publishes, it POSTs a signed event to an OpenBot webhook routine, which
  acts on it right away.

## Pull: MCP

**1. Serve Herald over HTTP.** In Herald's `.env`, set `HERALD_MCP_TOKEN` (16+ characters,
`openssl rand -hex 32`), then:

```bash
uv run herald-mcp --http            # http://127.0.0.1:8765/mcp
```

If OpenBot runs on the same machine as Herald you can use STDIO instead: command
`/path/to/herald/.venv/bin/herald-mcp`, environment `HERALD_CONFIG=/path/to/herald/config.json`.

**2. Add the server in OpenBot.** Use **Add MCP server**:

- Transport: **Streamable HTTP**
- URL: `http://127.0.0.1:8765/mcp`
- Header: `Authorization` = `Bearer <HERALD_MCP_TOKEN>`

This is the combination verified on 2026-11-29. OpenBot masks stored header values for workspace
members.

**3. Give the tools to an agent.** MCP servers are assigned per agent. Give Herald to the agent
that should use it, and tell it which tools to use, read-only first: `herald_briefing`,
`herald_categories`, `herald_history_search`. Add `herald_follow` / `herald_unfollow` only for an
agent that may change what you follow. OpenBot's docs do not describe a per-tool allow list (only
per-server assignment); check your version's docs.

Then ask the agent: "Use herald_briefing for today's Brazilian markets section."

## Daily delivery: scheduled routine

Create a **Routine** for the agent above:

- Schedule: daily, at a time after Herald's run finishes, with your timezone
- Instruction: "Call herald_briefing and send me the five items that matter most, one line each,
  with links."
- **Send answers to:** the channel or chat where you want it

This uses only the MCP connection above, so it needs nothing from the webhook.

## Push: webhook

OpenBot webhook routines accept [Standard Webhooks](https://www.standardwebhooks.com/)
signatures (`webhook-id`, `webhook-timestamp`, `webhook-signature`), which Herald sends with
`auth.type: "standard-webhooks"`. The routine runs as soon as Herald publishes, with the whole
event as its input.

**1. Create the routine.** In the editor of the agent (or channel) that should act, set **When
to run** to **Webhook**, optionally the event type `briefing.published`, and save. OpenBot shows
the routine URL and a signing secret (`whsec_` plus base64) **once**: copy both. Secrets from
older OpenBot versions are base64url; regenerate one for Herald.

Instruction, for example: "A Herald event arrived. If it is briefing.published, send me the five
items that matter most, one line each, with links."

**2. Point Herald at the routine.** In Herald's `.env`: `OPENBOT_WEBHOOK_URL` (the routine URL)
and `OPENBOT_WEBHOOK_SECRET` (the `whsec_` secret). OpenBot rejects bodies over 64 KiB, so cap
Herald there:

<!-- herald-config -->
```json
{
  "type": "webhook",
  "enabled": true,
  "name": "openbot",
  "languages": ["en"],
  "url": "${OPENBOT_WEBHOOK_URL}",
  "auth": { "type": "standard-webhooks", "secret": "${OPENBOT_WEBHOOK_SECRET}" },
  "events": ["briefing.published"],
  "format": "full",
  "max_body_bytes": 65536
}
```

OpenBot needs a JSON object with a string `type`, which Herald's envelope has; the routine gets
the whole body as the event's `data`. A full briefing can pass 64 KiB. When it does, Herald sends
the `markdown` format instead (`{id, type, title, markdown}`), cut at a section boundary and ending
with a link to the full briefing when `site.base_url` is set. If even the header does not fit,
nothing is sent and the run report says so.

OpenBot checks the timestamp within 5 minutes of its clock, so keep both clocks in sync (NTP). It
answers `202` when the routine starts (or the event is filtered out) and `200` for a repeated
`webhook-id`, so Herald's retries never run the routine twice.

## Troubleshooting

| Symptom | Cause |
|---|---|
| OpenBot cannot connect to the server | `herald-mcp --http` not running, or the URL does not end in `/mcp` |
| 401 from Herald | the header is missing `Bearer ` or the token differs from `HERALD_MCP_TOKEN` in Herald's `.env` |
| `herald-mcp --http` exits at start | `HERALD_MCP_TOKEN` unset or shorter than 16 characters |
| The agent does not see Herald's tools | the server is not assigned to that agent |
| `herald_briefing` says no briefing found | Herald has not run yet today, or the routine runs before Herald finishes; move the routine later |
| The routine answers in the wrong language | pass `language` explicitly: "Call herald_briefing with language en" |
| Run report: `webhook:openbot HTTP 401` | the secret differs from the routine's, it is an old base64url secret (regenerate it), or the clocks are more than 5 minutes apart |
| Run report: `webhook:openbot HTTP 404` | the routine was deleted, switched to Schedule, or its URL changed (switching to Webhook again or signing in to another account) |
| Run report: `webhook:openbot HTTP 413` | body over 64 KiB (set `max_body_bytes: 65536`), or the instruction plus the event pass 100,000 characters: shorten the instruction |
| Run report: `auth.secret must be whsec_<base64>` | the secret is not the `whsec_` value OpenBot showed |

## Testing without OpenBot

Check the MCP side with the MCP Inspector before adding the server to OpenBot:

```bash
npx @modelcontextprotocol/inspector
# Transport: Streamable HTTP, URL: http://127.0.0.1:8765/mcp,
# header Authorization: Bearer <HERALD_MCP_TOKEN>; then list tools and call herald_briefing
```

For the push side, point the notifier at `herald dev sink` first. It checks the Standard
Webhooks signature with the same secret (timing-safe, ±5 minutes) and saves each body:

```bash
uv run herald dev sink --port 8787 --standard-webhooks-secret "$OPENBOT_WEBHOOK_SECRET" --out herald-sink
# OPENBOT_WEBHOOK_URL=http://127.0.0.1:8787/ in .env
uv run herald --data-dir /tmp/herald-try run --hours 6
```

Check that the saved body is under 64 KiB. A saved body cannot be replayed to OpenBot with
`curl`: the signature covers the timestamp and expires after five minutes.
