Accelerating Workflow Process with Sitecore + Microsoft Teams Integration Module

It is highly important to equip Content Authors with required tools/integrations that will help them to accomplish tasks with minimal clicks possible. When it comes to involvement of more than one person (Content Author, Content Approver), there is a high possibility of delays in taking updates live that might be time-sensitive due to expected/unexpected communication delays. Automating this communication effectively through the business communication/collaboration platform along with quick actions(approve/reject), will not only avoid the delays but also help to optimize time & work. This modules allows seamless integration of Sitecore Workflow with Microsoft Teams (which is now replacing Skype).

The module can be downloaded from the below links,
Sitecore – Microsoft Teams Integration for SPE 6.x
Sitecore – Microsoft Teams Integration for SPE 5.x

NOTE:

  • This module is built on top of Sitecore Powershell Extensions (SPE), please make sure SPE is installed before installing this module
  • This module uses Sitecore Feed Urls, hence Approvals reside behind Sitecore Security and the links will prompt the Content Approver to authenticate before approving/rejecting the updates (if not logged in already)

STEPS TO CONFIGURE THE MODULE:

GIF by joelremygif (GIF Image)

Creating Microsoft Teams Channel:

  • Navigate to ‘Teams’ section of Microsoft Teams from left navigation bar and click on ‘Join or Create a Team’ Button
  • Select ‘Build a team from scratch’ (or) ‘Create from an existing team’ to create the team/channel
  • Provide Name (preferably ‘Workflow Moderators’) & Description for the Team and add required Content Authors & Approvers

Adding WebHook:

  • Once the team/channel is created, click on the ‘More Options’ (three dots) button available in the top right corner and click on ‘Connectors’
  • Search for ‘Incoming Webhook’ in the opening popup and click on ‘Add’ button
  • Add Name(preferably ‘Sitecore Workflow’) and Image, and click on ‘Create’ button
  • Copy the ‘WebHook URI’ which is appearing before closing the window
  • Navigate to \App_Config\Include\Sitecore+MicrosoftTeams.Integration.config file and paste the copied WebHook URI within value attribute of ‘Teams.WebhookURI’ setting,

Setting up Workflow Notifications:

  • Navigate to the Workflow for which the Notifications have to be setup
  • Right-Click Submit Action of Draft State, click on Insert -> PowerShell Action and Enter name as ‘Awaiting Approval Notification’
  • Select ‘Script Library/Sitecore + Microsoft Teams Integration/Workflow/Awaiting Approval Notification’ for ‘Script’ field in the newly created ‘Awaiting Approval Notification’ item
  • Similarly, add PowerShell Actions under Approve & Reject actions and choose ‘Script Library/Sitecore + Microsoft Teams Integration/Workflow/Approved Notification’ & ‘Script Library/Sitecore + Microsoft Teams Integration/Workflow/Rejected Notification’ for ‘Script’ field respectively
  • If you’re using Sitecore Powershell Extensions version 6.1.1 or older, you will be needing to update the ‘Type string’ field value as ‘Sitecore.MicrosoftTeams.Integration.Workflows.ScriptAction, Sitecore.MicrosoftTeams.Integration’ (this ScriptAction class comes with the module) for ‘Approved Notification’ and ‘Rejected Notification’ items in case if you face the error described in https://github.com/SitecorePowerShell/Console/issues/1204

The configuration is now complete!
Awaiting Approval, Approved and Rejected Notifications should now be appearing in the configured Teams Channel.
Voila!

Come Here Lets Go GIF by Luis Ricardo (GIF Image)

Investigating Audit Logs with Sitecore Powershell Reports

Very often Content Administrators seek history of activities performed on an item like edit, publish, workflow approval etc. Though we have options like Sitecore Log Analyzer, it requires developers’ assistance while it is critical to equip Content Administrators to function independently.

Sitecore Powershell comes with a super cool report, ‘Find Audit Trail from logs’ which crawls through the logs for the specified timeframe yielding all the audit logs (without exceptions etc. ;), Sitecore Log Analyzer will need to be used for analyzing exceptions). I haven’t seen much mention of this report and speaking to a few people it seems to have been missed/unnoticed. Here is how you can access the same,

Like any other Sitecore Powershell report, we do have the export and filter options available in this report as well, which makes our life easier.
We experienced one issue which was specifically due to an error in the format of certain log entries,

Few log entries in our instance were having a weird additional spacing before the thread id though the log4net conversionPattern etc. were correct. This appeared to the root cause for the above issue,

Updating the following line to remove empty entries fixed the issue,

By default Sitecore Powershell Reports are enabled only for Administrators. When it is needed for other roles, we will be needing to provide read access to /sitecore/content/Documents and settings/All users/Start menu/Right/Reporting Tools/PowerShell Reports item in core database.

If we are looking to provide access only for this specific report, then deny access will need to be added to other reports under /sitecore/system/Modules/PowerShell/Script Library/SPE/Reporting/Content Reports/Reports item in master database. It is important to note that the Content Author will be able to view history of activities performed on all the items including the ones for which they might not have access.

This Report was introduced in Powershell Extensions 5.0, if you are using an older version, you could use this package.

If you are using Sitecore PAAS with Azure Application Insights, you will be needing Application Insights App ID/Key and will be needing to fetch the logs using Azure Application Insights Queries. The below blog will be helpful for PAAS setup, https://www.sitecoregabe.com/2019/09/azure-application-insights-logs.html

References:
https://www.sitecoregabe.com/2018/08/basic-sitecore-audit-trail-with.html
https://github.com/SitecorePowerShell/Console/issues/1033

Efficient way to retrieve list of created/updated and deleted items during Publish

While we are familiar with publish:itemProcessed event that will be triggered once per processed item during publish, there might be instances where we might be looking to work on the entire list of published items all at once to accomplish the desired operations efficiently.

Sitecore has introduced ProcessedPublishingCandidates property (previously it was ProcessedItems which is obsolete now), which accumulates the processed items within the PublishItem pipeline. The PublishItem pipeline holds the responsibility of publishing a single item from the publish queue (this pipeline can also be intercepted with publish:itemProcessed, publish:itemProcessing events). The ProcessedPublishingCandidates property is accessible within the Publish pipeline as well (this pipeline manages the entire publish operation). This behavior enables us to retrieve the list of published items by intercepting the Publish Pipeline using ProcessedPublishingCandidates property.

Sitecore has also added DeleteCandidates property which
will be helpful if you are just looking to retrieve only the deleted items.

Here is the code snippet,

class CustomPublishProcessor : PublishProcessor
{
    public override void Process(PublishContext context)
    {
        Assert.ArgumentNotNull(context, "context");

        if (context.Aborted)
            return;
	
        //Fetches List of Processed(Created/Updated/Deleted) Items
        var processedItems = context.ProcessedPublishingCandidates.Keys
                .Select(i => context.PublishOptions.TargetDatabase.GetItem(i.ItemId)).Where(j => j != null);

        //Fetches List of Deleted Items
        var deletedItems = context.DeleteCandidates;
    }
}
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <publish>
        <processor patch:after="*[@type='Sitecore.Publishing.Pipelines.Publish.ProcessQueue, Sitecore.Kernel']" type="Assembly.Pipelines.CustomPublishProcessor, Assembly"/>
      </publish>
    </pipelines>
  </sitecore>
</configuration>

Please note that we do have another property ‘CustomData’ which is available within PublishContext, hence it is shared across all the pipeline steps. This allows us to store any custom data specific to a processed item within CustomData property during PublishItem pipeline and can then be utilized across other steps within PublishItem and Publish pipelines if needed.

Extend Sitecore Experience to China

China being one of the top economies in the world, huge number of business entities are focusing to expand their services in China. Since websites are the face of the organization, it is highly crucial to have the websites perform better across different intended geographies for better user experience, but performance is a huge concern for websites in China when hosted outside of the country. While adding Content Delivery Network (CDN) usually improves the performance for different countries which are farther from the hosting servers, CDN setup process works little different for China.

There are a couple of major issues that make up to the slowness of the external websites in China,

Limited Peering Capacities – China has very limited internet providers with direct peering being  expensive. This makes the internet traffic exchange with the country highly congested and considered to be key reason for slowness.

The Great Firewall of China (GFW) – The country uses Deep Packet Inspection to monitor all the requests flow. This may also cause package loss, resulting in retransmission which slows the transaction even more.

In order to mitigate the above, to provide consistent load times in China, the easier route is to host the website in China. For hosting websites in China, a ICP (Internet Content Provider) License is mandatory which in turn requires the company to have a China business entity and a website with a Chinese domain registrar. This may also bring in the need of purchasing a new domain specifically for China region from Chinese domain registrar, probably .cn or .com.cn, based on the existing domain setup. Once the application for ICP is submitted and approved by Ministry of Industry and Information Technology (MIIT), an ICP Number is generated which is required to be placed in the website’s footer.

Few tasks including Infrastructure Setup can happen in parallel to the ICP Registration. There are a few options like Aliyun (Alibaba Cloud), Azure, AWS etc. for hosting the sites. Since AWS is one of the top providers in China and the current sites were hosted on AWS(IAAS), AWS China IAAS solution worked better for our situation. The platform selection requires some level of quality analysis based on existing infrastructure. Load Balancer should be considered for High Availability.

Here are few approaches that should be considered while hosting the website in China,

Setting up a New Website Infrastructure – Few businesses would prefer to run China websites separately from the existing infrastructure due to differences in website appearance, behaviour or content. This will introduce the need of setting up all required Application/Storage Roles and Environments.

Extending the Existing Website Infrastructure – Most of the businesses would like to retain their branding etc. which eliminates the need of setting up Content Management Role, Staging, UAT etc. unless it is required. Content Delivery and xDB/xConnect Application/Storage Roles will suffice the need.

Setting up CDN in China – Using China CDNs is another option which works well but introduces lot of challenges in leveraging different Experience Management capabilities of Sitecore. Please note that setting up CDNs in China will still require ICP Registration.

 

It is highly crucial to review the China Data Protection Regulations (CDPR) when there is a collection of personal information happening in any part of the website. Though there are various draft measures and sector-specific regulations on transfer of personal data outside borders of China, it is unclear at this point to what extent these rules apply and it is expected to be clearly defined this year. There is also a requirement to appoint a Data Protection Officer in China for large organizations depending on the quantity of data being collected/processed.

Though Google Chrome is the widely used Browser in China, there are few additional Browsers including Tencent’s QQ browser, Alibaba’s UC browser, Baidu, Sogou etc. which is being used by huge number of users. Hence it is important to make sure our websites are compatible with these additional browsers across different devices.

There are few Social Media including Facebook, Google+ etc. which are blocked in China, hence related integrations must be reviewed.

Though Google Analytics works in China, Baidu is highly preferred considering the following reasons,

  • Latency and Data loss issues when using Google Analytics
  • Google Analytics Web Interface being blocked in China

And there is no guarantee that Google Analytics won’t be blocked in future.

Despite all the above challenges and process, it is still worth doing. We did have our website performing about 70-80% faster in different regions of the country after hosting the sites in China.