Opening Problem Statement
Meet Niklas, a product manager at a growing software company that uses Linear to track bugs and issues reported by customers and developers. Every day, Niklas faces the tedious task of manually assessing new bug tickets to decide which team should handle them. This process is time-consuming and often error-prone, leading to delays in addressing critical bugs and frequent misassignments. As a result, teams spend extra hours clarifying responsibilities, and urgent fixes get slower, frustrating customers and wasting valuable resources.
In Niklas’ case, the volume of incoming bug tickets sometimes overwhelms the triage process. Some descriptions are incomplete or vague, making human classification challenging. Moreover, ensuring that each bug goes to the right specialized team — like the ‘Adore’ team for signup journeys or the ‘Payday’ team for enterprise features — requires deep familiarity with each team’s responsibilities. These struggles led to bottlenecks that cost Niklas’ company both time and money, slowing down product quality improvements and affecting customer satisfaction.
What This Automation Does
This custom n8n workflow harnesses the power of the Linear API combined with OpenAI to automatically classify bug tickets when they are created or updated. Here’s exactly what happens when this automation runs:
- Monitoring: It listens for new or updated bug tickets in Linear’s specified team using the Linear Trigger node.
- Filtering: It processes only those tickets that have a filled description, are in the “Triage” state, and tagged as bugs with the “type/bug” label — using the Filter node.
- Team Classification: Sends the ticket’s title and description to OpenAI (GPT-4-32K) with a prompt describing all possible teams and their responsibilities, asking which team should handle the bug.
- Team Lookup: Calls Linear’s GraphQL API via an HTTP Request node to fetch all teams and their IDs dynamically.
- Updating Ticket: Maps the team name returned by OpenAI to the corresponding team ID and updates the ticket’s team in Linear through the Linear – Update Issue node.
- Fallback Notification: If OpenAI cannot confidently assign a team (e.g., returns “Other”), the workflow sends an alert to a configured Slack channel to prompt manual triage, using the Slack node.
This workflow eliminates the painstaking manual triage of bugs, accelerates issue routing, and reduces misclassifications, saving potentially hours of manual effort per week while maintaining team alignment.
Prerequisites ⚙️
- Linear account with API access and OAuth2 credentials configured in n8n
- OpenAI account with API key for GPT-4 (or compatible model)
- Slack workspace with a bot token for sending messages (optional but recommended for notifications)
- n8n account to build and run workflows
- Self-hosting option available for n8n if preferred, see https://buldrr.com/hostinger
Step-by-Step Guide to Setup This Automation
Step 1: Create and Configure the Linear Trigger Node
Navigate to your n8n editor, then click + Add Node → Search for Linear Trigger. Select it.
Configure the node as follows:
- Select your Linear Team by its ID (e.g., “7a330c36-4b39-4bf1-922e-b4ceeb91850a”).
- Choose issue as the resource and update as the event to listen for ticket changes.
- Connect your Linear OAuth2 credentials.
- Description does not contain “Add a description here” (to exclude placeholder tickets).
- State ID equals the ID for “Triage” state (e.g., “6b9a8eec-82dc-453a-878b-50f4c98d3e53”).
- The ticket must have the label with ID corresponding to “type/bug” (filter labels by ID, ensuring it’s a bug).
Save and test by updating an issue in Linear; this triggers the workflow.
Common mistake: Forgetting to set the event or resource properly; make sure it listens to issue updates.
Step 2: Filter Tickets That Need Classification
Add a Filter node named “Only tickets that need to be classified.”
Set conditions:
This ensures only relevant bug tickets are processed.
Step 3: Define Team Responsibilities in Set Me Up Node
Add Set node “Set me up” to define all potential teams and their detailed responsibilities in a text list formatted like:
- [Adore][Is responsible for every persona that is not Enterprise. This includes signup journeys, trials, n8n Cloud, the Canvas building experience and more, the nodes detail view (NDV), the nodes panel, the workflows list and the executions view] - [Payday][Is responsible for the Enterprise persona. Includes performance, enterprise features SSO, LDAP, SAML, log streaming, etc.] - [Nodes][Responsible for anything node-related in n8n] - [Other][Fallback if no team fits]
Also, set your Slack channel in this node for notifications (e.g., “#yourChannelName”).
Step 4: Use OpenAI Node to Classify Bug Tickets
Add the OpenAI node (LangChain OpenAI) configured for GPT-4-32K-0314 model.
Set messages following this system prompt:
I need you to classify a bug ticket and tell me which team should work on it
All possible teams will be described in the following format: [Teamname][Areas of responsibility]
=The possible teams are the following:
{{ $('Set me up').first().json.teams }}
=This is the bug that we're trying to classify:
Title: {{ $('Linear Trigger').first().json.data.title }}
Description: {{ $('Linear Trigger').first().json.data.description }}
Which team should work on this bug?
Do not respond with anything else than the name of the team from the list you were givenThis prompt ensures AI returns only a team name from the given options.
Step 5: Fetch All Teams From Linear via HTTP Request
Add an HTTP Request node “Get all linear teams” configured as a POST to https://api.linear.app/graphql with the body:
{ "query": "{ teams { nodes { id name } } }" }Use the OAuth2 credentials for Linear.
This returns current team IDs and names to map the AI response to a valid team ID.
Step 6: Map AI Response to Team ID
Add a Set node “Set team ID” that runs a JavaScript expression:
={{
$('Get all linear teams').first().json.data.teams.nodes.find(team => team.name === $json.message.content).id
}}This finds the exact team ID based on the AI-chosen team name for the next update step.
Step 7: Update the Bug Ticket’s Team
Add the Linear node “Update team” with operation update.
- Set issueId to
{{ $('Linear Trigger').item.json.data.id }}. - Set teamId field to the value assigned in the previous step.
- Use your Linear API key credentials.
- Expand Teams List: In the “Set me up” node, append more teams and detailed responsibilities or update naming to exactly match your Linear teams.
- Change Slack Notifications Channel: Update the “slackChannel” field in the “Set me up” node to any Slack channel of your choice for alerts.
- Adjust Filter Conditions: Modify the “Only tickets that need to be classified” filter node conditions to target different Linear states or label IDs.
- Change AI Model: In the OpenAI node, switch the model from GPT-4-32K-0314 to another available model depending on your subscription or use case.
- Modify Prompt: Adjust the system messages in the OpenAI node to refine classification logic or team responsibilities.
- Problem: “Linear Trigger not firing when ticket updates occur.”
Cause: Incorrect team ID or webhook setup.
Solution: Verify Linear Trigger node configuration and ensure correct OAuth2 credentials are connected. - Problem: “OpenAI returns team name not found in Linear teams.”
Cause: Team names between OpenAI prompt and Linear teams do not match exactly.
Solution: Ensure team names in the “Set me up” node and Linear are case and spelling exact. - Problem: “Slack notification not sent when AI fails to classify.”
Cause: Wrong Slack channel ID or missing bot permissions.
Solution: Confirm Slack node channel field and bot token permissions. - Problem: “HTTP Request node to Linear GraphQL fails with error.”
Cause: OAuth2 credentials expired or invalid.
Solution: Re-authenticate the Linear OAuth2 credential in n8n. - Confirm OAuth2 credentials for Linear and OpenAI nodes are valid and authorized.
- Test the Linear Trigger by updating a sample bug ticket with appropriate description and labels.
- Validate the AI prompt by running OpenAI node manually with sample bug data.
- Check “Get all linear teams” HTTP request returns current teams successfully.
- Ensure Slack notifications send correctly to your desired channel.
- Backup your workflow before final activation.
- Can I use another AI provider instead of OpenAI?
Currently, this workflow uses n8n’s LangChain OpenAI node, but other AI integrations are possible with custom API nodes if you want to try alternatives like Cohere or AI21 Labs. - Does this workflow consume a lot of OpenAI credits?
Classification per ticket uses GPT-4-32K which is a powerful model; consider model choice and expected ticket volume to manage API costs. - Is my data safe?
All data handles through secure OAuth2 and API keys. Only textual bug data is sent to OpenAI. Confidentiality depends on your OpenAI settings. - Can it scale to large volumes?
Yes, n8n handles queues, but monitor your API rate limits and consider batching if needed.
Execute this to assign the bug to the proper team automatically.
Step 8: Handle Cases When AI Cannot Find a Team
Insert an If node “Check if AI was able to find a team”.
Set condition to check if the AI’s output is not equal to “Other” (the fallback team).
When false, route to a Slack node “Notify in Slack” that sends a message to your configured Slack channel, notifying the team about unclassified bugs needing manual attention.
Customizations ✏️
Troubleshooting 🔧
Pre-Production Checklist ✅
Deployment Guide
Once tested, activate this workflow in n8n by toggling it on. Regularly monitor the workflow executions for errors and adjust or refine the classification logic as new teams or bug types emerge. Use n8n’s built-in execution logs for troubleshooting and verifying data flows.
FAQs
Conclusion
By following this guide, you have built a highly effective automation that detects new or updated bug tickets in Linear, uses AI to intelligently classify the correct team, and updates the tickets automatically. This saves your team countless hours of manual triage and improves bug resolution speed and accuracy.
Imagine reclaiming hours every week that were lost to tedious sorting and instead focusing on fixing critical issues and enhancing your product. Next up, you might explore automating bug prioritization based on severity or integrating customer feedback analysis to enrich ticket metadata. With n8n and OpenAI, powerful, custom automations tailored to your exact workflows are within reach.
Happy automating!