Use the Sitecore Content Tagging framework in your custom solution


How to programmatically call the Sitecore Content Tagging framework to perform custom tagging operations.

The Sitecore Content Tagging feature provides a generic framework with a set of abstractions that allows you to create a custom implementation for any part of the tagging process. The default implementation enables Sitecore to tag Sitecore items based on the content of each item. The Tag commands on the ribbon in the Content Editor and the Experience Editor integrate the feature into the Sitecore user interface (UI).

To integrate the Sitecore Content Tagging framework into your custom solution, you can use the default Sitecore Content Tagging implementation, or you can build custom providers to implement a custom tagging flow.

To use the default content tagging implementation for Sitecore items in your custom solution:

  1. Get the ContentTaggingRunner and MessageBusFactory  services as follows:

    var ContentTaggingRunner = ServiceLocator.ServiceProvider.GetService<IContentTaggingRunner>();
    var MessageBusFactory = ServiceLocator.ServiceProvider.GetService<IMessageBusFactory>();
  2. Create a message bus. The UI can communicate with the process through the message bus. You must also implement a custom message handler.

    var messageBus = MessageBusFactory.Create();
    var messageHandler = new CustomMessageHandler();
  3. Pass the content item and message bus instance to the runner.

    ContentTaggingRunner.Run(item, messageBus);