Last active
October 13, 2024 18:09
-
-
Save albertopasqualetto/05bbb4b82068ae945678942e93b248a4 to your computer and use it in GitHub Desktop.
n8n Todoist -> MS To Do Workflow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Todoist -> MS To Do", | |
"nodes": [ | |
{ | |
"parameters": { | |
"dataType": "string", | |
"value1": "={{ $json[\"body\"][\"event_name\"] }}", | |
"rules": { | |
"rules": [ | |
{ | |
"value2": "item:completed" | |
}, | |
{ | |
"value2": "item:deleted" | |
}, | |
{ | |
"value2": "item:uncompleted" | |
}, | |
{ | |
"value2": "item:updated" | |
}, | |
{ | |
"value2": "item:added", | |
"output": 1 | |
} | |
] | |
} | |
}, | |
"id": "7619a118-7cb2-4402-a7b8-afa5b1c98446", | |
"name": "Switch", | |
"type": "n8n-nodes-base.switch", | |
"typeVersion": 1, | |
"position": [ | |
660, | |
300 | |
] | |
}, | |
{ | |
"parameters": { | |
"operation": "create", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"title": "={{ $node[\"Todoist webhook\"].json[\"body\"][\"event_data\"][\"content\"] }}", | |
"additionalFields": { | |
"content": "={{ $json[\"body\"][\"event_data\"][\"id\"] }}", | |
"dueDateTime": "={{ $node[\"Set daily tasks at 8\"].json.body.event_data.due.date }}", | |
"reminderDateTime": "={{ $node[\"Set daily tasks at 8\"].json.body.event_data.due.date }}" | |
} | |
}, | |
"id": "bc490ed5-13ed-4826-82b8-263f114ffa84", | |
"name": "Microsoft To Do", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
860, | |
460 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"dataType": "string", | |
"value1": "={{ $node[\"Todoist webhook\"].json.body.event_name }}", | |
"rules": { | |
"rules": [ | |
{ | |
"value2": "item:completed" | |
}, | |
{ | |
"value2": "item:uncompleted", | |
"output": 1 | |
}, | |
{ | |
"value2": "item:deleted", | |
"output": 2 | |
}, | |
{ | |
"value2": "item:updated", | |
"output": 3 | |
} | |
] | |
} | |
}, | |
"id": "9a437ea7-89f9-44d8-87ee-048fd6bbf09c", | |
"name": "Switch1", | |
"type": "n8n-nodes-base.switch", | |
"typeVersion": 1, | |
"position": [ | |
1140, | |
160 | |
] | |
}, | |
{ | |
"parameters": { | |
"operation": "update", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"taskId": "={{ $json.idModifiedTask }}", | |
"updateFields": { | |
"status": "completed" | |
} | |
}, | |
"id": "3959d51d-3b9f-4ff9-a697-2d469af1811a", | |
"name": "Complete", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
1400, | |
-20 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"operation": "update", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"taskId": "={{ $json.idModifiedTask }}", | |
"updateFields": { | |
"status": "notStarted" | |
} | |
}, | |
"id": "e18e06ac-b7d8-4447-954b-a002450f2158", | |
"name": "Uncomplete", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
1400, | |
120 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"operation": "delete", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"taskId": "={{ $json.idModifiedTask }}" | |
}, | |
"id": "5e1fcc41-cc5e-44c5-8498-e8765e08d073", | |
"name": "Delete", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
1400, | |
260 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"jsCode": "const idModifiedTask = $('Switch').first(0).json.body.event_data.id;\n\nfor (const item of $input.all()) {\n const thisTaskId = item.json.body.content.replace(/(\\r\\n|\\n|\\r)/gm, \"\");\n\n if (thisTaskId == idModifiedTask){\n console.log(item.json.id);\n return [{\"idModifiedTask\": item.json.id}];\n }\n}\n\nreturn null;" | |
}, | |
"id": "ec212005-7a51-4b77-8792-0c19e27c7d48", | |
"name": "Search modified task id", | |
"type": "n8n-nodes-base.code", | |
"typeVersion": 1, | |
"position": [ | |
1000, | |
160 | |
], | |
"alwaysOutputData": false | |
}, | |
{ | |
"parameters": { | |
"operation": "getAll", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"returnAll": true | |
}, | |
"id": "2fed542e-8902-4dd5-b67c-3640c2395f8a", | |
"name": "Get all tasks", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
860, | |
160 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"operation": "update", | |
"taskListId": "AQMkADAwATZiZmYAZC1kM2Y4LWExMQEtMDACLTAwCgAuAAADxeeKEHDPzUyDqR_uGHvsGAEAMb92IcD1v0mQrgs56Rc_ygAAAgESAAAA", | |
"taskId": "={{ $json.idModifiedTask }}", | |
"updateFields": { | |
"dueDateTime": "={{ $node[\"Set daily tasks at 8\"].json.body.event_data.due.date }}", | |
"reminderDateTime": "={{ $node[\"Set daily tasks at 8\"].json.body.event_data.due.date }}", | |
"title": "={{ $node[\"Todoist webhook\"].json.body.event_data.content }}" | |
} | |
}, | |
"id": "1127402c-afb0-4b15-97db-3b748f06d957", | |
"name": "Update", | |
"type": "n8n-nodes-base.microsoftToDo", | |
"typeVersion": 1, | |
"position": [ | |
1400, | |
400 | |
], | |
"credentials": { | |
"microsoftToDoOAuth2Api": { | |
"id": "3", | |
"name": "Microsoft To Do account" | |
} | |
} | |
}, | |
{ | |
"parameters": { | |
"mode": "runOnceForEachItem", | |
"jsCode": "if ($input.item.json.body.event_data.due && !($input.item.json.body.event_data.due.date).includes(\"T\"))\n $input.item.json.body.event_data.due.date = $input.item.json.body.event_data.due.date + \"T08:00:00\"\n\nreturn $input.item;" | |
}, | |
"id": "245c9144-b97b-4334-b0c9-9f492ee60a69", | |
"name": "Set daily tasks at 8", | |
"type": "n8n-nodes-base.code", | |
"typeVersion": 2, | |
"position": [ | |
520, | |
300 | |
] | |
}, | |
{ | |
"parameters": { | |
"content": "Update probably not updating due date" | |
}, | |
"id": "9c84b7a4-00a7-4a0a-8773-ae7990d08e34", | |
"name": "Sticky Note", | |
"type": "n8n-nodes-base.stickyNote", | |
"typeVersion": 1, | |
"position": [ | |
1500, | |
480 | |
] | |
}, | |
{ | |
"parameters": { | |
"httpMethod": "POST", | |
"path": "0bf6c02a-9e23-4196-897e-4ac3eee2aca9", | |
"options": {} | |
}, | |
"id": "03d1a34d-f930-485e-b414-06991cd5763b", | |
"name": "Todoist webhook", | |
"type": "n8n-nodes-base.webhook", | |
"typeVersion": 1, | |
"position": [ | |
360, | |
300 | |
], | |
"webhookId": "0bf6c02a-9e23-4196-897e-4ac3eee2aca9" | |
} | |
], | |
"pinData": {}, | |
"connections": { | |
"Switch": { | |
"main": [ | |
[ | |
{ | |
"node": "Get all tasks", | |
"type": "main", | |
"index": 0 | |
} | |
], | |
[ | |
{ | |
"node": "Microsoft To Do", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
}, | |
"Switch1": { | |
"main": [ | |
[ | |
{ | |
"node": "Complete", | |
"type": "main", | |
"index": 0 | |
} | |
], | |
[ | |
{ | |
"node": "Uncomplete", | |
"type": "main", | |
"index": 0 | |
} | |
], | |
[ | |
{ | |
"node": "Delete", | |
"type": "main", | |
"index": 0 | |
} | |
], | |
[ | |
{ | |
"node": "Update", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
}, | |
"Search modified task id": { | |
"main": [ | |
[ | |
{ | |
"node": "Switch1", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
}, | |
"Get all tasks": { | |
"main": [ | |
[ | |
{ | |
"node": "Search modified task id", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
}, | |
"Set daily tasks at 8": { | |
"main": [ | |
[ | |
{ | |
"node": "Switch", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
}, | |
"Todoist webhook": { | |
"main": [ | |
[ | |
{ | |
"node": "Set daily tasks at 8", | |
"type": "main", | |
"index": 0 | |
} | |
] | |
] | |
} | |
}, | |
"active": true, | |
"settings": { | |
"callerPolicy": "workflowsFromSameOwner", | |
"executionTimeout": -1, | |
"executionOrder": "v1" | |
}, | |
"versionId": "f4c7fcf5-07e5-417c-bf97-f11897971243", | |
"meta": { | |
"templateCredsSetupCompleted": true, | |
"instanceId": "afd7366da62d1095b6c121d8d0e307c83f533aff9f88ae1b32ceeb870082a204" | |
}, | |
"id": "1", | |
"tags": [ | |
{ | |
"createdAt": "2024-10-10T22:46:06.991Z", | |
"updatedAt": "2024-10-10T22:46:06.991Z", | |
"id": "1", | |
"name": "Todo list" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment