Skip to main content

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. 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.
integration/github/issues.ts
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.
integrations/github/index.ts

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:
integrations/github/index.ts