June 18, 2021

SharePoint – Adding ‘Time to read’ to modern pages

SharePoint Time to Read functionality screenshot

I was recently asked by a customer if functionality existed to display the estimated read time of content on modern SharePoint pages. This is something they had as part of the requirements for their new SharePoint modern Intranet.

A quick check on the roadmap and a discussion internally confirmed that this isn’t available out of the box yet, at least not for pages anyway. There is ‘Time to read’ functionality available for Office files though – 
Microsoft 365 is the smartest place to store your content | Microsoft 365 Blog. It seems something is coming for news posts, as indicated here – 
Microsoft SharePoint News: What’s New & What’s Coming – YouTube but it doesn’t mention site pages so we’ll see!

I was confident that this functionality could easily be built with a Power Automate flow, a new column in the ‘Site Pages’ library of a given site and the ‘Page properties’ Web Part to display it on the page.

Fast forward 10 minutes later and I had a fully working solution leveraging Power Automate which was extremely easy to build! Read on to find out how to implement this yourself.

The flow I created is very simple and at a high level, does the following:

  • Runs when files (pages in this case) are created/modified in the Site Pages library.
  • Retrieves the page content using the SharePoint REST API (Send HTTP request to SharePoint action).
  • Converts the page content (returned as HTML) to plain text.
  • Splits the content by words and creates an array.
  • Calculates the length of the array (number of words).
  • Calculates the reading time based on an assumption that the average adult reads around 200 words a minute. This formula is hardcoded and can easily be changed. There is the potential to integrate with a 3rd party REST API/service here if you want to produce a more accurate estimate.
  • Updates the value of a column (‘Time to Read’) with the output of the reading time calculation. 

Download the flow here – https://aka.ms/spotimetoread

So, here’s how to build it:

  1. Add a new column to your ‘Site Pages’ library – 

    Internal name: TimeToRead
    Display name: Time to Read
    Column time: SLOT

  2. Create a new page to use as a template OR edit an existing template. 
  3. Add a ‘Page properties’ Web part and configure it to show the ‘Time to Read’ property.
Page properties Web Part configuration displaying Time To Read property.
  1. Save your page as a template/update your existing page template.
  2. Download the flow package from the link above.
  3. Import the flow into your environment and connect the data connections.
  4. Open the flow in edit mode.
  5. Update the trigger ‘Site Address’ to the URL of your SharePoint site.
  6. Update the ‘SiteURL’ variable value to the URL of your SharePoint site.
Updating trigger and variable site URL.
  1. Save and turn on the flow.
  2. Create a new page (or modify an existing page that uses your template), add some text Web Parts with text in them and save/publish the page.
  3. Wait for the flow to run, refresh your page and watch the Time to Read appear! ?
Time to Read screenshot.

It’s worth noting that if you need this functionality in other SharePoint sites then you will need to duplicate the flow (one per site/site pages library).

You may however be able to leverage Kevin McDonnell’s (@kevmcdonk)  awesome ‘CrossSiteApprovals’ solution on GitHub – 
kevmcdonk/CrossSiteApprovals: For when you would like to have a single Flow approving content from across multiple SharePoint sites. (github.com). with some modifications to deploy this flow across multiple sites.

I hope this solution is useful and if you extend it in any way then please do share your updates ?

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

WP to LinkedIn Auto Publish Powered By : XYZScripts.com