mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
cd3f5b5b1f
Fix template credential setup for templates whose workflow includes nodes that require credentials but the workflow definition does not have them defined. Like for example https://n8n.io/workflows/1344-save-email-attachments-to-nextcloud/
183 lines
11 KiB
JSON
183 lines
11 KiB
JSON
{
|
|
"workflow": {
|
|
"id": 1344,
|
|
"name": "Save email attachments to Nextcloud",
|
|
"views": 650,
|
|
"recentViews": 9887,
|
|
"totalViews": 650,
|
|
"createdAt": "2021-11-29T13:59:16.771Z",
|
|
"description": "This workflow will take all emails you put into a certain folder, upload any attachements to Nextcloud, and mark the emails as read (configurable).\n\nAttachements will be saved with automatically generated filenames:\n`2021-01-01_From-Sender-Name_Filename-of-attachement.pdf`\n\nInstructions:\n1. **Allow lodash to be used in n8n** (or rewrite the code...)\n `NODE_FUNCTION_ALLOW_EXTERNAL=lodash` (environment variable)\n2. Import workflow\n3. Set credentials for Email & Nextcloud nodes\n4. Configure to use correct folder / custom filters\n5. Activate\n\nCustom filter examples:\n- Only unread emails:\n `Custom Email Config` = `[\"UNSEEN\"]`\n- Filter emails by 'to' address:\n `Custom Email Config` = `[[\"TO\", \"example+invoices@posteo.de\"]]`",
|
|
"workflow": {
|
|
"nodes": [
|
|
{
|
|
"name": "IMAP Email",
|
|
"type": "n8n-nodes-base.emailReadImap",
|
|
"position": [
|
|
240,
|
|
420
|
|
],
|
|
"parameters": {
|
|
"format": "resolved",
|
|
"mailbox": "Invoices",
|
|
"options": {
|
|
"customEmailConfig": "[\"ALL\"]"
|
|
}
|
|
},
|
|
"typeVersion": 1
|
|
},
|
|
{
|
|
"name": "Nextcloud",
|
|
"type": "n8n-nodes-base.nextCloud",
|
|
"position": [
|
|
940,
|
|
420
|
|
],
|
|
"parameters": {
|
|
"path": "=Documents/Invoices/{{$json[\"date\"]}}_{{$json[\"from\"]}}_{{$binary.file.fileName}}",
|
|
"binaryDataUpload": true,
|
|
"binaryPropertyName": "file"
|
|
},
|
|
"typeVersion": 1
|
|
},
|
|
{
|
|
"name": "Map each attachment",
|
|
"type": "n8n-nodes-base.function",
|
|
"position": [
|
|
620,
|
|
420
|
|
],
|
|
"parameters": {
|
|
"functionCode": "const _ = require('lodash')\n\nconst sanitize = str => _.chain(str)\n .replace(/[^A-Za-z0-9&.-]/g, '-') // sanitise via whitelist of characters\n .replace(/-(?=-)/g, '') // remove repeated dashes - https://regexr.com/6ag8h\n .trim('-') // trim any leading/trailing dashes\n .truncate({\n length: 60,\n omission: '-' // when the string ends with '-', you'll know it was truncated\n })\n .value()\n\nconst result = _.flatMap(items.map(item => {\n //console.log({item})\n\n // Maps each attachment to a separate item\n return _.values(item.binary).map(file => {\n console.log(\"Saving attachement:\", file.fileName, 'from:', ...item.json.from.value)\n \n // sanitize filename but exclude extension\n const filename_parts = file.fileName.split('.')\n const ext = _.slice(filename_parts, filename_parts.length-1)\n const filename_main = _.join(_.dropRight(filename_parts), '.')\n file.fileName = sanitize(filename_main) + '.' + ext\n \n return {\n json: {\n from: sanitize(item.json.from.value[0].name),\n date: sanitize(new Date(item.json.date).toISOString().split(\"T\")[0]) // get date part \"2020-01-01\"\n }, \n binary: { file }\n }\n })\n}))\n\n//console.log(result)\nreturn result"
|
|
},
|
|
"typeVersion": 1
|
|
}
|
|
],
|
|
"connections": {
|
|
"IMAP Email": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Map each attachment",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Map each attachment": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Nextcloud",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"lastUpdatedBy": 11,
|
|
"workflowInfo": {
|
|
"nodeCount": 3,
|
|
"nodeTypes": {
|
|
"n8n-nodes-base.function": {
|
|
"count": 1
|
|
},
|
|
"n8n-nodes-base.nextCloud": {
|
|
"count": 1
|
|
},
|
|
"n8n-nodes-base.emailReadImap": {
|
|
"count": 1
|
|
}
|
|
}
|
|
},
|
|
"user": {
|
|
"username": "tennox"
|
|
},
|
|
"nodes": [
|
|
{
|
|
"id": 10,
|
|
"icon": "fa:inbox",
|
|
"name": "n8n-nodes-base.emailReadImap",
|
|
"defaults": {
|
|
"name": "Email Trigger (IMAP)",
|
|
"color": "#44AA22"
|
|
},
|
|
"iconData": {
|
|
"icon": "inbox",
|
|
"type": "icon"
|
|
},
|
|
"categories": [
|
|
{
|
|
"id": 6,
|
|
"name": "Communication"
|
|
},
|
|
{
|
|
"id": 9,
|
|
"name": "Core Nodes"
|
|
}
|
|
],
|
|
"displayName": "Email Trigger (IMAP)",
|
|
"typeVersion": 2
|
|
},
|
|
{
|
|
"id": 14,
|
|
"icon": "fa:code",
|
|
"name": "n8n-nodes-base.function",
|
|
"defaults": {
|
|
"name": "Function",
|
|
"color": "#FF9922"
|
|
},
|
|
"iconData": {
|
|
"icon": "code",
|
|
"type": "icon"
|
|
},
|
|
"categories": [
|
|
{
|
|
"id": 5,
|
|
"name": "Development"
|
|
},
|
|
{
|
|
"id": 9,
|
|
"name": "Core Nodes"
|
|
}
|
|
],
|
|
"displayName": "Function",
|
|
"typeVersion": 1
|
|
},
|
|
{
|
|
"id": 25,
|
|
"icon": "file:nextcloud.svg",
|
|
"name": "n8n-nodes-base.nextCloud",
|
|
"defaults": {
|
|
"name": "Nextcloud"
|
|
},
|
|
"iconData": {
|
|
"type": "file",
|
|
"fileBuffer": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2aWV3Qm94PSIwIDAgNzYgNTEiIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPjx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Nextcloud",
|
|
"typeVersion": 1
|
|
}
|
|
],
|
|
"categories": [
|
|
{
|
|
"id": 2,
|
|
"name": "Sales"
|
|
},
|
|
{
|
|
"id": 8,
|
|
"name": "Finance & Accounting"
|
|
}
|
|
],
|
|
"image": []
|
|
}
|
|
}
|