Receive comment notifications by email in Modern SharePoint Pages

Manage comments on modern page is not easy specially if you are monitoring a lot of pages, this is a lack of functionality that I’m sure Microsoft will address in future updates.

I was challenged a couple times to try to build a solution to get notifications on new comments in modern pages, after a few tries I was able to put together a solution that notifies the owner of the page when a new comment is posted.

The solution is composed by an SPFx extension that is used to trigger the check on new comments, a modified page library with two extra columns and a Flow that ultimately sends the email.

Bellow you have all the steps involved to implement it.

Modify the Site Pages library

For each site where you want to implement this solution you will need to modify the Site Pages library to create to extra columns, the new columns will be used to track the number of comments.

To modify your library, do the following:

  1. Go to Settings and then Site Contents
  2. Open the Site Pages library
  3. Click on Add Column and select Number
  4. The name of the first column must be Previous Comments
  5. Select 0 for the Number of Decimal Places
  6. Type 0 for the Default Value
  7. Click on Add Column and select Number
  8. The name of the first column must be Actual Comments
  9. Select 0 for the Number of Decimal Places
  10. Type 0 for the Default Value

Previous Comments – Is the number of the comments returned for each page by the SharePoint API.

Actual Comments – Is the number of comments that was notified to the page owner.

Create the email notification Flow

To receive notifications by email you will need to use Microsoft Flow, for each execution of the Flow it will compare the number of Previous Comments with the number of Actual Comments, if the numbers are different the follow will send an email to the page owner.

To create your Flow do the following:

  1. Open Microsoft Flow
  2. Click on Create from Blank
  3. On the first trigger select SharePoint – When an item is created or modified
  4. Type the URL to your modern site
  5. If the Site Pages is not listed type it as a custom value
  6. Click on New Step and then Add a Condition
  7. Define the condition like the image bellow, this condition will check if the Actual Commnents column is empty
  8. For the Yes section
    1. Click on Add a new action
    2. Select SharePoint – Update Item
    3. Type the URL of your modern site
    4. If the Site Pages is not listed type it as a custom value
    5. On the ID field select the ID
    6. Type 0 on the Actual Comments
  9. For the No section
    1. Click on Add a Condition
    2. Define the condition like the image bellow, this condition will validate if there are new comments available
    3. For the Yes section
      • Click Add an action
      • Select SharePoint – Update Item
      • Type the URL of your modern site
      • If the Site Pages is not listed type it as a custom value
      • On the ID field select the ID
      • On the Actual Comments select the Previous Comments
  10. Click on Add an action
  11. Select Office 365 Outlook – Send an Email
  12. On the To field select the Created by Email
  13. For the Subject and Body you can use the Title and Link to item columns

Trigger the Microsoft Flow

To trigger the Flow a custom SPFx Extension was built, the extension is responsible to check the number of comments on each page and then update the Previous Comments column.

The code for the extension is available on GitHub and the package for the solution can be downloaded from this post.

Note: PnP PowerShell is required to install the solution.

To install the extension, do the following:

  1. Download the installation files file from here
  2. Open your SharePoint App Catalog
  3. Upload the SPPKG file to the App Catalog
  4. Check the option Make this solution available to all sites in the organization
  5. Execute the Install.ps1 file
  6. Provide the modern site URL where you want to apply the solution

Once the solution is installed you will see a button on the lower left corner of your window, this button will be only visible to the users with permissions to edit the pages.

When you click the button the Flow will be triggered, and all page owners will receive an update on new comments by email.

Download Comments Notifications
Explore Solution on GitHub

Thanks to Elio Struyf for the great article Getting likes and comments from modern pages it was fundamental to build this solution.

To watch this solution in action watch the video below

This solution was featured on the SharePoint Dev Weekly by Vesa Juvonen and Waldek Mastykarz, you can check their comments on the video below.

Designed by Freepik


22 Responses to “Receive comment notifications by email in Modern SharePoint Pages”

  1. jonas björkander

    August 15, 2018

    If we have alot of pages, it will render many many flows and most of us do have a limit on how many flows we can run and we might up using them all. Could we run through all pages in one batch/loop?

    Reply
    • João Ferreira

      August 16, 2018

      Hi Jonas,

      Thanks for your feedback, I’ve been thinking about this but didn’t had the time to test any alternative.
      It might be possible following a similar approach described in this article, the idea is to use an auxiliary list to trigger the flow, and then the flow will iterate through all the pages in the library sending the email.
      If what I’m thinking is possible this approach will do 2 executions of Flow for each check on new comments.

      Reply
  2. […] Receive comment notifications by email in Modern SharePoint pages – João Ferreira (BindTuning) […]

    Reply
  3. Bastian

    August 30, 2018

    Hi,
    In the condition “value” field, I’m not able to find “Actual Comments”. I can write the words, but I don’t get a SharePoint logo on the left side of the text as you do in your description. I’m on a mac with SharePoint Online.

    Do you have any idea on where to start troubleshooting?

    Reply
    • Daniel

      September 18, 2018

      Hi Bastian!
      It may be because your Site Pages isn’t actually called Site Pages. For me they’re called Webbplatssidor (which is of course the Swedish translation for Site Pages). So when I changed the List name to the correct list name Actual Comments showed up.

      Kind regards
      Daniel

      Reply
  4. Andrew

    October 7, 2018

    Hi João,
    great idea. But doesn’t work for me. I’ve just followed step by step all instructions, but no button on same row as “feedback” at the end. Also, I see buttons from Microsoft, “like”, “comments”, “save for later” on this row which absent on your picture. What happened? May be the reason is some visual changes in design of modern pages?

    In my understanding, the logic can be another. For example, send notifications to owner of this page + users who wrote some comments. It need one more column for list of users. But no buttons or other visual elements.

    I’ll try to see the code on GitHub. But I do not expect success due my qualification. Anyway, it will be helpful to confirm that custom SPFx extension still work and I need search the problem in my tenant.

    Reply
    • João Ferreira

      October 10, 2018

      Hi Andrew,

      I tested the solution on my tenant and it is still working.
      Two possible thing can be happening on your solutions:

      1 – The extension is not enabled, make sure you checked the check box to make it available without feature activation
      On powershell execute this command let and check if the solution is listed.
      Connect-PnPOnline -url https://tenantname.sharepoint.com
      Get-PnPCustomAction -scope site

      Let me knwo what do you have listed

      2 – The account you are using do not have enough permissions to see the button, only users with edit permissions will see it.

      About notifying the user that made the comment, it is possible but requires a more complex structure and flow, but it can be an option.

      Reply
  5. Andrew

    October 11, 2018

    Hi João,
    PowerShell said me:
    CommentNotifications ClientSideExtension.ApplicationCustomizer Site 79d0f5fc-3c55-4f6c-b802-bc683d581c7f

    I’m admin on this tenant and have full rights.

    Please note, in my case, this is Teams Site. In the line, where you have button and Fedback on right side, I have three buttons on left side: “Like”, “Comment”, “Save for later”. I do not see these buttons on your picture. What difference here? May be they cover target button?

    Reply
    • João Ferreira

      October 11, 2018

      Hi Andrew,

      Can you send me a screenshot of your page to my email?

      Reply
  6. Rajsons

    November 14, 2018

    About notifying the user that made the comment, it is possible but requires a more complex structure and flow, but it can be an option. thanks

    Reply
  7. Casey

    November 19, 2018

    How do we remove this? Tried Remove-PnpCustomAction and says Guid not found. Cool solution however the client does not want it anymore. thanks

    Reply
    • João Ferreira

      November 19, 2018

      Hi Casey,

      To remove the solution execute the PowerShell cmdlets by the following order:

      1 – Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/modern
      2 – Get Get-PnPCustomAction -Scope site
      3 – Copy the id of the solution presented in the PowerShell console
      4 – Remove-PnPCustomAction -Scope site -Identity ID
      5 – Replace the ID by the ID of your solution

      Reply
      • Casey

        November 28, 2018

        That worked great, thanks!

        Reply
  8. Selva Kumar

    March 19, 2019

    Thanks for Sharing.. Read more about us..

    Reply
  9. Shin

    April 18, 2019

    Hi João,

    First of all thank you for the effort in creating the webpart and this guide.
    I’ve stumbled on to the following issue. I was able to edit the library, create the flow and add the webpart. The webpart also triggers the flow. But the Previous and Actual comments numbers never change. Even if I make a comment and trigger the flow, it ends up not updating any numbers and not sending a mail. Because the result of previous comments > actual comments is always false.

    Do you have an idea why this happens? Thanks in advance.

    Reply
    • Shin

      June 12, 2019

      Friendly reminder to check this question if possible. Thanks

      Reply
    • João Ferreira

      August 21, 2019

      Hi Shin,

      By your description seems that the solution is not being executed on the page when you click on the button, please make sure the columns were created with the right name and type.
      I just implemented the solution on a new site and it’s still working as expected.
      After clicking on the button please open your browser console pressing F12 and let me know if there is any error there.

      Hope we are able to track down your issue.

      Have a nice day 🙂

      Reply
  10. Pedro Francisco

    April 25, 2019

    Informativo , totalmente գue eu procurava.

    Reply
  11. Ravi

    August 8, 2019

    thanks for sharing these great information. this is very help for us to managing website.

    Reply
  12. visit

    November 21, 2019

    Nice information You master that and you have achieved god level

    Reply
  13. link alternatif

    June 20, 2020

    Listing of Alternative Linksbo Backlinks
    Today is increasingly developing, rendering it simpler for people to access
    computerized networks. Till now there are many on-line gambling games that may
    be played by any person online. Therefore, betting lovers no extended need to
    go to the particular casino to try out wagering, this is quite effortless for them in order to play anytime in addition to anywhere without limitations.

    Reply

Leave a Reply to João Ferreira


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.

%d bloggers like this: