Tasks
Tasks are the main way that developers will interact with your Integration. They are the actions that developers will be able to perform in their jobs.
runTask
You should add a runTask()
function to your integration, before adding individual Tasks. It will be used by all Tasks, and allows users to use any function in the official SDK as a Task.
Matching the original SDK structure
The structure of the integrtion should closely map to the official Node SDK for that API.
API | Official SDK | Trigger.Dev Task |
---|---|---|
GitHub (octokit) | client.rest.issues.create | io.github.issues.create |
Typeform | client.forms.get | io.typeform.forms.get |
OpenAI | client.completions.create | io.openai.completions.create |
Closely resembling the official SDK makes it far easier for developers to use integrations. Aim for 1:1 mapping wherever possible.
Adding Tasks
Any tasks you add will use the runTask
function you added above.
Remember we want to structure our integration to match the original SDK. If an SDK has a client.forms.get
function, we want to add a myintegration.forms.get
task.
This requires adding a bit of structure to the SDK, to add the Forms object, the get function and use runTask
inside them.
Create the structure
In this example, we’ll add io.github.issues.create
. This will allow users to create a GitHub issue in their jobs.
Comments inline are for instructional purposes only, and should not be included in your final code.
Notice how the params are the second argument, that’s because the first argument is always the task key. See our Keys and Resumability docs for more on why this is important.
onError
function
You can optionally have logic in the onError
param. See the reference for runTask for more info.
The GitHub integration uses this to retry rate-limited requests when the rate limit resets:
Was this page helpful?