Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 41

Automating Task Completion Notifications

Recommended resources

Introduction

In the previous lesson, you successfully engineered the operational backbone of the onboarding system by dynamically generating a project plan based on a client's service package. Your Processor workflow now populates a Project Task Tracker sheet, transitioning the client's state to TASKS_ASSIGNED.

This lesson addresses the next critical step in automated project management: closing the feedback loop. Your objective is to implement status tracking that triggers notifications to stakeholders upon task completion.

You will build a separate, event-driven workflow that monitors the Project Task Tracker in real-time. When a team member updates a task's status to Completed, your system will instantly send a notification to a designated Slack channel. This provides immediate visibility into project velocity, eliminates manual status updates, and embodies the "act-and-inform" principle of a mature automation system.

To achieve this, we will use a webhook-based architecture, which is vastly more efficient and responsive than scheduled polling, aligning with the production-ready standards we are targeting.


1. The Real-Time Monitoring Architecture

A professional system reacts to events as they happen. Instead of repeatedly asking "Is anything done yet?" (polling), we will configure the Google Sheet to tell us the moment a task is completed.

This architecture consists of three parts:

  1. Google Apps Script: A small piece of JavaScript attached to your Project Task Tracker sheet. It runs automatically on every edit.
  2. onEdit(e) Trigger: The script's function that captures the edit event, including what was changed and where.
  3. n8n Webhook: A unique URL that the Apps Script calls, sending the edit event data to your n8n workflow for processing.

The workflow you'll build will receive this data, filter it to act only on relevant status changes, and then execute the notification. This is a classic Trigger -> Transform -> Notify (TTN) pattern.

Google Sheets to Slack n8n - Lets Viz

The article 'Connect Google Sheets to Slack with n8n' from Lets Viz provides an excellent overview of this architecture. Read the introduction and the 'Architecture at a Glance' section to solidify your mental model of the system you are about to build.

Focus on the sections 'What You’ll Build' and 'Architecture at a Glance'. Note the TTN model mentioned (Trigger → Transform → Notify). This is the core pattern for this lesson.

This diagram illustrates a similar conditional notification pattern. A trigger event is evaluated, and based on the outcome, a notification is dispatched to the relevant stakeholder.

n8n Workflow for Automated Support Ticket Processing with Escalation and Routing
This workflow demonstrates a common professional pattern: an event triggers a workflow, an IF node checks a condition, and a notification is sent down a specific path. You will build a similar structure.

2. Implementing the Google Sheet Webhook Trigger

To begin, you need to equip your Project Task Tracker sheet with the Apps Script that will fire the webhook.

The video segment below provides a direct, practical walkthrough of this exact process. You have seen this before, and now you will apply it to your new tracker sheet.

Google Sheets on Autopilot: 11 Insane n8n Automation Hacks

To implement the real-time trigger, watch this segment from Jono Catliff's 'Google Sheets on Autopilot' video. It details how to set up an n8n webhook and connect it to a Google Sheet using an Apps Script trigger.

Watch the section from 07:00 to 12:08. Follow the steps precisely: create the webhook in n8n, paste the URL into the provided Apps Script, and configure the 'onEdit' trigger in your Google Sheet's Apps Script editor. Pay attention to the HTTP Method being set to 'POST'.

Use the following Google Apps Script. This is a standard script that sends the details of any cell edit to your n8n webhook.

function onEdit(e) {
  var webhookUrl = "YOUR_N8N_WEBHOOK_URL"; // PASTE YOUR TEST WEBHOOK URL HERE

  // Get information about the edited cell
  var range = e.range;
  var sheet = range.getSheet();
  var sheetName = sheet.getName();
  var row = range.getRow();
  var column = range.getColumn();
  var value = e.value;
  var oldValue = e.oldValue;

  // Get all values from the edited row
  var rowValues = sheet.getRange(row, 1, 1, sheet.getLastColumn()).getValues()[0];
  var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];

  // Create a JSON payload
  var payload = {
    'sheetName': sheetName,
    'range': range.getA1Notation(),
    'row': row,
    'column': column,
    'value': value,
    'oldValue': oldValue,
    'rowValues': rowValues,
    'headers': headers
  };

  // Set options for the HTTP request
  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'payload': JSON.stringify(payload)
  };

  // Send the request
  UrlFetchApp.fetch(webhookUrl, options);
}


Practical Task: Build the Status Notification Workflow

You will now create a new, dedicated workflow to handle these real-time status updates.

Scenario: A project manager updates the Status of a task in the Project Task Tracker from In Progress to Completed. The system must immediately send a formatted message to the #project-updates Slack channel.

Phase 1: Configure the Sheet and Workflow Trigger

  1. Create a New Workflow: In n8n, create a new workflow named Project Status Monitor.
  2. Add Webhook Node: Add a Webhook node. Copy the Test URL.
  3. Update Project Task Tracker:
    • Add two new columns to your Project Task Tracker sheet: Status (Column H) and NotificationSent (Column I).
    • Populate the Status column for your existing tasks with Not Started.
  4. Implement Apps Script:
    • Open your Project Task Tracker sheet, go to Extensions > Apps Script.
    • Paste the provided JavaScript code.
    • Replace YOUR_N8N_WEBHOOK_URL with your n8n Test URL.
    • Save the script.
    • Go to the Triggers tab (clock icon), click Add Trigger, and configure it to run the onEdit function from the spreadsheet on the On edit event type. Save the trigger.

Phase 2: Implement Filtering and Notification Logic

  1. Test the Trigger: In n8n, click Listen for Test Event. Go to your Google Sheet and change the Status of one task to Completed. The webhook node should receive the data. Inspect the JSON to understand its structure.

  2. Add an IF Node:

    • Name it Is Task Completed?.
    • Add two conditions that must both be true (AND):
      • Condition 1 (Check Column): The edited column must be the Status column (Column H, which is index 8).
        • Value 1: {{ $json.body.column }}
        • Operation: Number -> Equal
        • Value 2: 8
      • Condition 2 (Check Value): The new value of the cell must be Completed.
        • Value 1: {{ $json.body.value }}
        • Operation: String -> Equal
        • Value 2: Completed

    The following video segment demonstrates this exact filtering technique.

Google Sheets on Autopilot: 11 Insane n8n Automation Hacks

To correctly configure your IF node, review this segment from 'Google Sheets on Autopilot'. It shows how to filter incoming webhook data based on the edited column and its new value.

Watch from 14:01 to 18:49. The video uses a 'Filter' node, which functions identically to an 'IF' node for this purpose. Adapt the logic shown to match your column index (8) and desired status ('Completed').

  1. Add a Set Node (Prepare Notification):

    • Connect this to the true output of the IF node.
    • Name it Compose Slack Message.
    • This node will transform the raw row data into structured variables for your message. The rowValues array from the webhook contains the data.
    • Create the following String values, mapping them from the rowValues array (remember arrays are 0-indexed):
      • projectName: {{ $json.body.rowValues[2] }}
      • taskName: {{ $json.body.rowValues[3] }}
      • assignedTo: {{ $json.body.rowValues[5] }}
    • Create another String value named message and use Slack's mrkdwn to format it:
      :white_check_mark: *Task Completed*
      *Project:* {{ $('Compose Slack Message').item.json.projectName }}
      *Task:* {{ $('Compose Slack Message').item.json.taskName }}
      *Assigned To:* {{ $('Compose Slack Message').item.json.assignedTo }}
      
  2. Add a Slack Node:

    • Connect it after the Set node.
    • Create or use existing Slack API credentials.
    • Channel: Enter the name of a test channel, e.g., #project-updates.
    • Text: Use an expression to pull in your formatted message: {{ $('Compose Slack Message').item.json.message }}.

Phase 3: Ensure Idempotency

To prevent sending a notification every time something in a "Completed" row is edited, we will add a flag.

  1. Modify IF Node: Add a third AND condition to your Is Task Completed? node:

    • Condition 3 (Check Notification Status): Check if the NotificationSent column (Column I, index 8) is empty or FALSE.
      • Value 1: {{ $json.body.rowValues[8] }}
      • Operation: Is Empty
  2. Add Google Sheets Node (Update Flag):

    • Connect this node after the Slack node.
    • Operation: Update Row.
    • Sheet ID: Select your Project Task Tracker sheet.
    • Row Number: Use the row number from the webhook: {{ $json.body.row }}.
    • Columns to Update:
      • NotificationSent: TRUE

This pattern is a hallmark of robust systems. The article below reinforces this concept of using a "Processed" flag.

Google Sheets to Slack n8n - Lets Viz

This article from Lets Viz describes the exact idempotency pattern you are implementing. Reading this will confirm why this is a critical step for production-ready workflows.

Review 'Step 2: Add Google Sheets Node', focusing on 'B) Change tracking with a “Processed” flag'. Then, review 'Step 8: Mark as Sent (Idempotency)'. This validates the pattern of checking a flag before acting and updating it after.

Deliverables

  1. The complete JSON of your Project Status Monitor workflow.
  2. A screenshot of a notification message successfully posted to your Slack test channel.

Evaluation Criteria

  • Real-Time Trigger: The Apps Script and n8n webhook are correctly configured and trigger on edit.
  • Conditional Logic: The IF node correctly filters events based on the column, value, and idempotency flag.
  • Correct Data Handling: The Set node correctly extracts data from the webhook payload and formats a professional notification.
  • Successful Notification: The Slack node successfully sends the formatted message to the specified channel.
  • Idempotency: The workflow correctly updates the NotificationSent flag in the Google Sheet to prevent duplicate notifications.

Conclusion

You have now built an event-driven, real-time monitoring and notification system. This workflow effectively closes the loop on task management, providing automated, instantaneous progress updates. This is a significant step up from batch-oriented, scheduled processes and demonstrates your ability to architect responsive, efficient systems.

Key Takeaways:

  • Event-Driven Architecture: Using webhooks for real-time triggers is a superior pattern to polling for both performance and user experience.
  • Defensive Filtering: Always assume your trigger will fire for irrelevant events. Robust IF conditions are your primary defense against unwanted workflow executions.
  • The Flag Pattern for Idempotency: Checking and setting a "processed" flag is a fundamental technique to prevent duplicate actions, especially in notification systems.
  • Separation of Concerns: The Project Status Monitor is a distinct workflow with a single responsibility, making the overall system easier to debug, maintain, and scale.

Preview of the Next Lesson:
With task generation and status monitoring now fully automated and robust, we will circle back to ensure the very first step of our client interaction is equally resilient. In the final lesson of this module, you will "Apply automatic retry mechanisms to critical communication steps, such as sending welcome emails," completing your production-grade Client Onboarding System.