Sitecore connector for Content Hub CMP

Sitecore Content Hub CMP Connector

How to install Sitecore’s Connect Hub CMP connector “Sitecore Connect™ for Sitecore CMP 1.0.0”

Versions used: Sitecore Experience Platform 9.2 Initial Release. Content Hub 3.2

Sitecore Connect™ for Sitecore CMP pulls content from Content Hub and stores them in Sitecore buckets. The connector requires an azure service bus that supports topics. See below.

What gets synced and when is configured in Content Hub via triggers. Content Hub sends configured content to an Azure Topic. On Sitecore side, the connector is listening to this topic and creates/updates items when messages are added. It then creates a message on another topic with information about what was done.

For the connector to work, you need to configure the following 3 places::

  • Azure Services Bus
  • Content Hub
  • Sitecore Content Management

Azure Services Bus

As mentioned before, you need a subscription that allows to select either Standard or Premium Pricing tier. This is because the connector uses Topics which are not avaiable on Basic tier.
Azure Service Bus Tiers

  • On azure portal, go to Resources and click on Add. Search for Service Bus, then click on create.
  • Enter desired name for your Service Bus service. Select Subscription, Resource Group, Location and either Standard or Premium pricing tier.
  • Once created, go to the service and click on Shared access policies.
    – Click on Add. Create a new Policy named ManageSendListenAccessKey with Manage, Send and Listen access. Or use default RootManageSharedAccessKey.
    – Click on newly created ManageSendAccessKey policy and copy one of the connection strings. You will need this later. [connection string]
  • Now click on Topics.
    – Create a topic and call it cmp_content. Set desired configuration on the topic. cmp topic
    – Create another topic and call it sitecore_notifications. Set desired configuration on the topic. sitecore notifications topic
    – Go inside the cmp_content topic and create a subscription called sitecore. cmp topic subscription

The service bus is now ready. CMP will send messages to cmp_content topic and the connector will subscribe to sitecore subscription and act when messages are added to the topic.

Content Hub

In Content Hub, you need an Action of type Azure Service Bus and a Trigger that invokes this action when the desired content should send a message to the service bus.

Action

  • Log in to Content Hub and go to Manage -> Actions.
  • Click on new Action. Enter desired name (e.g. CMP - Content to Service Bus) and label. Under type, select Azure Service Bus.
    – Enter copied Service Bus connection string.
    – Select Topic as Destination type.
    – Enter cmp_content cmp topic in Destination field.
    – Test Connection and click Save when done.

Trigger

  • Log in to Content Hub and go to Manage -> Triggers.
  • Click on new Trigger. Enter desired name (e.g. CMP - On Published Content) and description. Under objective, select Entity creation and Entity modification.
  • Set execution type to In background.
  • Click on Conditions tab and add a Definition with Content (M.Content). If left like this, the trigger will execute whenever an entity of type M.Content, CMP’s default, is created or modified. You can add as many conditions as you wish if you want to restrict which content is sent to the service bus. For example, if you want only Published content to be sent to the bus, add a condition like: Active state (MContentToActiveState) added item contains any Published.
  • Click on Actions tab and add created action CMP - Content to Service Bus to Post Actions.
  • Save trigger and make sure it’s enabled.

Sitecore Configuration

Now that Azure and Content Hub have been configured, you are ready to install and configure the connector; and then, create Content Hub to Item mappings.

Connector Configuration

  • Download Sitecore Connect™ for Sitecore CMP 1.0.0 from sitecore website.
  • Install the package on your CM server via Sitecore package installer.
  • Navigate to item /sitecore/system/Modules/CMP/Config
    – Populate the fields as follows:
    Client Id and Client Secret : from a Content Hub OAuth client. Find or create one under Manage -> OAuth Clients.
    User Name and Password : from a Content Hub User with sufficient permissions to read content from entities being pushed.
    Content Hub URI : the full URL of your Content Hub instance without trailing slash.
    Connection string : service bus connection string.
    Incoming topic name : cmp_content cmp topic.
    Incoming subscription name : sitecore cmp topic subscription.
    Outgoing topic name : cmp_content sitecore notifications topic.
    Default Language : en. This item language will be used if no language is specified in Content Hub. Note: en is default in Sitecore whereas en-US is default in Content Hub.

Templates and Mappings

  • Create a new template that contains /sitecore/templates/CMP/Content Hub Entity as a Base template under desired templates folder. e.g. Advertisement. sitecore template
    • Add the fields you want to sync from Content Hub. Select appropriate field types (Only text fields are supported).
    • Mark as Bucketable.
  • Create a new Bucket under /sitecore/content/CMP. e.g. Advertisements.
  • Navigate to item /sitecore/system/Modules/CMP/Config and create a new /sitecore/templates/CMP/Entity Mapping item under it. e.g. Advertisement.
    • Populate the fields as follows:
      • Content Type Id : M.ContentType.Advertisement. To find this id, go to your Content Hub instance and navigate to Manage -> Taxonomy -> M.ContentType, and click on the info icon next to the desired type. The identifier is what you need.
      • Bucket : /sitecore/content/CMP/Advertisements. The parent location where you want the items to be created.
      • Template the newly created sitecore template containing the fields to map tositecore template.
    • Create an item of type /sitecore/templates/CMP/Field Mapping under it. e.g. Title.
      • Populate the fields as follows:
        • CMP Field Name : Advertisement_Title. To find this id, you can either find the field on the M.Content entity definition under Manage -> Schema -> M.Content, or find a content entity with the desired type, grab the entity id from the URL and navigate to https://content-hub-instance/api/entities/entity_id to find the property id.
        • Sitecore Field Name : Title. The field name where the data should map to.
      • Create as many items as fields are required.

Voilà! Now your connector has been configured. Restart your sitecore instance and items should be created as soon as the Content Hub trigger executes.
Hint: Look at your sitecore logs to find errors and it logs a lot when something fails.

====================

References:
https://dev.sitecore.net/Downloads/Sitecore_Connect_for_Sitecore_CMP/10/Sitecore_Connect_for_Sitecore_CMP_100.aspx


Please let me know what you think and/or if you can spot any errors.
/eom

Share