Notify monday.com board item owners if the item has not been updated recently


Get Started

Not the template you're looking for? Browse more.

About the template


This template demonstrates how to build an automation in monday.com to notify the owner of a board item when the item has not been updated in a specific (configurable) period. Get started to learn more.

About ScriptRunner Connect


What is ScriptRunner Connect?

ScriptRunner Connect is an AI assisted code-first (JavaScript/TypeScript) integration platform (iPaaS) for building complex integrations and automations.

Can I try it out for free?

Yes. ScriptRunner Connect comes with a forever free tier.

Can I customize the integration logic?

Absolutely. The main value proposition of ScriptRunner Connect is that you'll get full access to the code that is powering the integration, which means you can make any changes to the the integration logic yourself.

Can I change the integration to communicate with additional apps?

Yes. Since ScriptRunner Connect specializes in enabling complex integrations, you can easily change the integration logic to connect to as many additional apps as you need, no limitations.

What if I don't feel comfortable making changes to the code?

First you can try out our AI assistant which can help you understand what the code does, and also help you make changes to the code. Alternatively you can hire our professionals to make the changes you need or build new integrations from scratch.

Do I have to host it myself?

No. ScriptRunner Connect is a fully managed SaaS (Software-as-a-Service) product.

What about security?

ScriptRunner Connect is ISO 27001 and SOC 2 certified. Learn more about our security.

Template Content


README

Scripts

TypeScriptNotifyPersonsAfterSetNumberOfWorkingDays
Scheduled

README


๐Ÿ“‹ Overview

This template demonstrates how to build an automation in monday.com to notify the owner of a board item when the item has not been updated in a specific (configurable) period.

๐Ÿ–Š๏ธ Setup

Follow these steps to configure the template with your board:

  1. Open the Notify persons after set number of working days template.
  2. Click Create a Workspace on the top right corner of the screen.
  3. Review the Workspace name, Description and Add to a team fields. You can change these if needed.
  4. Click Create.
  5. On the left side of the screen, under API Connections, select Complete API Connection Setup.
  6. Select your monday.com connector in the Uses connector field.
  7. Click Save.
  8. On the left side of the screen under Scheduled Triggers, select Complete scheduled trigger setup.
  9. In the CRON Expression field, enter how often you want the template to run.
  10. Click Save.
  11. Navigate to Parameters and and edit the following parameters:
    • BOARD_ID - Enter the board ID you want to work with.
    • DATE_COLUMN_ID - Enter the ID of the Date column value to check.
    • PROJECT_OWNERS_ID - Enter the ID of the project owners column.
    • WORKING_DAYS - Enter the number of working days you want to pass before a notification is sent.
  12. Click Save.

๐Ÿš€ How to Use

Every day at 9 AM, the script runs to check all Board items. If it has been three working days after the date provided in the Date column for an item, a log message is printed to confirm a notification will be sent.

For example, if an item with an Updated Date column value of 6 May, a notification is sent on 9 May since it is three working days after the Updated Date.

Item

An example of the in-app monday.com notification sent:

Monday.com notification

To manually test the script, follow these steps to trigger the script:

  1. Click Trigger Script Manually at the top left of the scripting area of the NotifyPersonsAFterSetNumberOfWorkingDays script.
  2. Monitor the output console at the bottom of the screen. The green tick indicates the script executed successfully.
  3. Check the board for your notification.

๐Ÿ–Š๏ธ How to modify the script

You could modify this script to send a notification to a Slack channel. Additionally, the text constant in the script can be updated to send a more personalised message in the notification.

API Connections


TypeScriptNotifyPersonsAfterSetNumberOfWorkingDays

import Monday from "./api/monday";
import { ItemReturnType } from "@managed-api/monday-core/definitions/item";
import { DateValueReturnType } from "@managed-api/monday-core/definitions/columnValueFragments/dateValue";

const PERSONS = "persons_and_teams";
const DayToMilliseconds = 86400000; // 24*60*60*1000 

export default async function(event: any, context: Context): Promise<void> {
    const { BOARD_ID, DATE_COLUMN_ID, PROJECT_OWNERS_ID, WORKING_DAYS } = context.environment.vars;

    // Get items from selected Board
    const boardItems = await Monday.Board.getBoards({
        args: {
            ids: [BOARD_ID],
        },
        fields: {
            items_page: {
                fields: {
                    items: {
                        fields: {
                            name: true,
                            id: true,
                            column_values: {
                                fragments: {
                                    DateValue: {
                                        id: true,
                                        date: true
                                    },
                                    PeopleValue: {
                                        [PERSONS]: {
                                        fields:{
                                            id: true,
                                        }
                                    }
                                }
                                },
                                fields: {
                                    id: true
                                }
                            }
                        } 
                    }
                }
            }
        }
    });

    const { items } = boardItems.data.boards[0].items_page;

    // Process returned items with only required item properties
    const processedItems = items.map((item: ItemReturnType) => {
        const { column_values, name, id } = item;

        const dateColumnValue: unknown = column_values.find(({ id }) => id === DATE_COLUMN_ID);
        
        if(isDateValueReturnType(dateColumnValue)) {
            const { date } = dateColumnValue;
            const owners: string[] = column_values.find(({ id }) => id === PROJECT_OWNERS_ID)[PERSONS].map(({ id }) => id);

            return { name, id, date, owners };
        }

        throw new Error("The dateColumnValue is not of type DateValueReturnType");
    });

    // Send notification if item date is the set number of working days
    for (const processedItem of processedItems) {
        const { date, owners, name, id } = processedItem;
        // Check that in window period to send notification
        const sendNotification = sendNotificationMessage(date, WORKING_DAYS);
        
        // Log out message if notification will be sent out
        console.log(`Notification message will ${!sendNotification ? 'not' : ""} be sent to owners of ${name}`);

        if(sendNotification) {
            const text = `It has been ${WORKING_DAYS} working days since the last updated date of ${date} for item: ${name}.`;

            for (const owner of owners) {
                await Monday.Notification.createNotification({
                    args: {
                        user_id: owner,
                        target_id: id,
                        target_type: 'Project',
                        text
                    },
                    fields: {
                        text: true
                    }
                });
            }
        }
    }

}

const sendNotificationMessage = (columnDate: string, workingDays: number): boolean => {
    // Get current time in milliseconds
    const currentDateInMilliseconds = new Date().getTime();
    
    const notificationDate = new Date(columnDate);
    let workingDaysCounter = 0;

    // get notifiction date after set number of working days
    while (workingDaysCounter < workingDays) {
        notificationDate.setDate(notificationDate.getDate() + 1); // Move to the next day
        // Check if the day is not the weekend
        if (![Days.Sunday, Days.Saturday].includes(notificationDate.getDay())) {
            workingDaysCounter++;
        }
    }

    const notificationDateInMilliseconds = notificationDate.getTime();

    // Check window period is after set number of days and within 24 hours of set days, so that notifications are not sent every time scheduled trigger runs.
    const diff = currentDateInMilliseconds - notificationDateInMilliseconds;
    const isNotificationWindow = diff >= 0 && diff <= DayToMilliseconds;

    return isNotificationWindow;
}

// Typeguard to check type is of DateValueReturnType
const isDateValueReturnType = (value: unknown): value is DateValueReturnType => {
    const dateObject = value as { date: string | null };

    return "date" in dateObject && typeof dateObject.date === "string";
}

enum Days {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
}
Documentation ยท Support ยท Suggestions & feature requests