Skip to main content
If your app hands video or podcast links to Trigger.dev tasks, the media step is the one that breaks once it runs in the cloud: sites block the datacenter IPs the task runs on, and many videos have no captions to read. Call Importly from the task instead. It returns the transcript, a download link for the file, or the video’s details, for links from YouTube, TikTok, Instagram, X, podcasts and 1,000+ other sites. Imports can take a few minutes for long videos. Rather than polling, the task passes a Trigger.dev waitpoint token URL as Importly’s webhookUrl. The run pauses until Importly posts the result to that URL, and you aren’t billed for compute while it waits. This page uses @trigger.dev/sdk v4 and plain fetch.

1. Add your key

Create your key on the API key page (it is shown once). Add it as IMPORTLY_API_KEY in your Trigger.dev project’s environment variables for each environment you deploy to, and to .env for trigger dev:
.env

2. A small client

Both tasks share one helper that sends a request and turns an error response into an exception. A 400 (a bad link), 401 (a wrong key) or 402 (balance too low) won’t change on a retry, so they abort the run. Anything else throws a normal error, and Trigger.dev retries the run with the task’s retry settings:
trigger/importly.ts
"mode": "auto" uses the video’s captions and falls back to speech-to-text when it has none. wait: true holds the request open for up to 30 seconds, so a transcript from captions usually comes back in the response. When it doesn’t, the run waits on the token until the webhook arrives:
trigger/transcribe-link.ts
The webhook payload has the transcript fields directly on data, while the status endpoint nests them under result (Webhooks), which is why the last line handles both. A caption transcript costs $0.003; speech-to-text is billed per minute, and maxCostDollars caps what one link can cost. More options are in Transcripts.

4. Download the file

POST /import returns a job ID straight away, and the file is ready when the webhook arrives:
trigger/import-link.ts
mediaUrl is valid for 7 days. To keep files, copy them to your storage in the next step of the task, or connect your bucket once and import with store: true so every file lands there (Save to your bucket).

Run it

Start npx trigger.dev@latest dev, open the task in the dashboard and run it with:
Or trigger it from your app’s backend:

Notes

POST /import allows 240 requests per hour per key, and an account can have 50 imports queued or running at once. A 429 throws a normal error, so Trigger.dev retries the run later. For hundreds of links, set a queue with a concurrencyLimit on the import task, and see Batch imports. Running your own Node workers on Redis instead of Trigger.dev? The BullMQ guide does the same job with two queues and one shared rate limit. Importly posts each result once, with no retries. The token’s timeout is the fallback: when it passes, the task reads the job from the status endpoint instead. A youtube.com/playlist?list=… link is rejected with PLAYLIST_NOT_SUPPORTED. Trigger one run per video, for example with batchTrigger.