AutomationFlowsData & Sheets › Sync Tasks Data Between Notion And Asana

Sync Tasks Data Between Notion And Asana

Sync Tasks Data Between Notion And Asana. Uses notion, asana, asanaTrigger. Event-driven trigger; 10 nodes.

Event trigger★★★★☆ complexity10 nodesNotionAsanaAsana Trigger
Data & Sheets Trigger: Event Nodes: 10 Complexity: ★★★★☆

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "daaa472a-fff3-41e2-9b6f-f7f54655ea16",
      "name": "Determine create/update",
      "type": "n8n-nodes-base.if",
      "position": [
        1380,
        300
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"action\"] }}",
              "value2": "Create"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1b047238-80b4-4144-929d-f860510b68c6",
      "name": "Update task",
      "type": "n8n-nodes-base.notion",
      "position": [
        1580,
        420
      ],
      "parameters": {
        "pageId": "={{ $json[\"database_id\"] }}",
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Task|title",
              "title": "={{ $json[\"name\"] }}"
            },
            {
              "key": "Deadline|date",
              "date": "={{ $json[\"due_on\"] }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "71801502-14bd-42d2-beb9-e44e90bcac49",
      "name": "Create task",
      "type": "n8n-nodes-base.notion",
      "position": [
        1580,
        180
      ],
      "parameters": {
        "title": "={{$json[\"name\"]}}",
        "resource": "databasePage",
        "databaseId": "6181df20-c949-42e3-9999-7168d746efab",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Asana GID|number",
              "numberValue": "={{ parseInt($json[\"gid\"]) }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 2
    },
    {
      "id": "76d95145-89ff-477f-9e28-a64c3601b4ea",
      "name": "Get tasks",
      "type": "n8n-nodes-base.asana",
      "position": [
        780,
        300
      ],
      "parameters": {
        "id": "={{ $json[\"gid\"] }}",
        "operation": "get"
      },
      "credentials": {
        "asanaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "b79c96eb-ad00-4aa7-b02e-306a940396fc",
      "name": "Find tasks",
      "type": "n8n-nodes-base.notion",
      "position": [
        980,
        160
      ],
      "parameters": {
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": "6181df20-c949-42e3-9999-7168d746efab",
        "filterJson": "={{$node[\"Get unique tasks\"].json[\"notionfilter\"]}}",
        "filterType": "json"
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9804b81f-b2f9-45dc-9bbd-a652543668fd",
      "name": "Get unique tasks",
      "type": "n8n-nodes-base.function",
      "position": [
        580,
        300
      ],
      "parameters": {
        "functionCode": "const gids = [];\n\n// get all the unique Asana task gids\nfor (item of items) {\n  var gid = parseInt(item.json.resource.gid);\n  var resource_type = item.json.resource.resource_type;\n  if (!(gids.includes(gid)) && resource_type == \"task\") {\n    gids.push(gid);\n  }\n}\n\n// show in output\nconst new_items = [];\nfor (gid of gids) {\n  var new_item = {\n    \"json\": {\n      \"gid\": 0,\n      \"gids\": [],\n      \"notionfilter\": \"\"\n    }\n  };\n  new_item = JSON.stringify(new_item);\n  new_item = JSON.parse(new_item);\n  new_item.json.gid = gid;\n  new_item.json.gids = gids;\n  new_items.push(new_item);\n\n  // Notion filter\n  notionfilter = {\n    or: [],\n  }\n\n  for (gid of gids) {\n    const filter = {\n      property: 'Asana GID',\n      number: {\n        equals: gid\n      }\n    }\n    notionfilter[\"or\"].push(filter);\n  }\n\n\n  new_item.json.notionfilter = JSON.stringify(notionfilter); \n}\n\nconsole.log(gids);\nreturn new_items;"
      },
      "executeOnce": false,
      "typeVersion": 1
    },
    {
      "id": "91883ca1-91f8-41ce-84d5-00f9f3296cc7",
      "name": "Determine",
      "type": "n8n-nodes-base.function",
      "position": [
        1180,
        300
      ],
      "parameters": {
        "functionCode": "const gids_to_update = [];\nconst database_ids = [];\n\nfor (item of $items(\"Find tasks\")) {\n  gids_to_update.push(parseInt(item.json.property_asana_gid));\n  database_ids.push(item.json.id);\n}\nconsole.log(gids_to_update);\nconsole.log(database_ids);\n\nvar gid;\nlet i = 0;\nfor (item of $items(\"Get tasks\")) {\n  gid = parseInt(item.json.gid);\n  if (gids_to_update.includes(gid)) {\n    item.json.action = \"Update\"\n    item.json.database_id = database_ids[i];\n  } else {\n    item.json.action = \"Create\"\n  }\n  i++;\n}\n\nreturn $items(\"Get tasks\");"
      },
      "typeVersion": 1
    },
    {
      "id": "8ba512bb-671a-47d2-88fc-19ed358df728",
      "name": "Check required fields exist",
      "type": "n8n-nodes-base.if",
      "position": [
        1780,
        180
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $node[\"Determine\"].json[\"due_on\"] }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "512a09e0-c595-4613-a4d9-ed3160fd403b",
      "name": "Update deadline",
      "type": "n8n-nodes-base.notion",
      "position": [
        1980,
        180
      ],
      "parameters": {
        "pageId": "={{ $json[\"id\"] }}",
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Deadline|date",
              "date": "={{ $node[\"Determine\"].json[\"due_on\"] }}"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "4b08a930-93ef-4f88-8109-9afa45af703e",
      "name": "On update",
      "type": "n8n-nodes-base.asanaTrigger",
      "position": [
        380,
        300
      ],
      "parameters": {
        "resource": "1202718722261680",
        "workspace": "1177253494675264"
      },
      "credentials": {
        "asanaApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Determine": {
      "main": [
        [
          {
            "node": "Determine create/update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get tasks": {
      "main": [
        [
          {
            "node": "Find tasks",
            "type": "main",
            "index": 0
          },
          {
            "node": "Determine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On update": {
      "main": [
        [
          {
            "node": "Get unique tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find tasks": {
      "main": [
        [
          {
            "node": "Determine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create task": {
      "main": [
        [
          {
            "node": "Check required fields exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get unique tasks": {
      "main": [
        [
          {
            "node": "Get tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Determine create/update": {
      "main": [
        [
          {
            "node": "Create task",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check required fields exist": {
      "main": [
        [
          {
            "node": "Update deadline",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

About this workflow

Sync Tasks Data Between Notion And Asana. Uses notion, asana, asanaTrigger. Event-driven trigger; 10 nodes.

Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →