Spaces:
Sleeping
Sleeping
File size: 7,278 Bytes
51d1d83 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
{
"meta": {
"instanceId": "237600ca44303ce91fa31ee72babcdc8493f55ee2c0e8aa2b78b3b4ce6f70bd9"
},
"nodes": [
{
"id": "b220e0c7-3c34-4221-8fee-11c133a5345b",
"name": "Get ticket",
"type": "n8n-nodes-base.zendesk",
"position": [
740,
540
],
"parameters": {
"id": "={{$node[\"On new Zendesk ticket\"].json[\"body\"][\"id\"]}}",
"operation": "get"
},
"credentials": {
"zendeskApi": {
"id": "24",
"name": "[UPDATE ME]"
}
},
"typeVersion": 1
},
{
"id": "e58834a7-1a94-429f-a50c-2e27293c32a0",
"name": "IF",
"type": "n8n-nodes-base.if",
"position": [
1140,
540
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$node[\"Determine\"].json[\"Slack Thread ID\"]}}",
"operation": "isNotEmpty"
}
]
}
},
"typeVersion": 1
},
{
"id": "c6f82ab9-54f4-4f91-a4d9-018739c6519d",
"name": "Update ticket",
"type": "n8n-nodes-base.zendesk",
"notes": "Update the Zendesk ticket by adding the Jira issue key to the \"Jira Issue Key\" field.",
"position": [
1540,
640
],
"parameters": {
"id": "={{$node[\"On new Zendesk ticket\"].json[\"body\"][\"id\"]}}",
"operation": "update",
"updateFields": {
"customFieldsUi": {
"customFieldsValues": [
{
"id": 7022397804317,
"value": "={{$node[\"Create thread\"].json[\"ts\"]}}"
}
]
}
}
},
"credentials": {
"zendeskApi": {
"id": "24",
"name": "[UPDATE ME]"
}
},
"notesInFlow": true,
"typeVersion": 1
},
{
"id": "74d93ba5-d82d-4cc4-a177-bd86dbc18534",
"name": "On new Zendesk ticket",
"type": "n8n-nodes-base.webhook",
"position": [
540,
540
],
"webhookId": "b7845b15-0a44-4be5-b513-f4f4bb8989a6",
"parameters": {
"path": "b7845b15-0a44-4be5-b513-f4f4bb8989a6",
"options": {},
"httpMethod": "POST"
},
"typeVersion": 1
},
{
"id": "65d387cd-5c7a-4567-9a3c-9fa033f98ac9",
"name": "Create thread",
"type": "n8n-nodes-base.slack",
"position": [
1340,
640
],
"parameters": {
"text": "={{$node[\"Get ticket\"].json[\"subject\"]}}",
"channel": "={{$node[\"Configure\"].parameter[\"values\"][\"string\"][0][\"value\"]}}",
"attachments": [],
"otherOptions": {},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "28",
"name": "[UPDATE ME]"
}
},
"typeVersion": 1
},
{
"id": "50f5aa84-70bc-4b08-a9cc-576fbed72636",
"name": "Create reply on existing thread",
"type": "n8n-nodes-base.slack",
"position": [
1340,
440
],
"parameters": {
"text": "={{$node[\"On new Zendesk ticket\"].json[\"body\"][\"comment\"]}}",
"channel": "={{$node[\"Configure\"].parameter[\"values\"][\"string\"][0][\"value\"]}}",
"attachments": [],
"otherOptions": {
"thread_ts": "={{$node[\"Determine\"].json[\"Slack Thread ID\"]}}"
},
"authentication": "oAuth2"
},
"credentials": {
"slackOAuth2Api": {
"id": "28",
"name": "[UPDATE ME]"
}
},
"typeVersion": 1
},
{
"id": "6d5e8df0-4b0b-487c-81be-93359976dd90",
"name": "Configure",
"type": "n8n-nodes-base.set",
"position": [
540,
360
],
"parameters": {
"values": {
"string": [
{
"name": "Slack channel",
"value": "#zendesk-updates"
}
]
},
"options": {
"dotNotation": false
}
},
"typeVersion": 1
},
{
"id": "934b95bb-2ffa-40a4-a2ca-02cfd646dd78",
"name": "Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-20,
360
],
"parameters": {
"width": 469.4813676974197,
"height": 268.2900466166276,
"content": "## Sync Zendesk tickets to Slack threads\n### Setup\n1. Add your [Zendesk credential](https://docs.n8n.io/integrations/builtin/credentials/zendesk/) to the `Get ticket` and `Update ticket` nodes.\n2. Add your [Slack credential](https://docs.n8n.io/integrations/builtin/credentials/slack/) to `Create Thread` and `Create reply on existing thread` nodes.\n3. Open `Configure` node and change \"Slack channel\" value to your slack channel (like #zendesk-updates).\n4. Activate the workflow so it runs automatically each time a Zendesk ticket is created."
},
"typeVersion": 1
},
{
"id": "b582f7ff-7cc6-48dc-89fc-bc8bde13b06e",
"name": "Code",
"type": "n8n-nodes-base.code",
"notes": "if thread was created already in Slack",
"position": [
940,
540
],
"parameters": {
"jsCode": "/* configure here =========================================================== */\n/* Zendesk field ID which represents the \"Slack Thread ID\" field.\n*/\nconst ISSUE_KEY_FIELD_ID = 7022397804317;\n\n/* ========================================================================== */\nnew_items = [];\n\nfor (item of $items(\"Get ticket\")) {\n \n // instantiate a new variable for status\n var custom_fields = item.json[\"custom_fields\"];\n var slack_thread_id = \"\";\n for (var i = 0; i < custom_fields.length; i++) {\n if (custom_fields[i].id == ISSUE_KEY_FIELD_ID) {\n slack_thread_id = custom_fields[i].value;\n break;\n }\n }\n\n // push the new item to the new_items array\n new_items.push({\n \"Slack Thread ID\": slack_thread_id\n });\n}\n\nreturn new_items;"
},
"notesInFlow": true,
"typeVersion": 1
}
],
"connections": {
"IF": {
"main": [
[
{
"node": "Create reply on existing thread",
"type": "main",
"index": 0
}
],
[
{
"node": "Create thread",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"Get ticket": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Create thread": {
"main": [
[
{
"node": "Update ticket",
"type": "main",
"index": 0
}
]
]
},
"On new Zendesk ticket": {
"main": [
[
{
"node": "Get ticket",
"type": "main",
"index": 0
}
]
]
}
}
} |