Automatisation de l'attribution aléatoire des tâches ménagères avec Google Sheets et les notifications Gmail

Intermédiaire

Ceci est uncontenant 15 nœuds.Utilise principalement des nœuds comme Code, Gmail, GoogleSheets, ScheduleTrigger. Automatisation de l'attribution aléatoire des tâches ménagères avec Google Sheets et les notifications Gmail

Prérequis
  • Compte Google et informations d'identification Gmail API
  • Informations d'identification Google Sheets API

Catégorie

-
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "meta": {
    "instanceId": "0867aa2e4fb4e86d170a6ca997a164fd02d27420eb0e7cb54482c4b03d1672ac",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "2346a47e-4dc0-4017-83f4-c45098e88319",
      "name": "Déclencheur programmé",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1568,
        -288
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 7
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ac1a1dc4-ab83-41cc-a4f9-78f200aeb324",
      "name": "Obtenir les tâches",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1296,
        -288
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit#gid=0",
          "cachedResultName": "Tasks"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit?usp=drivesdk",
          "cachedResultName": "Chore_scheduler"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "x23VLPzDtSY8QGZL",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "cb86134c-7f25-48f2-af87-2297386ca3be",
      "name": "Obtenir les personnes",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -992,
        -288
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 307557581,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit#gid=307557581",
          "cachedResultName": "Persons"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit?usp=drivesdk",
          "cachedResultName": "Chore_scheduler"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "x23VLPzDtSY8QGZL",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "5870874f-35ce-4b0d-8230-ec7c27fa71eb",
      "name": "Envoyer un message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -384,
        -288
      ],
      "webhookId": "8c1a3396-8d92-419e-ac17-794f5ecbfa98",
      "parameters": {
        "sendTo": "={{ $('Filter Data and Assign Tasks').item.json.email }}",
        "message": "=Hello {{ $('Filter Data and Assign Tasks').item.json.assigned_to }}!\n\nThe homework assigned to you this week is: {{ $('Filter Data and Assign Tasks').item.json.task }}.\n{{ $('Filter Data and Assign Tasks').item.json.description }}\n\nHave a good day!",
        "options": {},
        "subject": "=Task selection"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "Lq6xBv8sVLgAMlGL",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0c83e351-1158-4577-9f24-06297d7477fb",
      "name": "Filtrer les données et attribuer les tâches",
      "type": "n8n-nodes-base.code",
      "position": [
        -688,
        -288
      ],
      "parameters": {
        "jsCode": "let tasks = $items('Get Tasks');\nlet people = $items('Get People');\n\n// Filter persons without Email\npeople = people.filter(item => {\n  const email = item.json.email;\n  return email && email.toString().trim() !== '';\n});\n\n// Filter tasks undefined\ntasks = tasks.filter(item => {\n  const task = item.json.task;\n  return task && task.toString().trim() !== '';\n});\n\n// Error if there aren´t any persons\nif (people.length === 0) {\n  throw new Error('No hay personas con correo electrónico para asignar las tareas.');\n}\n\n// Assign Tasks\nconst assignments = tasks.map((taskItem, index) => {\n  const personItem = people[Math.floor(Math.random() * people.length)];\n  return {\n    json: {\n      row_number: taskItem.json.row_number,\n      task: taskItem.json.task,\n      description: taskItem.json.description,\n      assigned_to: personItem.json.name,\n      email: personItem.json.email,\n    }\n  };\n});\n\nreturn assignments;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "d5692ac3-3119-4466-a557-15bf38acb8c0",
      "name": "Mettre à jour assign_to dans la feuille",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -80,
        -288
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('Filter Data and Assign Tasks').item.json.row_number }}",
            "assigned_to": "={{ $('Filter Data and Assign Tasks').item.json.assigned_to }}"
          },
          "schema": [
            {
              "id": "task",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "task",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "description",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "assigned_to",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "assigned_to",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit#gid=0",
          "cachedResultName": "Tasks"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ghJREX21axnMDVF5tndQMIh6MWYUJevNRV9Ji4kBG7s/edit?usp=drivesdk",
          "cachedResultName": "Chore_scheduler"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "x23VLPzDtSY8QGZL",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d60ce508-5931-4250-968b-79f1064ed6de",
      "name": "Note adhésive1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        -224
      ],
      "parameters": {
        "color": 2,
        "width": 320,
        "content": "## Sheets Tasks Example\n![](https://i.imgur.com/VHb4GQM.jpeg)"
      },
      "typeVersion": 1
    },
    {
      "id": "17b51b73-044f-4798-a939-fac4daa167df",
      "name": "Note adhésive2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2016,
        -672
      ],
      "parameters": {
        "color": 2,
        "width": 352,
        "height": 832,
        "content": "## Setup steps before start\n1.\tSpreadsheet – Create a Google Sheets document with two sheets (“Tasks” and “Persons”) You can see examples in the **images**.\n2.\tCreate your credential for Google Sheets with read and write permissions.\n3. Create your credential to send messages from Gmail.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "97d87ab3-a03d-4522-b516-3bbde84306f3",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1984,
        -448
      ],
      "parameters": {
        "color": 2,
        "width": 288,
        "height": 208,
        "content": "## Sheet Persons ![](https://i.imgur.com/0eN0zPX.jpeg)"
      },
      "typeVersion": 1
    },
    {
      "id": "d8e31fc6-60b1-4ca5-ad1b-70b396bc53e3",
      "name": "Note adhésive3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        -48
      ],
      "parameters": {
        "color": 2,
        "width": 320,
        "height": 192,
        "content": "## How to customise it\n\nChange the schedule interval to suit your rotation, edit the email template to include due dates or motivational messages, or modify the assignment script to weight tasks by difficulty. You could also send notifications via Slack or Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "289e4235-712e-4b95-bace-0eb749181767",
      "name": "Note adhésive5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 352,
        "content": "**Filter Data and Assign Tasks Node (Optional):** \n\nIt's preconfigured but you can or modify the assignment script to weight tasks by difficulty.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ea1dd9bf-3a8c-42cf-b43e-cb5e6fe12d66",
      "name": "Note adhésive6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 352,
        "content": "**Send a message node:** \n\nSelect your Gmail credential. If you want you can customise the subject and body of the email."
      },
      "typeVersion": 1
    },
    {
      "id": "ee4d6fb2-e4a4-44c9-9d1a-ea348ec2ca5f",
      "name": "Note adhésive7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -160,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 352,
        "content": "**Update sheet assign_to in sheet node:** \n\nThe workflow uses the row_number to match the row being updated. Ensure mapping writes the assigned person’s name to the correct row. "
      },
      "typeVersion": 1
    },
    {
      "id": "75fc9783-7d22-448b-bd52-559f3ec38ca6",
      "name": "Note adhésive8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 352,
        "content": "**Get People Node:** \n\nSelect the credential for your Google account and search for your Persons sheet in drive.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b2b88914-0526-4936-8d5a-b6215dd05eb9",
      "name": "Note adhésive9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -464
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 352,
        "content": "**Get Tasks Node:** \n\nSelect the credential for your Google account and search for your Tasks sheet in drive.\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "ac1a1dc4-ab83-41cc-a4f9-78f200aeb324": {
      "main": [
        [
          {
            "node": "cb86134c-7f25-48f2-af87-2297386ca3be",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cb86134c-7f25-48f2-af87-2297386ca3be": {
      "main": [
        [
          {
            "node": "0c83e351-1158-4577-9f24-06297d7477fb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5870874f-35ce-4b0d-8230-ec7c27fa71eb": {
      "main": [
        [
          {
            "node": "d5692ac3-3119-4466-a557-15bf38acb8c0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2346a47e-4dc0-4017-83f4-c45098e88319": {
      "main": [
        [
          {
            "node": "ac1a1dc4-ab83-41cc-a4f9-78f200aeb324",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d5692ac3-3119-4466-a557-15bf38acb8c0": {
      "main": [
        []
      ]
    },
    "0c83e351-1158-4577-9f24-06297d7477fb": {
      "main": [
        [
          {
            "node": "5870874f-35ce-4b0d-8230-ec7c27fa71eb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds15
Catégorie-
Types de nœuds5
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Adrian

Adrian

@nafri

Experienced tech professional with 10+ years in Big Data, AI, and automation, former bootcamp director, and passionate about innovation and strategic growth.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34