Sitecore + Microsoft Teams: Accelerating remote collaboration across your digital eco-system 

The global shift to remote working poses a wide variety of challenges, from inevitable delays in content deliveries, communication transparency, to traceability, quality, efficiency, etc. Sitecore + Teams Integration connects teams in the new virtual workspace with its rich instant notifications, actions & valuable insights.


This Integration includes Sitecore Connect+  Microsoft Teams App and Sitecore SPE Module that can be installed from the below links,
Sitecore+MicrosoftTeams(Sitecore-9.2+)-v2.0.zip
Sitecore+MicrosoftTeams(Sitecore-9.0-9.1)-v2.0.zip
subburamanathan/sitecore-microsoft-teams-integration:1.0.0.0-1809

This blog details the steps involved in setting up the Microsoft Teams App and Sitecore SPE Module for receiving workflow and publish notifications in Microsoft Teams Desktop/Web/Mobile Apps.

PREREQUISITE:
This module is built on top of Sitecore Powershell Extensions (SPE), please make sure SPE is installed before installing this module.

TEAMS APP SETUP:

  • Create a Teams Channel in the Microsoft Teams with the intended content authors/administrators
  • Update the Channel Notification Settings if required
  • Navigate to the ‘Apps’ tab of Microsoft Teams
  • Search for ‘Sitecore Connect+’ app and click on ‘Add to a Team’
  • Select the new Teams Channel and click on ‘Set up a Connector’
  • Copy the webhook URL from the Teams Configuration page launched
  • Click on the ‘Save’ button to set up the connector in the Teams Channel

SITECORE SPE MODULE INSTALLATION:

  • Install one of the above mentioned Sitecore packages in your Sitecore Instance depending on your Sitecore version
  • Alternatively, the Docker Asset Image can also be used

WORKFLOW/PUBLISH NOTIFICATION SETTINGS:

  • From the Sitecore Launchpad, select the ‘Microsoft Teams Integration’ tile to launch the Sitecore module configuration page
  • Click on ‘Add New Teams Endpoint’ and enter the webhook URL copied from the Teams  Configuration page
  • Click on the ‘Test’ link to ensure that the connector is set up successfully. A TEST notification will be received in the Teams Channel.
  • Select the Workflow commands for which you would like to receive notifications in Teams from the Workflow tab
  • Select the content locations for which you would like to receive notification in Teams if the item(or its subitem) or at least one of its/subitem’s referrers is published.
  • Click on the ‘Create’ button to complete the notification settings configuration for the Teams Channel

OPTIONAL SETTINGS:

  • Create PageSpeed Insights API Key using the below link and update the same in the Settings tab to receive insights on Performance, Accessibility, SEO, etc.,
    https://developers.google.com/speed/docs/insights/v5/get-started
  • Update the Sitemap or Sitemap Index Url in the Settings tab to enable ‘Request Google Indexing’ feature in publish notifications
  • Ensure to select your preferred content editors(Eg: Horizon, Content Editor etc.) in the Settings tab to render only the required actions in the notifications
  • Update the Background Image, Button Color, or Text Color in the Appearance tab to match your branding

IMPORTANT:

  • Use profile pictures that are 48×48 dimensions in Sitecore User Manager
  • Ensure TargetHostName & LanguageEmbedding properties are set for your Sitecore sites in site config
  • Create/Update the default notification templates if required from the below path,
    /sitecore/system/Modules/PowerShell/Script Library/Sitecore + Microsoft Teams Integration/Message Templates
  • Due to certain limitations, mobile app might not display certain features
  • Performance Scores might have little variations between each run (as the server response times for individual requests won’t be exactly the same every time)

KNOWN ISSUE:
There are chances that you might encounter the below ‘Stack Empty’ issue while configuring the notifications in Sitecore. Please try again after some time or remove the conflicting handlers mentioned in the below article to get rid of this issue,
https://github.com/SitecorePowerShell/Console/issues/1215

As a best practice, create individual endpoints/channels for different teams with only the intended workflow commands/publish content locations to reduce noise and improve work efficiency.

Source Code for this module is available in Github. This module is built for the Sitecore community and doesn’t require any license. This module doesn’t collect any of your information. Please check out and let me know if you have any feedback/issues/feature requests here. Thank you for using this module!

Happy Remote Working!

Improving SOLR Index Resilience: Preserving previously indexed data in SOLR during unexpected Indexing failures

While Search Platforms help to drive sites faster, they are also prone to stability issues. The chances of failures are directly proportional to the dependencies & customizations involved.

By default, when an exception is encountered during the indexing of a computed index field, the corresponding field will be excluded from the indexed document, thereby leading to invalid results in the front-end. In regards to Custom Crawler, whenever an exception/issue is encountered and not thrown, by default the entire index would be cleared. Hence it is essential to improve the SOLR index resiliency against these kinds of failures for a consistent user experience. This blog explains the approach to retain the previously indexed data in SOLR when the indexing operation fails or experiences any issue.

Prerequisities: Ensure Rebuild Core is setup for the SOLR index to support swapping of indexes during the rebuild, https://doc.sitecore.com/en/developers/101/platform-administration-and-architecture/switch-solr-indexes.html

High-Level Approach:

STEPS TO STOP INDEXING/SWAPPING DURING COMPUTEDINDEXFIELD FAILURES:

    • Update the ‘StopOnCrawlFieldError’ setting to true

    • Add appropriate validations in the computedindexfield to ensure that the right data in the expected format is received from dependencies/external services; else throw an exception. Catch any exceptions encountered and stop indexing as indicated below.

    • Create a new class for SearchIndex inheriting SwitchOnRebuildSolrSearchIndex. Resume indexing from the PerformRebuild method after the current rebuild is complete, so that the IndexingCustodian can execute the next queued job.

    • Change the type attribute of the index node in the index’s config to refer to the above created class.

STEPS TO STOP INDEXING/SWAPPING DURING CUSTOM CRAWLER FAILURES:

    • Sitecore handles the exception happening within custom crawler code (created by inheriting FlatDataCrawler class) and stops indexing/swapping automatically . Hence it is important that an exception shouldn’t be caught within custom code. If the exception is caught for any reason, it must be rethrown, so that Sitecore can stop indexing.
    • In order to stop indexing/swapping for any error that may happen when Sitecore is processing the data to prepare index documents, the stopOnError property must be set to true within the crawler config node,

Now that the SOLR index is more resilient towards failures, it is vital to set up appropriate monitoring & alerting to get notified of the failures happening in the rebuild core to prevent stale results from being displayed on the site.

Happy Searching!

Debugging Sitecore dlls made easy with In-built Visual Studio Decompiler & Symbol Generator

Quite often, debugging Sitecore assemblies becomes very essential for developers, to investigate any exception or unintended behavior happening within Sitecore assemblies (or any Third-party managed code). While there are few options available currently to debug Sitecore assemblies with tools like dotPeek, dnSpy, etc., it would incur some effort to install and configure them to be able to debug.

Visual Studio by partnering with ILSpy has now made it easy by bundling this capability in Visual Studio 2019. This works great for both Docker-based and non-Docker-based implementations.

IMPORTANT:
Visual Studio 2019 version 16.10.0 is required to use this feature, you may upgrade to 16.10.0 using the regular Visual Studio Installer.
Though this feature was introduced in Visual Studio 2019 version 16.5, decompiling Sitecore assemblies were experiencing the below ‘Unable to decompile the module.’ issue which was addressed in 16.10.0,
https://developercommunity.visualstudio.com/t/decompile-source-to-symbol-file-fails-unable-to-de/1281484

STEPS TO DEBUG SITECORE DLLS:

  • Navigate to Debug -> Options and uncheck the ‘Enable Just My Code’ option
  • Start debugging the application
  • Once the debugger hits a breakpoint, launch the Modules window by navigating to Debug -> Window -> Modules (or Ctrl+Alt+U)
  • Identify the module/dll(Eg: Sitecore.Xdb.MarketingAutomation.Tracking.dll) that needs to be debugged (You can also right-click on the intended function and navigate to its definition(metadata) to identify the related Sitecore dll)
  • Right-click on the identified module/dll and select ‘Decompile Source to Symbol File’ option. It may take up to 1-3 mins for decompilation depending on the size of the assembly.
  • Once the Symbol File generation is complete, add a Function Breakpoint by navigating to Debug -> New Breakpoint -> Function Breakpoint (or Ctrl K, B) and specify the Sitecore method name along with it’s namespace(Eg: Sitecore.Xdb.MarketingAutomation.Tracking.Extensions.ContactExtensions.GetPlanEnrollmentCache)
  • Press Continue or F5, you will now be able to step through the Sitecore or Third-Party code!

NOTE: 
Decompiling Sitecore assemblies using this feature is currently possible only when the debugger is in break mode and the application is paused. Visual Studio enters break mode when it hits a breakpoint or an exception. Alternatively, Visual Studio can be forced to enter break mode by selecting Debug -> Break All after attaching the specific IIS process. There are a few known limitations, which are covered here.

For remote debugging, you will still be needing the Remote Debugger application in Target Environment.

Happy Debugging!

Launching Published Content Delivery Website URL for Page Items straight from Sitecore Content Editor

An efficient content authoring experience is crucial for the success of any Sitecore Implementation. Accelerating the authoring process by automating possible areas of authoring and publishing workflows, improves the efficiency of content authoring thereby helping content authors realize its exceptional value.

It is quite common that a content author will need to switch between CMS and Website to view/update content. Bridging the gap between CM and CD, allows seamless navigation and improves productivity.

Sitecore Powershell Extensions, makes this much easier with its Content Editor Integration Point and Invoke-JavaScript cmdlet. This blog covers the steps involved in setting up this Content Editor button.

STEPS TO CREATE POWERSHELL MODULE
Powershell Module(Eg: ‘Published Page Viewer’) can be created under /sitecore/system/Modules/PowerShell/Script Library using ‘Module Wizard’ Insert Option,

Ensure to select the ‘Content Editor’ Integration Point while creating the module,

Remove the items under Ribbon item except ‘Publish’. Build the following tree structure under ‘Published Page Viewer’ module item based on templates/insert-options indicated below,

  • Content Editor
    • Ribbon
      • Publish (PowerShell Script Library)
        • Publish (PowerShell Script Library)
          • View Published Page (PowerShell Script)

 

Below PowerShell Script shall be copied into the ‘Script body’ field of above created ‘PowerShell Script’ item,

IMPORTANT: Ensure that the Targethostname attribute of the site(s) in the site config (or Site Definition Item in case of SXA) holds the CD Domain, for this script to work as expected. If Targethostname doesn’t hold CD Domain, CD Domain can still be hard-coded in this script but not recommended. This script might need to be optimized if the default site resolving flow has been customized in the implementation.

Update the ‘Show Rule’ field in the Script Item to add ‘where the item has a layout’ rule, to ensure that the ‘View Published Page’ button appears only for page items.

Navigate to ‘PowerShell ISE’ from Sitecore LaunchPad. Select the ‘Settings’ tab and choose ‘Sync Library with Content Editor Ribbon’ from ‘Rebuild All’,

‘View Published Page’ option should now be available within the ‘Publish’ Chunk of the ‘Publish’ tab, using which Content Authors can navigate to respective CD URLs directly.

Happy Authoring!

In-Sitecore Alerts & Push Notifications: Effectively communicating Maintenance Activities to Authors & Marketers

Building a strong DevContentOps within the organization helps to keep the productivity of all teams at maximum. This module eliminates friction and enables seamless collaboration between Authors, Marketers, Developers, and Operations.

The module can be downloaded from the below links,
Sitecore Maintenance Notification-v1.0 – Sitecore Package
sitecore-maintenance-notification:1.0.0.0-1903 – Docker Image

Integrating the above image into CM/MSSQL Containers requires few changes to .env, docker-compose/override, and Dockerfiles of CM & MSSQL Containers, as indicated in this screenshot (build is required for the changes to reflect). Alternatively, Sitecore packages can also be installed in Docker as described here.

Key Benefits:
• Optimized delivery of maintenance alerts through in-sitecore alerts and push notifications(works even if browser is not open) with appropriate auto-expiration
• Introduces Opt-in/Opt-out flexibility for Maintenance Notifications from Sitecore Control Panel.
• Displays Maintenance Page during Maintenance to avoid confusion.
• Displays Maintenance Alerts in User’s Local Timezone.
• Enables smooth handling of any Schedule Changes and Cancellations.
• Sends reminders before outage & Completion Message immediately after warm-up to keep content freeze at a bare minimum.
• Permits modifying Scheduled Alert messages, Reminder & Completion messages, Reminder Duration, etc. quickly from Sitecore

NOTE:
This module is built on top of Sitecore Powershell Extensions (SPE), please ensure SPE(v5.0+) is installed. 

STEPS TO CONFIGURE THE MODULE:
After installing the module, navigate to ‘PowerShell ISE’ from Sitecore LaunchPad. Select the ‘Settings’ tab and choose ‘Sync Library with Control Panel’ from ‘Rebuild All’,

Below changes need to be introduced in web.config of CM instance. As a best practice, this transform file can be added to the solution. If there is any existing CM web.config transform, the below config can be appended to it.

  <location path="sitecore modules/Maintenance Notification/js/serviceworker.js">
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Service-Worker-Allowed" value="/" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
  </location>

Module comes with default VAPID Keys but it is highly recommended to update the defaults for security reasons. New VAPID Keys can be created using web-push npm package. Below command can be executed to generate new Public/Private VAPID key pair,

npm install web-push -g
web-push generate-vapid-keys


Public Key needs to be updated in /sitecore/system/Modules/PowerShell/Script Library/Maintenance Notification/Notification Settings item. Private Key needs to be updated in the DevOps/Windows PowerShell scripts (described in the next section).

Module includes a default Sitecore API Key(works for 9.1+). But it is necessary to clone/create a new ‘OData Item API Key’ item(with same values) under /sitecore/system/Settings/Services/API Keys of master database for v9.1+ (make sure to publish to web). Item needs to be created under /sitecore/system/Settings/Services/API Keys of core database if v9.0.

For Impersonation User, it is recommended to create a new user(Eg: sitecore\MaintenanceNotification) with just read access only to the items under /sitecore/system/Modules/PowerShell/Script Library/Maintenance Notification. Item ID of this newly created ‘OData Item API Key’ item will need to be updated in DevOps/Windows PowerShell scripts (described in the next section).

FOR RECEIVING ALERTS:
Content Authors and Marketers will have to just select ‘Subscribe to Scheduled Maintenance Notifications’ of ‘Preferences/My Settings’ section of Control Panel, from normal mode of browsers (not incognito/inprivate) to receive maintenance notifications

FOR SENDING ALERTS:
DevOps team will have two options to send notifications during deployments,
DevOps Integration(Automated):
Module comes with two Powershell scripts,

The scripts require four variables. Since $sitecoreHostUrl, $vapidPrivateKey and $sitecoreAPIKey will be consistent across releases, they can be created as pipeline variables. VAPID Private Key and Sitecore API Key Item ID obtained in the above section needs to be assigned to $vapidPrivateKey & $sitecoreAPIKey. $sitecoreHostUrl will be the CM Domain Url. $maintenanceStartDateTime will need to be supplied as input for every release (Format: yyyy/MM/dd HH:mm EST  Ex:2021/01/18 10:00 EST). Script can be tweaked to accept deployment start date/time in another timezone if needed.

This script works with all the DevOps tools that support Powershell tasks. The initial demo uses Azure DevOps self-hosted agent to deploy to a windows machine.

Windows PowerShell(Manual):
Module includes a Windows PowerShell script (SendMaintenanceNotification(Optimized for Manual Notification).ps1), which can be used for sending/clearing notifications anytime without using DevOps tool.
Script requires deployment start date/time as input for every release, to send notifications accordingly. Sitecore CM Domain Url and VAPID Private Key & Sitecore API Key Item ID (created in the above section), needs to be updated in this script directly for $sitecoreHostUrl, $vapidPrivateKey, $sitecoreAPIKey variables.
This Script will automatically send scheduled alerts, reminders, and completion messages based on the input date/time to all subscribed users. Script will send notifications based on the availability of the site, hence do not close this powershell window till end of maintenance, else reminders and completion messages might be skipped.

The module configuration is now complete!

BACKGROUND:
This module leverages the following popular libraries/modules,

  • Service Worker – will be installed in the browser with on click of Subscribe button for receiving notifications. Service Worker is supported in the recent versions of all latest browsers
  • Web-push NPM Package – used for sending optimized Push Notifications.
  • IDB-KeyVal library served via cdnjs – a tiny js imported by Service Worker into users’ browsers for easy storing/retrieving of values in/from Browser IndexedDB (helps to avoid loss of data upon browser/system restart)

This module also relies on the below Sitecore services to keep the details centralized and editable from Sitecore without impacting security,

  • Sitecore ItemService – for fetching Notification Settings and storing User Subscription information received from Service Worker
  • Sitecore OData Item Service – for reading the Subscriptions from Sitecore during DevOps/Windows PowerShell script execution

TIPS:

  • In the event of maintenance cancellation, running the Manual PowerShell script without specifying any input will automatically clear notifications for all subscribed users
  • If the maintenance time or details change, sending the updated time or details through Windows/DevOps PowerShell will overwrite the previously sent details for all users
  • There are chances that a user might have removed the service worker while clearing browser data. In such cases, PowerShell script will throw subscription expired error with failed user’s subscription endpoint url. This won’t affect notifications for other users, but it is recommended to manually remove the respective subscription json(along with date) from /sitecore/system/Modules/PowerShell/Script Library/Maintenance Notification/Push Subscriptions item.
  • If authors/marketers will need more lead time, adding Agentless jobs with Manual Intervention or Delay tasks will be helpful to communicate well in advance and will also free up agents for other tasks during the wait time. Alternatively, manual approach can be used just for initial communication.
  • Service Worker will require localhost or https. In case if the implementation doesn’t meet this requirement, Invoke-AddWebFeatureSSLTask powershell command might help to get a quick self-signed certificate.
  • Notification Settings can be updated if/as needed in /sitecore/system/Modules/PowerShell/Script Library/Maintenance Notification/Notification Settings,

Source Code for this module is available in Github.

Voila!