How to upgrade v2 jobs to v3 tasks, and how to use them together.
io.runTask()
(and no cacheKeys
).task
s are the new primitive, not job
s.Copy and paste this prompt in full:
eventTrigger
defines the payload type. In v3 that needs to be done on the TypeScript type of the run
payload param.
2. v2 had integrations with some APIs. Any package that isn’t @trigger.dev/sdk
can be replaced with an official SDK. The syntax may need to be adapted.
For example:
v2:@trigger.dev/openai
package in v3, use the official OpenAI SDK.
Bear in mind that the syntax for the latest official SDK will probably be different from the @trigger.dev integration SDK. You will need to adapt the code accordingly.
3. The most critical difference is that inside the run
function you do NOT need to wrap everything in io.runTask
. So anything inside there can be extracted out and be used in the main body of the function without wrapping it.
4. The import for task
in v3 is import { task } from "@trigger.dev/sdk/v3";
5. You can trigger jobs from other jobs. In v2 this was typically done by either calling io.sendEvent()
or by calling yourOtherTask.invoke()
. In v3 you call .trigger()
on the other task, there are no events in v3.
v2:trigger()
or batchTrigger()
which you can do on any type of task. Including scheduled, webhooks, etc if you want.