AutomationFlowsData & Sheets › Ensure User

Ensure User

Ensure_User. Uses executeWorkflowTrigger, googleSheets. Event-driven trigger; 9 nodes.

Event trigger★★★★☆ complexity9 nodesExecute Workflow TriggerGoogle Sheets
Data & Sheets Trigger: Event Nodes: 9 Complexity: ★★★★☆ Added:

This workflow follows the Execute Workflow Trigger → Google Sheets recipe pattern — see all workflows that pair these two integrations.

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
{
  "name": "Ensure_User",
  "nodes": [
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "chat_id"
            },
            {
              "name": "username"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        0
      ],
      "id": "8126456a-fde1-41cb-95d1-ec7e4dfc797e",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1jf9i07TJb_A6dWc9Q42DwJQ2QFORunelvuat3l319ks",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "users",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jf9i07TJb_A6dWc9Q42DwJQ2QFORunelvuat3l319ks/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        -96
      ],
      "id": "e0135e02-1e8e-445a-ba4a-79a563b142ce",
      "name": "Users_Read",
      "alwaysOutputData": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Always fetch the frozen values from the Inputs node\nconst uid = String($item(0).$node[\"Inputs\"].json.uid || \"\");\nconst username = $item(0).$node[\"Inputs\"].json.username || \"\";\n\n// Pull rows produced by Users_Read (may be 0)\nconst rows = ($items(\"Users_Read\") || []).map(i => i.json);\n\n// Compare user_id with uid\nconst exists = rows.some(r => String(r.user_id) === uid);\n\nreturn [{ uid, username, exists }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        672,
        0
      ],
      "id": "76cd6832-4bf2-424c-834f-790d5edde2d9",
      "name": "Ensure_Logic"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "00b9d842-1d4e-44be-81d4-399260dabae5",
              "leftValue": "={{$json.exists}}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            },
            {
              "id": "46924421-a2fc-4bf3-9587-2824d4369f83",
              "leftValue": "",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        896,
        0
      ],
      "id": "3828da72-8b54-49b2-a0ac-4a779426d5b8",
      "name": "IF_UserExists"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1jf9i07TJb_A6dWc9Q42DwJQ2QFORunelvuat3l319ks",
          "mode": "list",
          "cachedResultName": "Fasting Tracker",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jf9i07TJb_A6dWc9Q42DwJQ2QFORunelvuat3l319ks/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "users",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1jf9i07TJb_A6dWc9Q42DwJQ2QFORunelvuat3l319ks/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "user_id": "={{$json.uid}}",
            "created_at_utc": "={{ new Date().toISOString() }}",
            "username": "={{$json.username}}",
            "tz_offset_min": "={{180}}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "user_id",
              "displayName": "user_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at_utc",
              "displayName": "created_at_utc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "username",
              "displayName": "username",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "tz_offset_min",
              "displayName": "tz_offset_min",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1120,
        80
      ],
      "id": "88c92e6c-3390-4deb-87c1-d2b8973382cc",
      "name": "Users_Create",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3be7ab6f-149b-4b5e-9495-f0a8e01d85a4",
              "name": "uid",
              "value": "={{ String($json.chat_id) }}",
              "type": "string"
            },
            {
              "id": "34fb3ab5-59bd-4320-a170-4afd087536a3",
              "name": "username",
              "value": "={{ $json.username || '' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        96
      ],
      "id": "d59adcdc-a136-4bf5-abc4-5bf35151173e",
      "name": "Inputs"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        448,
        0
      ],
      "id": "c69c278f-1426-4e2d-884b-7f6502fd4caa",
      "name": "Join_Users"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1344,
        0
      ],
      "id": "5713edba-6585-4f2c-9861-6888f2dcf509",
      "name": "Merge"
    },
    {
      "parameters": {
        "jsCode": "// Inputs available here: uid, username from the parent; users row from Users_Read\nconst uid = String($json.uid || $item(0).$node[\"When Executed by Another Workflow\"].json.chat_id || \"\");\nconst row = $json.user_row || {};   // however you\u2019re holding the matched users row\n\n// Robust fallbacks\nconst toPos = (v, d) => {\n  const n = Number(v);\n  return Number.isFinite(n) && n > 0 ? n : d;\n};\n\nconst profile = {\n  uid,\n  username: $json.username || \"\",\n  goalH: toPos(row.goal_hours, 16),\n  tzOffsetMin: Number(row.tz_offset_min ?? 0) || 0,\n  pct_list: (row.pct_list || \"50,75,90,100\"),\n  past_goal_every_min: Number(row.past_goal_every_min) || 60,\n  eat_nudge_hours: (row.eat_nudge_hours || \"6,8,10\")\n};\n\n// return only what the parent needs\nreturn [ profile ];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1552,
        0
      ],
      "id": "d9831129-4c99-49d8-9b30-0b01e86027ea",
      "name": "Return_UserProfile"
    }
  ],
  "connections": {
    "Users_Read": {
      "main": [
        [
          {
            "node": "Join_Users",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ensure_Logic": {
      "main": [
        [
          {
            "node": "IF_UserExists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF_UserExists": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Users_Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inputs": {
      "main": [
        [
          {
            "node": "Join_Users",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Join_Users": {
      "main": [
        [
          {
            "node": "Ensure_Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Users_Read",
            "type": "main",
            "index": 0
          },
          {
            "node": "Inputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Users_Create": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Return_UserProfile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ade2883a-0838-421b-be4b-e4be81165efc",
  "id": "ZpltDIh7Zqrc7mZh",
  "tags": []
}

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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Ensure_User. Uses executeWorkflowTrigger, googleSheets. Event-driven trigger; 9 nodes.

Source: https://github.com/yanairon/fast-tracker/blob/e1388b18364e08d5b8b7bdceb7bce30cee83dc8b/workflows/Ensure_User.json — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

Google Maps Email Scraper Template. Uses removeDuplicates, splitInBatches, httpRequest, splitOut. Event-driven trigger; 26 nodes.

HTTP Request, Google Sheets, Execute Workflow Trigger
Data & Sheets

Splitout Comparedatasets. Uses manualTrigger, gong, stickyNote, executeWorkflow. Event-driven trigger; 26 nodes.

Gong, Execute Workflow Trigger, Google Sheets +1
Data & Sheets

Streamline your sales call analysis with CallForge, an automated workflow that extracts, enriches, and refines Gong.io call data for AI-driven insights.

Gong, Execute Workflow Trigger, Google Sheets +1
Data & Sheets

Email Scapper. Uses httpRequest, googleSheets, executeWorkflowTrigger. Event-driven trigger; 26 nodes.

HTTP Request, Google Sheets, Execute Workflow Trigger
Data & Sheets

ITHome比賽進程. Uses httpRequest, googleSheets, executeWorkflowTrigger, n8n. Event-driven trigger; 25 nodes.

HTTP Request, Google Sheets, Execute Workflow Trigger +1