{ "nodes": [ { "id": "aaf1c25e-c398-4715-88bf-bd98daafc10f", "name": "Schedule Trigger", "type": "n8n-nodes-base.scheduleTrigger", "position": [ -340, -100 ], "parameters": { "rule": { "interval": [ { "field": "minutes", "minutesInterval": 30 } ] } }, "typeVersion": 1.2 }, { "id": "2fbcfbea-3989-459b-8ca7-b65c130a479b", "name": "Fetch Active Linear Issues", "type": "n8n-nodes-base.graphql", "position": [ -140, -100 ], "parameters": { "query": "=query (\n $filter: IssueFilter\n) {\n issues(\n first: 50\n filter: $filter\n ) {\n nodes {\n id\n identifier\n title\n description\n url\n createdAt\n updatedAt\n assignee {\n name\n }\n comments(first: 50) {\n nodes {\n id\n createdAt\n user {\n displayName\n }\n body\n }\n }\n }\n }\n}", "endpoint": "https://api.linear.app/graphql", "variables": "={{ {filter:{updatedAt:{gte:$now.minus({minutes:30}).toISO()}}} }}", "requestFormat": "json", "authentication": "headerAuth" }, "typeVersion": 1 }, { "id": "82fd6023-2cc3-416e-83b7-fda24d07d77a", "name": "Issues to List", "type": "n8n-nodes-base.splitOut", "position": [ 40, -100 ], "parameters": { "options": {}, "fieldToSplitOut": "data.issues.nodes" }, "typeVersion": 1 }, { "id": "sentiment-threads", "name": "Validate Issue Threads", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 220, -100 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "function collectSentimentDetails({issues,previousState,issue}){\n const state=previousState===null?{index:0,issues:[]}:JSON.parse(JSON.stringify(previousState));\n if(!Array.isArray(issues)||issues.length>50||new Set(issues.map(i=>i.id)).size!==issues.length)throw new Error('Expected the source first50 unique Linear issues.');\n if(previousState!==null){const expected=issues[state.index];if(!expected||!issue||issue.id!==expected.id||!Array.isArray(issue.comments?.nodes)||issue.comments.nodes.length>50)throw new Error('Linear issue detail does not match the selected issue.');\n for(const k of['id','identifier','title','createdAt','updatedAt'])if(typeof issue[k]!=='string'||!issue[k])throw new Error('Linear issue metadata is incomplete.');\n const text=issue.comments.nodes.map(c=>{if(typeof c.body!=='string'||typeof c.createdAt!=='string')throw new Error('Linear comment content is incomplete.');return (c.user?.displayName??c.user?.name??'Unknown author')+' commented on '+c.createdAt+':\\n'+c.body;}).join('---\\n');\n if(!text.trim())throw new Error('The source Information Extractor needs nonempty comment text.');\n state.issues.push({id:issue.id,identifier:issue.identifier,title:issue.title,url:issue.url,createdAt:issue.createdAt,updatedAt:issue.updatedAt,assignee:issue.assignee??null,commentText:text});state.index++;\n }\n return {state,more:state.indexi.json);return items.map((item,index)=>({json:collectSentimentDetails({issues,previousState:{index,issues:[]},issue:item.json}).state.issues[0],pairedItem:{item:index}}));" } }, { "id": "fe6560f6-2e1b-4442-a2af-bd5a1623f213", "name": "Sentiment over Issue Comments", "type": "@n8n/n8n-nodes-langchain.informationExtractor", "position": [ 360, -80 ], "parameters": { "schemaType": "manual", "inputSchema": "{\"type\":\"object\",\"properties\":{\"sentiment\":{\"type\":\"string\",\"enum\":[\"positive\",\"negative\",\"neutral\"],\"description\":\"One of positive, negative or neutral\"},\"sentimentSummary\":{\"type\":\"string\",\"description\":\"Describe the sentiment of the conversation\"}},\"required\":[\"sentiment\"],\"additionalProperties\":false}", "text": "={{ $json.commentText }}", "options": { "systemPromptTemplate": "You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value." } }, "typeVersion": 1 }, { "id": "9cc77786-e14f-47c6-a3cf-60c2830612e6", "name": "OpenAI Chat Model", "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi", "position": [ 360, 80 ], "parameters": { "model": { "__rl": true, "mode": "id", "value": "gpt-5-mini" }, "options": {} }, "typeVersion": 1.2 }, { "id": "821d4a60-81a4-4915-9c13-3d978cc0114b", "name": "Combine Sentiment Analysis", "type": "n8n-nodes-base.code", "position": [ 700, -80 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "function parseSentimentText(text){if(typeof text!=='string')throw new Error('Sentiment completion is not text.');const result=JSON.parse(text.trim().replace(/^```(?:json)?\\s*|\\s*```$/g,''));if(!result||typeof result!=='object'||Array.isArray(result)||!['positive','negative','neutral'].includes(result.sentiment)||(result.sentimentSummary!==undefined&&typeof result.sentimentSummary!=='string')||Object.keys(result).some(k=>!['sentiment','sentimentSummary'].includes(k)))throw new Error('Expected sentiment positive/negative/neutral and optional text sentimentSummary.');return {sentiment:result.sentiment,sentimentSummary:result.sentimentSummary??''};}\n\nconst results=$input.all(),issues=$(\"Validate Issue Threads\").all();if(results.length!==issues.length)throw new Error(\"Sentiment count differs.\");return results.map((item,index)=>({json:{...issues[index].json,...parseSentimentText(JSON.stringify(item.json.output))},pairedItem:{item:index}}));" }, "typeVersion": 2 }, { "id": "6d103d67-451e-4780-8f52-f4dba4b42860", "name": "For Each Issue...", "type": "n8n-nodes-base.splitInBatches", "position": [ 1020, -60 ], "parameters": { "batchSize": 1, "options": {} }, "typeVersion": 3 }, { "id": "4fd0345d-e5bf-426d-8403-e2217e19bbea", "name": "Copy of Issue", "type": "n8n-nodes-base.set", "position": [ 1200, -60 ], "parameters": { "mode": "raw", "options": {}, "jsonOutput": "={{ $json }}" }, "typeVersion": 3.4 }, { "id": "032702d9-27d8-4735-b978-20b55bc1a74f", "name": "Get Existing Sentiment", "type": "n8n-nodes-base.airtable", "position": [ 1380, -60 ], "parameters": { "authentication": "airtableTokenApi", "base": { "__rl": true, "mode": "id", "value": "app00000000000000" }, "table": { "__rl": true, "mode": "id", "value": "YOUR_SENTIMENT_TABLE" }, "operation": "search", "returnAll": true, "filterByFormula": "={{ \"{Issue ID} = '\" + $json.identifier.replace(/\\\\/g,\"\\\\\\\\\").replace(/'/g,\"\\\\'\") + \"'\" }}", "options": { "fields": [ "Issue ID", "Current Sentiment" ] } }, "typeVersion": 2.1, "alwaysOutputData": true }, { "id": "sentiment-previous", "name": "Validate Previous Sentiment", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1460, -60 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const source=$(\"Copy of Issue\").item.json,rows=$input.all().map(i=>i.json).filter(row=>row.id);if(rows.length>1)throw new Error(\"Issue ID must uniquely identify an Airtable row.\");const current=rows[0]?.[\"Current Sentiment\"]??rows[0]?.fields?.[\"Current Sentiment\"];if(current!==undefined&&typeof current!==\"string\")throw new Error(\"Previous sentiment is not text.\");return [{json:{...source,previousSentiment:current??\"N/A\"},pairedItem:{item:0}}];" } }, { "id": "f2ded6fa-8b0f-4a34-868c-13c19f725c98", "name": "Update Row", "type": "n8n-nodes-base.airtable", "position": [ 1560, -60 ], "parameters": { "base": { "__rl": true, "mode": "id", "value": "app00000000000000" }, "table": { "__rl": true, "mode": "id", "value": "YOUR_SENTIMENT_TABLE" }, "columns": { "value": { "Issue ID": "={{ $json.identifier }}", "Previous Sentiment": "={{ $json.previousSentiment }}", "Current Sentiment": "={{ $json.sentiment.charAt(0).toUpperCase()+$json.sentiment.slice(1) }}", "Summary": "={{ $json.sentimentSummary }}", "Issue Title": "={{ $json.title }}", "Issue Created": "={{ $json.createdAt }}", "Issue Updated": "={{ $json.updatedAt }}", "Assigned": "={{ $json.assignee?.name ?? \"\" }}" }, "schema": [ { "id": "id", "type": "string", "display": true, "removed": true, "readOnly": true, "required": false, "displayName": "id", "defaultMatch": true }, { "id": "Issue ID", "type": "string", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Issue ID", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Previous Sentiment", "type": "options", "display": true, "options": [ { "name": "Positive", "value": "Positive" }, { "name": "Negative", "value": "Negative" }, { "name": "Neutral", "value": "Neutral" }, { "name": "N/A", "value": "N/A" } ], "removed": false, "readOnly": false, "required": false, "displayName": "Previous Sentiment", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Current Sentiment", "type": "options", "display": true, "options": [ { "name": "Positive", "value": "Positive" }, { "name": "Negative", "value": "Negative" }, { "name": "Neutral", "value": "Neutral" }, { "name": "N/A", "value": "N/A" } ], "removed": false, "readOnly": false, "required": false, "displayName": "Current Sentiment", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Summary", "type": "string", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Summary", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Issue Title", "type": "string", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Issue Title", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Issue Created", "type": "dateTime", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Issue Created", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Issue Updated", "type": "dateTime", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Issue Updated", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Assigned", "type": "string", "display": true, "removed": false, "readOnly": false, "required": false, "displayName": "Assigned", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Created", "type": "string", "display": true, "removed": true, "readOnly": true, "required": false, "displayName": "Created", "defaultMatch": false, "canBeUsedToMatch": true }, { "id": "Last Modified", "type": "string", "display": true, "removed": true, "readOnly": true, "required": false, "displayName": "Last Modified", "defaultMatch": false, "canBeUsedToMatch": true } ], "mappingMode": "defineBelow", "matchingColumns": [ "Issue ID" ] }, "options": {}, "operation": "upsert", "authentication": "airtableTokenApi" }, "typeVersion": 2.1 }, { "id": "e6fb0b8f-2469-4b66-b9e2-f4f3c0a613af", "name": "Airtable Trigger", "type": "n8n-nodes-base.airtableTrigger", "position": [ 1900, -40 ], "parameters": { "baseId": { "__rl": true, "mode": "id", "value": "app00000000000000" }, "tableId": { "__rl": true, "mode": "id", "value": "YOUR_SENTIMENT_TABLE" }, "pollTimes": { "item": [ { "mode": "everyHour" } ] }, "triggerField": "Last Modified", "authentication": "airtableTokenApi", "additionalFields": {} }, "typeVersion": 1 }, { "id": "669762c4-860b-43ad-b677-72d4564e1c29", "name": "Sentiment Transition", "type": "n8n-nodes-base.switch", "position": [ 2080, -40 ], "parameters": { "rules": { "values": [ { "outputKey": "NON-NEGATIVE to NEGATIVE", "conditions": { "options": { "version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict" }, "combinator": "and", "conditions": [ { "operator": { "type": "boolean", "operation": "true", "singleValue": true }, "leftValue": "={{ $json.fields[\"Previous Sentiment\"] !== 'Negative' && $json.fields[\"Current Sentiment\"] === 'Negative' }}", "rightValue": "" } ] }, "renameOutput": true } ] }, "options": { "fallbackOutput": "none" } }, "typeVersion": 3.2 }, { "id": "b3e2df39-90ce-4ebf-aa68-05499965ec30", "name": "Deduplicate Notifications", "type": "n8n-nodes-base.removeDuplicates", "position": [ 2280, -40 ], "parameters": { "options": {}, "operation": "removeItemsSeenInPreviousExecutions", "dedupeValue": "={{ $json.fields[\"Issue ID\"] }}:{{ $json.fields['Last Modified'] }}" }, "typeVersion": 2 }, { "id": "sentiment-notification-settings", "name": "Notification Settings", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 2400, -40 ], "parameters": { "mode": "manual", "assignments": { "assignments": [ { "id": "issue-url", "name": "issueUrlBase", "type": "string", "value": "https://linear.app/YOUR_ORGANIZATION/issue/" } ] }, "includeOtherFields": true, "options": {} } }, { "id": "sentiment-notices", "name": "Group Complete Transition Alerts", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 2620, -40 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "function escapeSentimentSlack(text){return text.replace(/&/g,'&').replace(//g,'>');}\nfunction prepareSentimentNotices({events,issueUrlBase}){\n if(!Array.isArray(events)||typeof issueUrlBase!=='string'||!/^https:\\/\\/linear\\.app\\/[a-zA-Z0-9_-]+\\/issue\\/$/.test(issueUrlBase))throw new Error('Configure the Linear organization issue URL.');\n const seen=new Set(),transitions=[];for(const event of events){const f=event.fields;if(!f||typeof f!=='object')throw new Error('Airtable event fields are missing.');if(f['Previous Sentiment']==='Negative'||f['Current Sentiment']!=='Negative')continue;for(const key of['Issue ID','Issue Title','Last Modified'])if(typeof f[key]!=='string'||!f[key])throw new Error('Negative transition metadata is incomplete.');if(!/^\\d{4}-\\d\\d-\\d\\dT/.test(f['Last Modified'])||!Number.isFinite(Date.parse(f['Last Modified'])))throw new Error('Last Modified must be an Airtable time field.');if(f.Summary!==undefined&&typeof f.Summary!=='string')throw new Error('Airtable summary is not text.');const key=f['Issue ID']+':'+f['Last Modified'];if(seen.has(key))continue;seen.add(key);transitions.push({...f});}\n const chunks=[],header={type:'section',text:{type:'mrkdwn',text:':rotating_light: The following issues transitioned to Negative Sentiment'}},divider={type:'divider'};let blocks=[header,divider];\n for(const f of transitions){const url=issueUrlBase+encodeURIComponent(f['Issue ID']),link='*<'+url+'|'+escapeSentimentSlack(f['Issue ID'])+'>* ';if(link.length>3000)throw new Error('Linear issue link exceeds one Slack section.');let segment=link;const parts=[];for(const character of f['Issue Title']+'\\n'+(f.Summary??'')){const token=escapeSentimentSlack(character);if(segment.length+token.length>3000){parts.push(segment);segment='';}segment+=token;}if(segment)parts.push(segment);for(const text of parts){if(blocks.length===50){chunks.push({blocks});blocks=[header,divider];}blocks.push({type:'section',text:{type:'mrkdwn',text}});}}\n if(blocks.length>2)chunks.push({blocks});return {messages:chunks.map((chunk,i)=>({...chunk,text:transitions.length+' issues transitioned to Negative Sentiment'+(chunks.length>1?' ('+(i+1)+'/'+chunks.length+')':'')})),count:transitions.length};\n}\n\nconst items=$input.all(),plan=prepareSentimentNotices({events:items.map(i=>({fields:i.json.fields})),issueUrlBase:items[0].json.issueUrlBase});return plan.messages.map(message=>({json:message,pairedItem:{item:0}}));" } }, { "id": "2a116475-32cd-4c9d-bfc1-3bd494f79a49", "name": "Report Issue Negative Transition", "type": "n8n-nodes-base.slack", "position": [ 2840, -40 ], "parameters": { "resource": "message", "operation": "post", "select": "channel", "channelId": { "__rl": true, "mode": "id", "value": "YOUR_SLACK_CHANNEL_ID" }, "messageType": "block", "text": "={{ $json.text }}", "blocksUi": "={{ {blocks:$json.blocks} }}", "otherOptions": { "unfurl_links": false, "unfurl_media": false, "includeLinkToWorkflow": false } }, "typeVersion": 2.3 }, { "id": "1f3d30b6-de31-45a8-a872-554c339f112f", "name": "Sticky Note", "type": "n8n-nodes-base.stickyNote", "position": [ -420, -320 ], "parameters": { "color": 7, "width": 660, "height": 440, "content": "## 1. Continuously Monitor Active Linear Issues\n[Learn more about the GraphQL node](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.graphql)\n\nTo keep up with the latest changes in our active Linear tickets, we'll need to use Linear's GraphQL endpoint because filtering is currently unavailable in the official Linear.app node.\n\nFor this demonstration, we'll check for updated tickets every 30mins." }, "typeVersion": 1 }, { "id": "9024512d-5cb9-4e9f-b6e1-495d1a32118a", "name": "Sticky Note1", "type": "n8n-nodes-base.stickyNote", "position": [ 260, -320 ], "parameters": { "color": 7, "width": 640, "height": 560, "content": "## 2. Sentiment Analysis on Current Issue Activity\n[Learn more about the Information Extractor node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.information-extractor)\n\nWith our recently updated posts, we can use our AI to perform a quick sentiment analysis on the ongoing conversation to check the overall mood of the support issue. This is a great way to check how things are generally going in the support queue; positive should be normal but negative could indicate some uncomfortableness or even frustration." }, "typeVersion": 1 }, { "id": "233ebd6d-38cb-4f2d-84b5-29c97d30d77b", "name": "Sticky Note2", "type": "n8n-nodes-base.stickyNote", "position": [ 920, -320 ], "parameters": { "color": 7, "width": 840, "height": 560, "content": "## 3. Capture and Track Results in Airtable\n[Learn more about the Airtable node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.airtable)\n\nNext, we can capture this analysis in our insights database as means for human review. When the issue is new, we can create a new row but if the issue exists, we will update it's existing row instead.\n\nWhen updating an existing row, we move its previous \"current sentiment\" value into the \"previous sentiment\" column and replace with our new current sentiment. This gives us a \"sentiment transition\" which will be useful in the next step.\n\nCheck out the Airtable here: Configure your own Airtable base and table; the original source links a demonstration base." }, "typeVersion": 1 }, { "id": "a2229225-b580-43cb-b234-4f69cb5924fd", "name": "Sticky Note3", "type": "n8n-nodes-base.stickyNote", "position": [ 1800, -320 ], "parameters": { "color": 7, "width": 920, "height": 560, "content": "## 4. Get Notified when Sentiment becomes Negative\n[Learn more about the Slack node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.slack/)\n\nA good use-case for tracking sentiment transitions could be to be alerted if ever an issue moves from a non-negative sentiment to a negative one. This could be a signal of issue handling troubles which may require attention before it escalates.\n\nIn this demonstration, we use the Airtable trigger to catch rows which have their sentiment column updated and check for the non-negative-to-negative sentiment transition using the switch node. For those matching rows, we combine add send a notification via slack. A cool trick is to use the \"remove duplication\" node to prevent repeat notifications for the same updates - here we combine the Linear issue key and the row's last modified date." }, "typeVersion": 1 }, { "id": "6f26769e-ec5d-46d0-ae0a-34148b24e6a2", "name": "Sticky Note4", "type": "n8n-nodes-base.stickyNote", "position": [ -940, -720 ], "parameters": { "width": 480, "height": 840, "content": "## Try It Out!\n### This n8n template performs continous monitoring on Linear Issue conversations performing sentiment analysis and alerting when the sentiment becomes negative.\nThis is helpful to quickly identify difficult customer support situations early and prioritising them before they get out of hand.\n\n## How it works\n* A scheduled trigger is used to fetch recently updated issues in Linear using the GraphQL node.\n* Each issue's comments thread is passed into a simple Information Extractor node to identify the overall sentiment.\n* The resulting sentiment analysis combined with the some issue details are uploaded to Airtable for review.\n* When the template is re-run at a later date, each issue is re-analysed for sentiment\n* Each issue's new sentiment state is saved to the airtable whilst its previous state is moved to the \"previous sentiment\" column.\n* An Airtable trigger is used to watch for recently updated rows\n* Each matching Airtable row is filtered to check if it has a previous non-negative state but now has a negative state in its current sentiment.\n* The results are sent via notification to a team slack channel for priority.\n\n**Check out the sample Airtable here**: Configure your own Airtable base and table; the original source links a demonstration base.\n\n## How to use\n* Modify the GraphQL filter to fetch issues to a relevant issue type, team or person.\n* Update the Slack channel to ensure messages are sent to the correct location.\n\n### Need Help?\nJoin the [Discord](https://discord.com/invite/XPKeKXeB7d) or ask in the [Forum](https://community.n8n.io/)!\n\nHappy Hacking!" }, "typeVersion": 1 } ], "pinData": {}, "connections": { "Update Row": { "main": [ [ { "node": "For Each Issue...", "type": "main", "index": 0 } ] ] }, "Copy of Issue": { "main": [ [ { "node": "Get Existing Sentiment", "type": "main", "index": 0 } ] ] }, "Issues to List": { "main": [ [ { "node": "Validate Issue Threads", "type": "main", "index": 0 } ] ] }, "Airtable Trigger": { "main": [ [ { "node": "Sentiment Transition", "type": "main", "index": 0 } ] ] }, "Schedule Trigger": { "main": [ [ { "node": "Fetch Active Linear Issues", "type": "main", "index": 0 } ] ] }, "For Each Issue...": { "main": [ [], [ { "node": "Copy of Issue", "type": "main", "index": 0 } ] ] }, "OpenAI Chat Model": { "ai_languageModel": [ [ { "node": "Sentiment over Issue Comments", "type": "ai_languageModel", "index": 0 } ] ] }, "Sentiment Transition": { "main": [ [ { "node": "Deduplicate Notifications", "type": "main", "index": 0 } ] ] }, "Get Existing Sentiment": { "main": [ [ { "node": "Validate Previous Sentiment", "type": "main", "index": 0 } ] ] }, "Deduplicate Notifications": { "main": [ [ { "node": "Notification Settings", "type": "main", "index": 0 } ] ] }, "Combine Sentiment Analysis": { "main": [ [ { "node": "For Each Issue...", "type": "main", "index": 0 } ] ] }, "Fetch Active Linear Issues": { "main": [ [ { "node": "Issues to List", "type": "main", "index": 0 } ] ] }, "Sentiment over Issue Comments": { "main": [ [ { "node": "Combine Sentiment Analysis", "type": "main", "index": 0 } ] ] }, "Validate Issue Threads": { "main": [ [ { "node": "Sentiment over Issue Comments", "type": "main", "index": 0 } ] ] }, "Validate Previous Sentiment": { "main": [ [ { "node": "Update Row", "type": "main", "index": 0 } ] ] }, "Notification Settings": { "main": [ [ { "node": "Group Complete Transition Alerts", "type": "main", "index": 0 } ] ] }, "Group Complete Transition Alerts": { "main": [ [ { "node": "Report Issue Negative Transition", "type": "main", "index": 0 } ] ] } }, "name": "Linear Support Sentiment to Slack", "settings": { "timezone": "UTC", "executionOrder": "v1" }, "active": false }