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 columns 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 columns 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


11 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

Leave a Reply


Web developer focused on SharePoint branding, blogger, tech enthusiast. Travelling and sports are my addictions, knowledge and success are my daily motivations.