trigger.dev
trigger.dev copied to clipboard
[TRI-1362] docs: Add better documentation for how to use Task Callbacks
We currently only have a small amount of documentation for task callbacks in the io.runTask() docs but it would be great to flesh out the documentation in more detail, especially usage with just io.runTask
instead of io.replicate.runTask
, e.g.:
await io.runTask(
"use-callback-url",
async (task) => {
// task.callbackUrl is the URL to call when the task is done
// The output of this task will be the body POSTed to this URL
},
{
name: "Use the callbackUrl to notify the caller when the task is done",
callback: {
enabled: true,
timeoutInSeconds: 300, // If task.callbackUrl is not called within 300 seconds, the task will fail
},
}
);
Things the doc should cover:
- When it makes sense to use callback URLs (a callback from an external system). Would be great to find another example of this other than Replicate
- How to correctly type runTask so the output type is correct
- How the request to the task URL works (POST and the entire JSON body becomes the task output)
- How the timeout works
I think this would probably best live in Documentation -> Guides -> Task Callbacks
If the issue hasn't been solved, I would like to work. Can you assign me this issue?
@ericallam i have made a PR, please check