Setup and Use Sitecore CMP Connector. Part 1

Jay Bonning - Jun 6 - - Dev Community

That sure is a nice Sitecore Content Hub you've got there. It is a good bet that you would like to use some of that content on XM Cloud. So lets do that.

This might get a bit long. So, briefly, here is what I am going to be describing how to do:

  • Setup an Action and Trigger inside of Content Hub
  • Setup the CMP connector inside of your XM Cloud application
  • Setup data mappings for the content hub items.
  • List some issues I had along the way and how they were overcome.

   
Assumptions:

  • You have access to create Triggers and Actions in Content Hub.
  • The content item you need to sync has already been created. I will show off what the sample one looks like, but I will not go into its creation.
  • You have access to add variables to your Sitecore XM Cloud project.
  • You already setup an Oauth connection string setup in Content Hub that is being used to connect to the DAM. We will reuse this for the cmp connection, but these can be different if you have difference security requirements.

   

Content Hub Actions and Triggers

     

Create an action

Actions are the way we communicate between the two systems and triggers are ways to cause the action to fire.

The action we are going to want to setup is a service bus action. There are two types supported.

  • Azure Service Bus - An azure service bus setup and maintained by you. So some of this setup can be useful for any other downstream application that might want to use the date being emitted by Content Hub.
  • M Azure Service Bus - A service bus topic setup and maintained by Sitecore.

For this we are going to be using the 'M Azure Service Bus' because I don't want to have to setup and maintain anything myself. When you add a new action select the Type "M Azure Service Bus" and choose "Topic" as the Destination Type.

Image description  

Make sure to copy the values that are generated in "Hub In" and "Hub Out". you will be using these later to setup the connection in XM Cloud.

Image description  

Now we have a way to send the data, we need a way to trigger the information exchange to happen.

     

Create a trigger

We now need to tell Content Hub to actually send the message. For this instance we are publishing out a simple new article which has already been defined as a content item. The news article we are syncing between systems has a title and a rich text body.

Image description  

It is also worth noting right now that this is also where we can see all the related taxonomy for content items in the system.

Image description  

Setting up the trigger is fairly simple. We define basic information about the trigger. Here I want to make sure I check all the objectives, since I might be mutating the object later, and the execution type as "in background" so it does not stall out any of the processing.

Image description  

The conditions can become quote specific. In this example I want to sync the object when a user has fully published the news item. The content item of "M.Content" has the information about the publish state and there is a separate publish flag that was added on the news item itself. I need to make sure both of these conditions are matched before I perform my action.

Image description  

Now all we have to do is tie in the action we created earlier and we are all set to start sending out information.

Image description

     

Setup the CMP connection on XM Cloud

In your Sitecore XM Cloud deploy portal you will need to setup a few values to get your CMP functionality working.

  • SITECORE_AppSettings_cmpEnabled_define - Enables the CMP connector in the system. (yes or no)
  • Sitecore_ConnectionStrings_CMP_dot_ContentHub - Connection string to content hub. You can reuse your DAM OAuth connection string here.
  • Sitecore_ConnectionStrings_CMP_dot_ServiceBusSubscription - Name of the azure service bus subscription. More on this later.
  • Sitecore_ConnectionStrings_CMP_dot_ServiceBusEntityPathOut - HUB IN connection string from the service bus action that was setup.
  • Sitecore_ConnectionStrings_CMP_dot_ServiceBusEntityPathIn - HUB OUT connection string from the service bus action that was setup

   
Image description  

This will cause the CMP items to start showing up inside of Sitecore.

   
Before:

Image description  

   
After:

Image description  

   
Now your application should be setup to receive information from Content Hub.

     

Some problems we ran into

   

The value for Sitecore_ConnectionStrings_CMP_dot_ServiceBusSubscription

It was not immediately apparent what the value of this was meant to be. If you are not familiar with how a topic works on Azure service bus it is basically a way to allow multiple "receivers" to handle the messages posted to a topic.

  • It was not the name of the action in Content Hub.
  • It was not derived from the action name.

after opening a ticket with Sitecore we did find out ours was named 'hub_out_subscription'. You can try this if you are having issue with your application receiving information. you might have to open a support request to get the name of yours though.

If you are setting up your own service bus, this will not be a problem.

   

Authentication / SSO

Working to get this up and going we also ran into an issue with authentication. Our content hub was originally setup to ONLY accept connections over SSO. This was causing the OAuth connection between Content Hub and XM Cloud to fail. We needed to go into Content Hub settings and set 'EnableBasicAuthentication' to true.

Image description  

Setting up data mappings coming in part 2

. . .