| title |
Linear |
| description |
Streamline your project and issue tracking |
To get started with the Linear integration on Trigger.dev, you need to install the @trigger.dev/linear package.
You can do this using npm, pnpm, or yarn:
npm install @trigger.dev/linear@latest
pnpm add @trigger.dev/linear@latest
yarn add @trigger.dev/linear@latest
To use the Linear API with Trigger.dev, you can either use OAuth or a Personal API Key.
import { Linear } from "@trigger.dev/linear";
//this will use OAuth
const linear = new Linear({
id: "linear",
});
You can create a Personal API Key in your Linear API Settings.
import { Linear } from "@trigger.dev/linear";
//this will use the passed in API key (defined in your environment variables)
const linear = new Linear({
id: "linear",
apiKey: process.env["LINEAR_API_KEY"],
});
Include the Linear integration in your Trigger.dev job.
client.defineJob({
id: "linear-new-issue-autoresponder",
name: "Linear - New Issue Autoresponder",
version: "0.1.0",
integrations: {
//use the linear integration
linear,
},
//trigger on issue created events
trigger: linear.onIssueCreated(),
run: async (payload, io, ctx) => {
//get new issue ID from the event payload
const newIssueId = payload.data.id;
//comment
await io.linear.createComment("create-comment", {
issueId: newIssueId,
body: "Thank's for opening this issue!",
});
//react
await io.linear.createReaction("create-reaction", {
issueId: newIssueId,
emoji: "+1",
});
//store and display in the job run
return { payload, ctx };
},
});
Use the serializeLinearOutput helper instead of returning raw Linear SDK responses:
import { Linear, serializeLinearOutput } from "@trigger.dev/linear";
...
client.defineJob({
id: "linear-sdk",
name: "Linear SDK",
version: "0.1.0",
integrations: {
linear,
},
trigger: eventTrigger({
name: "linear.sdk",
}),
run: async (payload, io, ctx) => {
//the official Linear SDK is exposed as `client`
const issues = await io.linear.runTask("first-two", async (client) => {
//these nodes contain values we can't serialize, e.g. functions
const { nodes } = await client.issues({ first: 2 });
//we remove them with this little helper
return serializeLinearOutput(nodes);
});
return issues;
},
});
Pagination
You can paginate responses two different ways:
- Iterating the same integration task with different params
- Using the
getAll helper exposed on the integration (recommended!)
When ordering results, make sure to use the PaginationOrderBy enum.
import { Linear, PaginationOrderBy, serializeLinearOutput } from "@trigger.dev/linear";
...
client.defineJob({
id: "linear-pagination",
name: "Linear Pagination",
version: "0.1.0",
integrations: {
linear,
},
trigger: eventTrigger({
name: "linear.paginate",
}),
run: async (payload, io, ctx) => {
//the same params will be used for all tasks
const params = { first: 5, orderBy: PaginationOrderBy.UpdatedAt };
//1. Linear integration - no pagination helper
let edges = await io.linear.issues("get-issues", params);
let noHelper = edges.nodes;
for (let i = 0; edges.pageInfo.hasNextPage; i++) {
edges = await io.linear.issues(`get-more-issues-${i}`, {
...params,
after: edges.pageInfo.endCursor,
});
noHelper = noHelper.concat(edges.nodes);
}
//2. Linear integration - with the pagination helper
const withHelper = await io.linear.getAll(io.linear.issues, "get-all", params);
return {
issueCounts: {
withSdk: sdkIssues.length,
noHelper: noHelper.length,
withHelper: withHelper.length,
},
};
},
});
| Function Name |
Description |
onAttachment |
When any action is performed on an attachment. |
onAttachmentCreated |
When an attachment is created. |
onAttachmentRemoved |
When an attachment is removed. |
onAttachmentUpdated |
When an attachment is updated. |
Comments
| Function Name |
Description |
onComment |
When any action is performed on an comment. |
onCommentCreated |
When an comment is created. |
onCommentRemoved |
When an comment is removed. |
onCommentUpdated |
When an comment is updated. |
| Function Name |
Description |
onCycle |
When any action is performed on an cycle. |
onCycleCreated |
When an cycle is created. |
onCycleRemoved |
When an cycle is removed. |
onCycleUpdated |
When an cycle is updated. |
| Function Name |
Description |
onIssue |
When any action is performed on an issue. |
onIssueCreated |
When an issue is created. |
onIssueRemoved |
When an issue is removed. |
onIssueUpdated |
When an issue is updated. |
| Function Name |
Description |
onIssueLabel |
When any action is performed on an issue label. |
onIssueLabelCreated |
When an issue label is created. |
onIssueLabelRemoved |
When an issue label is removed. |
onIssueLabelUpdated |
When an issue label is updated. |
| Function Name |
Description |
onIssueSLA |
When any action is performed on an issue SLA. |
onIssueSLASet |
When an issue SLA is set. |
onIssueSLABreached |
When an issue SLA is breached. |
onIssueSLAHighRisk |
When an issue SLA is high risk. |
| Function Name |
Description |
onProject |
When any action is performed on an project. |
onProjectCreated |
When an project is created. |
onProjectRemoved |
When an project is removed. |
onProjectUpdated |
When an project is updated. |
| Function Name |
Description |
onProjectUpdate |
When any action is performed on an project update. |
onProjectUpdateCreated |
When an project update is created. |
onProjectUpdateRemoved |
When an project update is removed. |
onProjectUpdateUpdated |
When an project update is updated. |
| Function Name |
Description |
onReaction |
When any action is performed on an reaction. |
onReactionCreated |
When an reaction is created. |
onReactionRemoved |
When an reaction is removed. |
onReactionUpdated |
When an reaction is updated. |
| Function Name |
Description |
attachment |
Gets an attachment. |
attachments |
Gets multiple attachments. |
createAttachment |
Creates an attachment. |
deleteAttachment |
Deletes an attachment. |
updateAttachment |
Updates an attachment. |
| Function Name |
Description |
attachmentLinkFront |
Links a Front conversation to an issue. |
attachmentLinkIntercom |
Links a Intercom conversation to an issue. |
attachmentLinkJiraIssue |
Links a Jira issue to an issue. |
attachmentLinkSlack |
Links a Slack message to an issue. |
attachmentLinkURL |
Links any URL to an issue. |
attachmentLinkZendesk |
Links a Zendesk ticket to an issue. |
Comments
| Function Name |
Description |
comment |
Gets a comment. |
comments |
Gets multiple comments. |
createComment |
Creates a comment. |
deleteComment |
Deletes a comment. |
updateComment |
Updates a comment. |
| Function Name |
Description |
archiveCycle |
Archives a cycle. |
createCycle |
Creates a cycle. |
updateCycle |
Updates a cycle. |
| Function Name |
Description |
document |
Gets a document. |
documents |
Gets multiple documents. |
createDocument |
Creates a document. |
searchDocuments |
Searches documents. |
| Function Name |
Description |
favorite |
Gets a favorite. |
favorites |
Gets multiple favorites. |
createFavorite |
Creates a favorite. |
| Function Name |
Description |
issue |
Gets an issue. |
issues |
Gets multiple issues. |
archiveIssue |
Archives an issue. |
createIssue |
Creates an issue. |
deleteIssue |
Deletes an issue. |
searchIssues |
Searches issues. |
updateIssue |
Updates an issue. |
| Function Name |
Description |
issueLabel |
Gets an issue label. |
issueLabels |
Gets multiple issue labels. |
createIssueLabel |
Creates an issue label. |
deleteIssueLabel |
Deletes an issue label. |
updateIssueLabel |
Updates an issue label. |
| Function Name |
Description |
issueRelation |
Gets an issue relation. |
issueRelations |
Gets multiple issue relations. |
createIssueRelation |
Creates an issue relation. |
| Function Name |
Description |
notification |
Gets a notification. |
notifications |
Gets multiple notifications. |
archiveNotification |
Archives a notification. |
createNotificationSubscription |
Creates a notification subscription. |
| Function Name |
Description |
organization |
Gets the viewer's organization. |
createOrganizationFromOnboarding |
Creates an organization. |
createOrganizationInvite |
Creates an organization invite. |
| Function Name |
Description |
project |
Gets a project. |
projects |
Gets multiple projects. |
archiveProject |
Archives a project. |
createProject |
Creates a project. |
deleteProject |
Deletes a project. |
searchProjects |
Searches projects. |
updateProject |
Updates a project. |
| Function Name |
Description |
projectLink |
Gets a project link. |
projectLinks |
Gets multiple project links. |
createProjectLink |
Creates a project link. |
| Function Name |
Description |
projectUpdate |
Gets a project update. |
projectUpdates |
Gets multiple project updates. |
createProjectUpdate |
Creates a project update. |
deleteProjectUpdate |
Deletes a project update. |
updateProjectUpdate |
Updates a project update. |
| Function Name |
Description |
createReaction |
Creates a reaction. |
deleteReaction |
Deletes a reaction. |
| Function Name |
Description |
archiveRoadmap |
Archives a roadmap. |
createRoadmap |
Creates a roadmap. |
| Function Name |
Description |
team |
Gets a team. |
teams |
Gets multiple teams. |
createTeam |
Creates a team. |
| Function Name |
Description |
teamMembership |
Gets a team membership. |
teamMemberships |
Gets multiple team memberships. |
createTeamMembership |
Creates a team membership. |
| Function Name |
Description |
template |
Gets a template. |
templates |
Gets multiple templates. |
| Function Name |
Description |
user |
Gets a user. |
users |
Gets multiple users. |
updateUser |
Updates a user. |
| Function Name |
Description |
webhook |
Gets a webhook. |
webhooks |
Gets multiple webhooks. |
createWebhook |
Creates a webhook. |
deleteWebhook |
Deletes a webhook. |
updateWebhook |
Updates a webhook. |
| Function Name |
Description |
workflowState |
Gets a workflow state. |
workflowStates |
Gets multiple workflow states. |
archiveWorkflowState |
Archives a workflow state. |
createWorkflowState |
Creates a workflow state. |
| Function Name |
Description |
createProjectMilestone |
Creates a project milestone. |
issuePriorityValues |
Gets issue priority values and labels. |
viewer |
Gets the currently authenticated user. |