This document provides a technical overview of integration patterns for connecting Trigger.dev tasks to external services and APIs. It covers practical approaches, configuration requirements, and code-level patterns for integrating with popular platforms such as OpenAI, Fal.ai, Replicate, Resend, BrowserBase, Anchor Browser, Cloudflare R2, Prisma, and React Email.
The focus is on how to structure tasks, manage credentials, configure build extensions, and orchestrate workflows that span multiple third-party services. This page is intended for developers building production-grade automations and background jobs that require reliable, observable, and maintainable integrations.
For information about the SDK task API, see Task Definition API. For details on the build extension system, see Build Extensions. For a catalog of example projects, see Example Projects and Tasks.
Purpose:
To document the recommended patterns and technical requirements for integrating Trigger.dev tasks with external APIs and services, including authentication, build configuration, and orchestration strategies.
Scope:
Not covered:
The following diagram maps common integration targets to the relevant code entities and configuration points in a Trigger.dev project.
Sources:
Many integrations require additional build steps or external dependencies. Trigger.dev uses a build extension system configured in trigger.config.ts to support these requirements.
| Extension Name | Purpose / Integration Target | Example Configuration Key | Docs Reference |
|---|---|---|---|
prismaExtension | Prisma ORM (database access) | prismaExtension() | /config/extensions/prismaExtension |
pythonExtension | Python script execution | pythonExtension() | /config/extensions/pythonExtension |
puppeteer | Puppeteer (browser automation) | puppeteer() | /config/extensions/puppeteer |
playwright | Playwright (browser automation) | playwright() | /config/extensions/playwright |
ffmpeg | FFmpeg (video/audio processing) | ffmpeg() | /config/extensions/ffmpeg |
lightpanda | Lightpanda browser automation | lightpanda() | /config/extensions/lightpanda |
additionalPackages | Custom npm/system packages | additionalPackages() | /config/extensions/additionalPackages |
external | Exclude packages from bundle | build.external | anchor-browser-web-scraper.mdx105-118 |
Sources:
All integrations require secure management of API keys and credentials. The recommended pattern is:
.env for local development.process.env.Example Environment Variables:
| Service | Variable Name(s) |
|---|---|
| OpenAI | OPENAI_API_KEY |
| Fal.ai | FAL_KEY |
| Replicate | REPLICATE_API_TOKEN |
| Resend | RESEND_API_KEY |
| BrowserBase | BROWSERBASE_API_KEY |
| Anchor Browser | ANCHOR_BROWSER_API_KEY |
| Cloudflare R2 | R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET, R2_PUBLIC_URL |
| Prisma | DATABASE_URL |
Sources:
Trigger.dev supports several orchestration patterns for integrating with external services:
Use schedules.task() to run tasks on a cron schedule, e.g., daily web scraping or monitoring.
Example:
Use batchTriggerAndWait() to process multiple items in parallel, such as summarizing multiple articles or generating multiple images.
Example:
Use wait.createToken() and wait.forToken() to pause a task until an external webhook is received (e.g., async AI model completion).
Example:
Use logging and metadata APIs to stream progress to the frontend via the Realtime API and React hooks.
Example:
Sources:
The following diagram shows how a single scheduled task can orchestrate multiple integrations using Trigger.dev's orchestration primitives.
Sources:
openai npm package.OPENAI_API_KEY.@fal-ai/serverless-client package.FAL_KEY.fal.subscribe() for image generation and progress updates.replicate npm package.REPLICATE_API_TOKEN.wait.createToken() and wait.forToken() for async webhook handling.resend npm package for sending emails.@react-email/components for email templates.RESEND_API_KEY.puppeteer and connect via BrowserBase's WebSocket endpoint.BROWSERBASE_API_KEY.puppeteer build extension in trigger.config.ts.anchorbrowser npm package.ANCHOR_BROWSER_API_KEY.build.external.@aws-sdk/client-s3).R2_ENDPOINT, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET, R2_PUBLIC_URL.prismaExtension build extension.DATABASE_URL.Sources:
The following table summarizes example projects and the integration patterns they demonstrate.
| Example Project | Integration Targets | Patterns Used | Reference File(s) |
|---|---|---|---|
| Scrape Hacker News and Email Summary | BrowserBase, Puppeteer, OpenAI, Resend, React Email | Scheduled, Batch, Email, Web Scraping | scrape-hacker-news.mdx |
| Fal.ai Image to Cartoon | Fal.ai, Cloudflare R2 | Task, File Upload, Progress Logging | fal-ai-image-to-cartoon.mdx |
| Realtime Fal.ai Image Generation | Fal.ai | Task, Realtime, Progress Logging | fal-ai-realtime.mdx |
| Replicate Image Generation | Replicate, Cloudflare R2 | Waitpoint, Webhook, File Upload | replicate-image-generation.mdx |
| Product Image Generator | Replicate, Cloudflare R2, UploadThing | Batch, Waitpoint, Realtime | product-image-generator.mdx |
| Anchor Browser Web Scraper | Anchor Browser, Playwright | Scheduled, Browser Automation | anchor-browser-web-scraper.mdx |
Sources:
This diagram links integration patterns to the main code entities and configuration files in a Trigger.dev project.
Sources:
Sources:
Refresh this wiki