|
| 1 | +--- |
| 2 | +title: "OpenClaw (ClawdBot) with Trigger.dev" |
| 3 | +sidebarTitle: "OpenClaw" |
| 4 | +icon: "sparkles" |
| 5 | +description: "Run OpenClaw autonomous AI agent workflows as durable, observable tasks using Trigger.dev." |
| 6 | +--- |
| 7 | + |
| 8 | +[OpenClaw](https://docs.clawd.bot/) (formerly ClawdBot) is an open-source autonomous AI agent that connects to messaging platforms (WhatsApp, Slack, Discord, etc.), runs shell commands, and can use Claude, GPT, or local models. Combined with Trigger.dev, you get durable execution, retries, and full observability when running OpenClaw workflows from your backend or on a schedule. |
| 9 | + |
| 10 | +## Why use Trigger.dev with OpenClaw? |
| 11 | + |
| 12 | +- **Durable runs** – Agent workflows run as tasks; if something fails, Trigger.dev retries and you keep a full run history. |
| 13 | +- **Trigger from anywhere** – Invoke OpenClaw skills or chat from HTTP, webhooks, cron, or other tasks. |
| 14 | +- **Observability** – Logs, metadata, and run status in the Trigger.dev dashboard. |
| 15 | + |
| 16 | +## Setup |
| 17 | + |
| 18 | +<Note> |
| 19 | + This guide assumes you have an existing [Trigger.dev](https://trigger.dev) project. Follow our [quickstart](/quick-start) if you don't yet. |
| 20 | +</Note> |
| 21 | + |
| 22 | +<Steps> |
| 23 | + |
| 24 | +<Step title="Run OpenClaw"> |
| 25 | + |
| 26 | +OpenClaw typically runs as a local or self-hosted service. Install and run it following the [OpenClaw docs](https://docs.clawd.bot/install). Ensure the API is reachable (e.g. `https://your-openclaw.local:3000` or your deployed URL). |
| 27 | + |
| 28 | +</Step> |
| 29 | + |
| 30 | +<Step title="Create a task that calls the OpenClaw API"> |
| 31 | + |
| 32 | +Use Trigger.dev tasks to call OpenClaw's HTTP API (e.g. execute a skill or send a chat). This gives you retries, logging, and triggers from schedules or webhooks: |
| 33 | + |
| 34 | +```ts trigger/openclaw-agent.ts |
| 35 | +import { task } from "@trigger.dev/sdk"; |
| 36 | + |
| 37 | +const OPENCLAW_BASE_URL = process.env.OPENCLAW_BASE_URL!; // e.g. https://your-openclaw.local:3000 |
| 38 | +const OPENCLAW_API_KEY = process.env.OPENCLAW_API_KEY!; |
| 39 | + |
| 40 | +export const runOpenClawSkill = task({ |
| 41 | + id: "run-openclaw-skill", |
| 42 | + run: async (payload: { skill: string; params?: Record<string, unknown> }) => { |
| 43 | + const res = await fetch(`${OPENCLAW_BASE_URL}/api/v1/skills/${payload.skill}/execute`, { |
| 44 | + method: "POST", |
| 45 | + headers: { |
| 46 | + "Content-Type": "application/json", |
| 47 | + Authorization: `Bearer ${OPENCLAW_API_KEY}`, |
| 48 | + }, |
| 49 | + body: JSON.stringify(payload.params ?? {}), |
| 50 | + }); |
| 51 | + |
| 52 | + if (!res.ok) { |
| 53 | + throw new Error(`OpenClaw skill failed: ${res.status} ${await res.text()}`); |
| 54 | + } |
| 55 | + |
| 56 | + return res.json(); |
| 57 | + }, |
| 58 | +}); |
| 59 | +``` |
| 60 | + |
| 61 | +</Step> |
| 62 | + |
| 63 | +<Step title="Add environment variables"> |
| 64 | + |
| 65 | +In the [Trigger.dev dashboard](https://cloud.trigger.dev) (or your `.env` for local dev), set: |
| 66 | + |
| 67 | +- `OPENCLAW_BASE_URL` – Your OpenClaw instance URL (e.g. `https://your-openclaw.local:3000`). |
| 68 | +- `OPENCLAW_API_KEY` – Your OpenClaw API key (see [OpenClaw authentication](https://docs.clawd.bot/gateway/authentication)). |
| 69 | + |
| 70 | +</Step> |
| 71 | + |
| 72 | +<Step title="Trigger the task"> |
| 73 | + |
| 74 | +From your app, on a schedule, or from a webhook: |
| 75 | + |
| 76 | +```ts |
| 77 | +import { runOpenClawSkill } from "@/trigger/openclaw-agent"; |
| 78 | + |
| 79 | +await runOpenClawSkill.trigger({ skill: "my-skill", params: { input: "hello" } }); |
| 80 | +``` |
| 81 | + |
| 82 | +</Step> |
| 83 | + |
| 84 | +</Steps> |
| 85 | + |
| 86 | +## OpenClaw API overview |
| 87 | + |
| 88 | +OpenClaw exposes REST endpoints you can call from Trigger.dev tasks: |
| 89 | + |
| 90 | +| Endpoint | Description | |
| 91 | +| -------- | ----------- | |
| 92 | +| `POST /api/v1/skills/{skill}/execute` | Execute a skill | |
| 93 | +| `POST /api/v1/assistant/chat` | Send a message to the assistant | |
| 94 | +| `GET /api/v1/skills` | List available skills | |
| 95 | +| `GET /api/v1/status` | Check status | |
| 96 | + |
| 97 | +See the [OpenClaw API docs](https://getclawdbot.org/docs/api) (or [OpenClaw gateway docs](https://docs.clawd.bot/gateway/openresponses-http-api)) for request/response formats and authentication. |
| 98 | + |
| 99 | +## Building skills with the SDK |
| 100 | + |
| 101 | +To build custom skills that OpenClaw can run, use the `@clawdbot/sdk` (or OpenClaw skills SDK). You can run skill logic inside a Trigger task as well—for example, call external APIs or write to your DB from a task that implements the same behavior as a skill. |
| 102 | + |
| 103 | +## Learn more |
| 104 | + |
| 105 | +- [OpenClaw docs](https://docs.clawd.bot/) – Installation, Node.js, and gateway APIs |
| 106 | +- [Trigger.dev Realtime](/realtime/overview) – Stream task progress to your frontend |
| 107 | +- [Scheduled tasks](/tasks/scheduled) – Run OpenClaw workflows on a cron schedule |
0 commit comments