Send a notification when a new person is added to monday.com board


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, so when a new person is added to the board, they will be sent a notification with pre-defined content. 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

TypeScriptOnMondayWhenAPersonChanges
When a person changes

README


๐Ÿ“‹ Overview

This template demonstrates how to build an automation in monday.com, so when a new person is added to the board, they will be sent a notification with pre-defined content.

Example use case

As a sales manager, I want to send notifications to any of my sales team when I add them to an item on my board so that I can send them pre-defined instructions on how to proceed with the sale.

๐Ÿ–Š๏ธ Setup

To configure this script to run against your selected board, complete the following steps below:

  1. Configure the API Connection by providing a monday.com connection that gives you access to the board against which you'd like to run this script.
  2. Configure an Event Listener for the When a column changes event by creating a connector for monday.com or use an existing one to execute the script when a People column value changes.

๐Ÿš€ How to use

When a user is added/removed from the selected People column, the template script logs out all the user IDs and names. It will then send each user a custom notification.

Steps to trigger the script:

  1. Select a new user value for your item's People column.
    Select A Person
  2. The listener setup earlier will then trigger.
  3. Refer to the ScriptRunner Connect console output to see a log of users by id and name.
  4. Each Person selected in the People column will then get the notification message you defined in the script.
    User Notification

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

You could modify the script to send the user details to an external tool such as Google Sheets or Salesforce.

API Connections


TypeScriptOnMondayWhenAPersonChanges

import { PeopleValueReturnType } from '@managed-api/monday-core/definitions/columnValueFragments/peopleValue';
import { UpdatePersonEvent } from '@sr-connect/monday/events';
import Monday from './api/monday';

export default async function(event: UpdatePersonEvent, context: Context): Promise<void> {
    if (context.triggerType === 'MANUAL') {
        console.error('This script is designed to be triggered externally or manually from the Event Listener. Please consider using Event Listener Test Event Payload if you need to trigger this script manually.');
        return;
    }

    // Extract necessary parameters from the event
    const { pulseId, columnId } = event.event;
    // Check if the necessary parameters are present in the event
    if (!pulseId) {
        throw Error('Pulse ID not present in the event');
    }
    if (!columnId) {
        throw Error('Column ID not present in the event');
    }

    // Fetch the column data for the item.
    const itemsQueryResult = await Monday.Item.getItems({
        args: {
            ids: [pulseId]
        },
        fields: {
            column_values: {
                args: {
                    ids: [columnId]
                },
                fields: {
                    id: true
                },
                fragments: { // use fragments to define the sub-fields we want returned for the People columns value
                    PeopleValue: {
                        persons_and_teams: {
                            fields: {
                                id: true
                            }
                        }
                    }
                }
            }
        }
    });

    // Convert the column value to the expected `PeopleValueReturnType` type for a People field.
    // We simply request the first index of the `column_values` list here as that is the only column we requested in the above `getItems` API call.
    const peopleValueReturnType = itemsQueryResult.data.items[0].column_values[0] as PeopleValueReturnType;

    // get all the person ids selected in the People column
    const personIds = peopleValueReturnType?.persons_and_teams?.map(persons => persons.id);

    if (!personIds || personIds?.length === 0) {
        console.log(`No person ids found for the People column with id ${columnId}`);
        return;
    }

    // log out the person ids
    console.log(personIds);

    // Use the ids obtained above to get more data on the assigned persons via the Users API.
    const personData = await Monday.User.getUsers({
        args: {
            ids: personIds
        },
        fields: {
            id: true,
            name: true
            // Add more fields here as desired.
        }
    });
    // log out the id and name of each person
    console.log(personData.data);

    // Send personalised notifications to each person
    for (const person of personData.data.users) {

        const notificationMessage = `Hi ${person.name}, please can you follow up with this sales lead before the end of the day`;

        await Monday.Notification.createNotification({
            args: {
                user_id: person.id,
                target_id: pulseId,
                target_type: 'Project',
                text: notificationMessage
            },
            fields: {
                text: true
            }
        });
    }
}
Documentation ยท Support ยท Suggestions & feature requests