Integrations: Overview
How to use Trigger.dev Integrations
You can use any API in your Jobs by using existing Node.js SDKs or HTTP requests. Integrations just make it much easier especially when you want to use OAuth. And you get great logging.
Integrations allow you to quickly use APIs, including webhooks and Tasks.
Authentication
There are two ways to authenticate Integrations, OAuth and API Keys/Access Tokens.
API Keys/Access Tokens
Use API Keys or Access Tokens to connect an Integration
OAuth
Use OAuth to connect an Integration for your team or your users
Bring-your-own Auth
Use our integrations with your user’s auth credentials, using Clerk.com, Nango.dev, or rolling your own with our custom auth resolvers
Using for Jobs & Tasks
You must pass Integrations into your Job to run integration tasks. Passed in Integrations will be available on the io
object in the run()
function with the same name as the key. For example:
Both the postMessage
and addIssueLabels
functions above are implemented as an “Authenticated Task” that is defined inside the Integration, where the first argument is always the task key and the second argument is the parameters for the task. For example, here is how you would call the postMessage
function above:
The above code will create a Task that will use the authentication configured for the specified Slack integration.
If the integration does not support a specific task function that you want to use, you can use the runTask
function to get access to the authenticated client.
For example, the Slack integration doesn’t expose an Authenticated Task function for deleting a message, but you can use the chat.delete
function provided by the @slack/web-api package directly:
You can optionally pass a third parameter to runTask
to specify the task parameters:
View the runTask reference for more information.
Using outside of Jobs
If you want to use integrations that support “local auth” only (e.g. API keys, like Stripe and Supabase) outside of a Job you can use the .native
property on the integration to get direct access to the client. For example:
Using for Triggers
Some integrations provide triggers that you can use to start a Job. For example, the GitHub integration provides a push
trigger that will start a Job when a new commit is pushed to a repository:
Behind the scenes, our @trigger.dev/github
integration will create a webhook on your repository that will call our API when a new push event is received. We will then start your Job with the payload from the push event.
If you are just using an integration to trigger a job but not using authenticated tasks inside the
job run, there is no need to pass the integration in the job integrations
option.
Was this page helpful?