Skip to content

Commit d5e9e26

Browse files
ericallamTrigger.dev RepoOps
authored andcommitted
docs: rework the introduction around chat.agent, webhooks and production
Reworked the docs introduction around building agents with `chat.agent`, webhooks, and running in production, with an expanded FAQ. Mono-RevId: b79d3f40d91d699c56406a750855012dca05262b
1 parent 2e4dd94 commit d5e9e26

2 files changed

Lines changed: 106 additions & 26 deletions

File tree

‎docs/ai-chat/overview.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ A `chat.agent` task takes `messages`, calls `streamText`, and returns the result
1212

1313
```ts trigger/chat.ts
1414
import { chat } from "@trigger.dev/sdk/ai";
15-
import { streamText, stepCountIs } from "ai";
15+
import { stepCountIs } from "ai";
1616
import { anthropic } from "@ai-sdk/anthropic";
1717

1818
export const myChat = chat.agent({
1919
id: "my-chat",
20-
run: async ({ messages, signal }) =>
20+
run: async ({ messages, signal, streamText }) =>
2121
streamText({
2222
model: anthropic("claude-sonnet-4-5"),
2323
messages,

‎docs/introduction.mdx‎

Lines changed: 104 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Trigger.dev docs"
33
sidebarTitle: "Introduction"
4-
description: "Build and run durable AI agents and workflows in TypeScript. Long-running tasks with retries, queues, observability, and elastic scaling. Open source and self-hostable."
4+
description: "Build and run durable AI agents and workflows in TypeScript. Long-running tasks with retries, queues, webhooks, observability, and elastic scaling. Open source and self-hostable."
55
mode: "center"
66
---
77

@@ -11,8 +11,8 @@ import AgentSetupPrompt from "/snippets/agent-setup-prompt.mdx";
1111
<Card title="Quick start" icon="rocket" href="/quick-start" color="#A8FF53">
1212
Go from zero to your first task in 3 minutes.
1313
</Card>
14-
<Card title="Build AI agents" icon="robot" href="/guides/ai-agents/overview" color="#a855f7">
15-
Agent patterns, worked examples, and the tools to run them in production.
14+
<Card title="Build AI agents" icon="robot" href="/ai-chat/overview" color="#a855f7">
15+
Durable, multi-turn agents with `chat.agent`, from your frontend to Slack and Linear.
1616
</Card>
1717
<Card title="AI coding assistants" icon="wand-magic-sparkles" href="/building-with-ai" color="#3B82F6">
1818
Let Claude Code, Cursor and Windsurf write correct Trigger.dev code with the MCP server, Skills and rules.
@@ -28,48 +28,124 @@ import AgentSetupPrompt from "/snippets/agent-setup-prompt.mdx";
2828

2929
## What is Trigger.dev?
3030

31-
Trigger.dev is the open source platform for building and running durable AI agents and workflows in TypeScript. Run them for hours, configure automatic retries, control concurrency, and manage queues. There's no execution timeout, and no queue or worker infrastructure for you to build.
31+
Trigger.dev is the open source platform for building and running durable AI agents and workflows in TypeScript. You write tasks and agents in your existing codebase, and they run on Trigger.dev with retries, queues, waits, full tracing, and elastic scaling. There's no execution timeout, and no queue or worker infrastructure for you to build.
3232

33-
You write agents and tasks in your existing codebase using our CLI and SDK, and get durable execution, queues, waits, full tracing, and elastic scaling without building any of it yourself.
33+
Trigger.dev's core is Apache-2.0 licensed. [Self-host it](/self-hosting/overview) on your own infrastructure, or let [Trigger.dev Cloud](https://cloud.trigger.dev) run it for you.
3434

35-
Trigger.dev's core is Apache-2.0 licensed, a genuine OSI license. [Self-host it](/self-hosting/overview) on your own infrastructure, or let [Trigger.dev Cloud](https://cloud.trigger.dev) run it for you.
35+
## Build agents with `chat.agent`
3636

37-
## Core concepts
37+
A `chat.agent` runs each conversation as one durable task. It wakes when a message arrives and idles between turns, and its state survives page refreshes, deploys, and crashes. Turn lifecycle, resuming a stream mid-reply, and approvals are handled for you, and your frontend connects with the AI SDK's `useChat`, with no API routes to write.
38+
39+
```ts trigger/chat.ts
40+
import { chat } from "@trigger.dev/sdk/ai";
41+
import { anthropic } from "@ai-sdk/anthropic";
42+
43+
export const supportAgent = chat.agent({
44+
id: "support-agent",
45+
run: async ({ messages, signal, streamText }) =>
46+
streamText({
47+
model: anthropic("claude-sonnet-4-5"),
48+
messages,
49+
abortSignal: signal,
50+
}),
51+
});
52+
```
53+
54+
<CardGroup cols={3}>
55+
<Card title="Agent quick start" icon="rocket" href="/ai-chat/quick-start">
56+
Build a chat agent and its frontend end to end.
57+
</Card>
58+
<Card title="Sessions" icon="layer-group" href="/ai-chat/sessions">
59+
Each conversation's durable state and two-way stream, across all its runs.
60+
</Card>
61+
<Card title="Tools" icon="screwdriver-wrench" href="/ai-chat/tools">
62+
Declare tools on your agent and get them back typed in `run()`.
63+
</Card>
64+
<Card title="Human in the loop" icon="hand" href="/ai-chat/patterns/human-in-the-loop">
65+
Pause a tool call for approval and resume when a person decides.
66+
</Card>
67+
<Card title="Slack agents" icon="slack" href="/webhooks/slack">
68+
Turn an agent into a native Slack agent with `@trigger.dev/slack`.
69+
</Card>
70+
<Card title="Linear agents" icon="list-check" href="/webhooks/linear">
71+
Assign Linear issues to an agent with `@trigger.dev/linear`.
72+
</Card>
73+
</CardGroup>
74+
75+
Version your [prompts](/ai/prompts) in code and change them from the dashboard, and see every model step and tool call, with tokens, cost and latency, in [AI observability](/ai/observability).
76+
77+
## Run work
3878

3979
<CardGroup cols={2}>
4080
<Card title="Writing tasks" icon="pen-to-square" href="/tasks/overview" color="#A8FF53">
41-
The durable functions at the core of Trigger.dev. Write them in your existing codebase, with retries and no timeouts.
81+
The durable functions at the core of Trigger.dev, written in your existing codebase.
4282
</Card>
4383
<Card title="Triggering tasks" icon="bullseye-pointer" href="/triggering" color="#3b82f6">
44-
Trigger a task from your backend, your frontend, a schedule, or another task.
84+
Trigger a task from your backend, your frontend, or another task.
4585
</Card>
4686
<Card title="Runs" icon="play" href="/runs" color="#28bf5c">
47-
Every execution of a task is a run, with its status, retries, and logs recorded.
87+
Every execution of a task is a run, with its status, retries, logs and trace.
88+
</Card>
89+
<Card title="Realtime" icon="bolt" href="/realtime/overview" color="#F43F5E">
90+
Stream run status and LLM output to your frontend with React hooks.
91+
</Card>
92+
</CardGroup>
93+
94+
## React to events
95+
96+
<CardGroup cols={2}>
97+
<Card title="Webhooks" icon="webhook" href="/webhooks/overview" color="#a855f7">
98+
Hosted, verified endpoints for Stripe, GitHub and more, delivered to your tasks and agents.
99+
</Card>
100+
<Card title="Scheduled tasks" icon="clock" href="/tasks/scheduled" color="#f6cd46">
101+
Run a task on a cron schedule, with timezone support.
102+
</Card>
103+
<Card title="Webhook waiters" icon="bell" href="/webhooks/waiters" color="#3b82f6">
104+
Pause a run until a matching webhook arrives, like a payment confirmation.
48105
</Card>
49-
<Card title="Idempotency" icon="fingerprint" href="/idempotency" color="#F43F5E">
50-
Use an idempotency key so a retried or duplicated trigger runs once, not twice.
106+
<Card title="Waits" icon="hourglass" href="/wait" color="#28bf5c">
107+
Pause a run for a duration, until a date, or until a token is completed. A waiting run doesn't use compute.
51108
</Card>
52109
</CardGroup>
53110

54-
## Build with agents
111+
## Run in production
55112

56-
Build durable, multi-turn agents with the [chat agent](/ai-chat/overview): one long-running task per conversation, with the tools it can call, streaming, and resumability handled for you. Add human-in-the-loop approval by pausing a run on a [waitpoint](/wait-for-token) until a person signs off, and a waiting run doesn't consume compute. Stream run status and LLM output straight to your frontend with the [Realtime API](/realtime/overview) and React hooks, and record your Vercel AI SDK calls as spans with the model, token counts, cost and latency using [AI observability](/ai/observability). Version your [prompts](/ai/prompts) in code, then edit the text or swap the model from the dashboard without redeploying.
113+
<CardGroup cols={2}>
114+
<Card title="Queues & concurrency" icon="layer-group" href="/queues" color="#3b82f6">
115+
Control how many runs execute at once, globally or per tenant.
116+
</Card>
117+
<Card title="Machines" icon="microchip" href="/machines" color="#a855f7">
118+
Choose the CPU and memory each task runs on.
119+
</Card>
120+
<Card title="Deployment" icon="cloud-arrow-up" href="/deployment/overview" color="#28bf5c">
121+
Atomic, versioned deploys, with preview branches and environments.
122+
</Card>
123+
<Card title="Errors & retries" icon="arrows-rotate" href="/errors-retrying" color="#F43F5E">
124+
Retry failed attempts automatically, and decide what happens when a task throws.
125+
</Card>
126+
<Card title="Logs, traces & metrics" icon="chart-line" href="/logging" color="#f6cd46">
127+
A full trace of every run, with your logs and spans.
128+
</Card>
129+
<Card title="Query & dashboards" icon="table" href="/observability/query" color="#A8FF53">
130+
Query your runs with TRQL, and build dashboards from the results.
131+
</Card>
132+
</CardGroup>
57133

58-
## Scale and scheduling
134+
## Frequently asked questions
59135

60-
Set how many runs of a task execute at once, globally or per tenant, with [concurrency](/concurrency) and [queues](/queues). Run a task on a [cron schedule](/tasks/scheduled) with timezone support, choose the CPU and memory each task runs on with [machines](/machines), and control what happens when a task throws with [errors and retries](/errors-retrying).
136+
**Can I use Trigger.dev for background jobs, not just AI?** Yes. The same durable tasks, queues, retries, and [cron schedules](/tasks/scheduled) run any background job or workflow, with or without AI.
61137

62-
## Self-hosting
138+
**How long can a run take?** As long as it needs. Runs have no maximum duration by default, and you can set a [`maxDuration`](/runs/max-duration) for a project, a task, or a single run to cap it.
63139

64-
Trigger.dev is open source and you can self-host. Read the [overview guide](/self-hosting/overview), or how to do it with [Docker](/self-hosting/docker) or [Kubernetes](/self-hosting/kubernetes).
140+
**Do my serverless function timeouts apply?** No. Tasks run on Trigger.dev, not inside your serverless functions, so your platform's function timeout isn't in the execution path. Your backend triggers the task and returns.
65141

66-
## Frequently asked questions
142+
**Can I receive webhooks without running a server?** Yes. Declare a [webhook endpoint](/webhooks/overview) in your code, and Trigger.dev hosts its URL, verifies each request, and delivers the event to your tasks and agents.
67143

68-
**How do I add human-in-the-loop approval to an agent?** Pause the run on a [waitpoint](/wait-for-token) until a person approves the action. A waiting run doesn't consume compute, so it can wait minutes or days.
144+
**How do I add human-in-the-loop approval?** Pause the run on a [waitpoint](/wait-for-token) until a person approves, or use a [chat agent's approvals](/ai-chat/patterns/human-in-the-loop) for tool calls. A waiting run doesn't use compute, so it can wait minutes or days.
69145

70146
**Does Trigger.dev support tool calling and MCP?** Yes. Agents call the tools you define, and the [MCP server](/building-with-ai) lets AI coding assistants trigger tasks, deploy, and read run traces.
71147

72-
**Can I use Trigger.dev for background jobs, not just AI?** Yes. The same durable tasks, queues, retries, and [cron schedules](/tasks/scheduled) run any background job or workflow, with or without AI.
148+
**Can I self-host?** Yes. Trigger.dev is open source. Read the [self-hosting overview](/self-hosting/overview), or set it up with [Docker](/self-hosting/docker) or [Kubernetes](/self-hosting/kubernetes).
73149

74150
## Getting help
75151

@@ -85,7 +161,7 @@ We'd love to hear from you or give you a hand getting started. Here are some way
85161
Our Discord is the best place to get help with any questions about Trigger.dev.
86162
</Card>
87163
<Card
88-
title="Follow us on X (Twitter)"
164+
title="Follow us on X"
89165
icon={
90166
<svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 0 512 512">
91167
<path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />
@@ -112,7 +188,7 @@ We'd love to hear from you or give you a hand getting started. Here are some way
112188
href="https://github.com/triggerdotdev/trigger.dev"
113189
color="#fbbf24"
114190
>
115-
Check us out our GitHub repo and give us a star if you like what we're doing.
191+
Check out our GitHub repo, and give us a star if you like what we're doing.
116192
</Card>
117193
</CardGroup>
118194

@@ -122,12 +198,16 @@ We'd love to hear from you or give you a hand getting started. Here are some way
122198

123199
**Current major version:** v4 (`@trigger.dev/sdk` 4.x). Documentation under `/docs/v2` and `/docs/v3` describes superseded versions and should not be used.
124200

125-
**Execution model:** tasks run on Trigger.dev infrastructure, not inside your serverless functions, so a platform function timeout is not in the execution path. A task runs until it finishes; you can cap runtime with `maxDuration` (minimum 5 seconds).
201+
**Execution model:** tasks run on Trigger.dev infrastructure, not inside your serverless functions, so a platform function timeout is not in the execution path. Runs have no maximum duration by default; `maxDuration` caps a run's compute time for a project, a task, or a single run, and `timeout.None` removes the cap.
126202

127203
**Deploys:** each deploy is an atomic version. A run already in progress is not affected by code shipped after it started.
128204

129205
**Durability and retries:** retries are automatic and configurable. A failed attempt is retried according to the task's retry settings; once retries are exhausted the run ends terminally as `FAILED`, and some crashes (for example out of memory) end the run as `CRASHED` without a retry. Idempotency keys deduplicate the task triggers and waits you key, so the same key runs once instead of again.
130206

207+
**Agents:** `chat.agent` is imported from `@trigger.dev/sdk/ai`, not from `@trigger.dev/sdk`. Inside `run()`, call the `streamText` passed in the run options. It records each model step and tool call as a span by default. Slack and Linear agents use the `@trigger.dev/slack` and `@trigger.dev/linear` packages, and `slack()` requires a `startOn` filter (`appMentions()` answers @mentions).
208+
209+
**Webhooks:** `webhooks.endpoint.define()` declares a hosted, verified endpoint that syncs on `trigger dev` and on deploy; `webhook()` subscribes a task with a filter, and `webhooks.waiter` pauses a run until a matching event arrives. Both come from `@trigger.dev/sdk`.
210+
131211
**License:** the platform core is Apache-2.0 and the `@trigger.dev/sdk` package is MIT, permissive open source, not fair-code or source-available. Some features are gated, but the open source core is not relicensed or held back.
132212

133213
**LLM observability coverage:** only Vercel AI SDK calls (`generateText`, `streamText`, `generateObject`) are recorded as spans. Raw `fetch` calls and provider SDKs used directly are not captured.

0 commit comments

Comments
 (0)