In a recent Sitecore XM Cloud project, we faced a challenge: how to use AI to assist content authors in improving their content while ensuring it aligns with the brand's tone and voice. The goal was to allow authors to click a button in Sitecore, send the serialized content to a private AI model (GPT), and receive AI-generated review comments tailored to the brand’s guidelines.
In this post, I'll walk through the technical implementation of this AI-powered content review system, covering:
- Custom AI GPT setup
- Integration with Sitecore XM Cloud
- Handling content serialization and API communication
- Review comment display in Sitecore
Step 1: Setting Up a Private AI GPT Model
Instead of using a public AI model, we set up a private GPT model trained on the brand’s tone, voice, and knowledge base. This ensures the AI-generated feedback is brand-aligned.
We used Azure OpenAI Service to host our private GPT model with a custom dataset containing:
- Brand tone and voice guidelines
- Existing well-written content for reference
- Rules for grammar, consistency, and clarity
Setting Up Azure OpenAI Service
- Deploy a Private OpenAI GPT Model in Azure OpenAI:
az cognitiveservices account create \
--name my-private-gpt \
--resource-group my-resource-group \
--kind OpenAI \
--sku S0 \
--location eastus
- Train the AI model with the brand's knowledge base by fine-tuning it with well-crafted content samples.
- Deploy the trained model and obtain the API endpoint and key.
Step 2: Integrating AI Review Button in Sitecore XM Cloud
Next, we add a “Review with AI” button in the Sitecore XM Cloud editor. When clicked, it will:
- Serialize the page content
- Send the data to the AI API
- Display AI-generated review comments
Creating a Custom Sitecore Command
We create a custom Sitecore Ribbon Button and command in the editor:
1. Register the Custom Button
Modify core database configurations to add the AI review button:
<command name="content:reviewWithAI" type="MyNamespace.AIReviewCommand, MyNamespace" />
2. Implement the AI Review Command
Create AIReviewCommand.cs:
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;
using System.Net.Http;
using System.Threading.Tasks;
public class AIReviewCommand : Command
{
public override void Execute(CommandContext context)
{
var serializedContent = GetSerializedPageContent(context);
var reviewResponse = GetAIReview(serializedContent).Result;
SheerResponse.Alert(reviewResponse);
}
private async Task<string> GetAIReview(string content)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_AI_API_KEY");
var response = await client.PostAsJsonAsync("https://your-private-gpt.com/review", new { content });
return await response.Content.ReadAsStringAsync();
}
}
}
This command fetches serialized page content, calls the AI review API, and shows the AI-generated comments in a pop-up.
Step 3: Serializing Page Content for AI Analysis
For accurate AI recommendations, we need to serialize the page content before sending it to the AI model. We include:
- Page fields (title, body, meta descriptions)
- Content blocks
- Localization details
Serializing Content in Sitecore
private string GetSerializedPageContent(CommandContext context)
{
Item item = context.Items[0];
var contentData = new
{
Title = item["Title"],
Body = item["Body"],
MetaDescription = item["Meta Description"],
Language = item.Language.Name,
Url = Sitecore.Links.LinkManager.GetItemUrl(item)
};
return JsonConvert.SerializeObject(contentDataStep 2: Integrating AI Review Button in Sitecore XM Cloud
Next, we add a “Review with AI” button in the Sitecore XM Cloud editor. When clicked, it will:
Serialize the page content
Send the data to the AI API
Display AI-generated review comments
Creating a Custom Sitecore Command
We create a custom Sitecore Ribbon Button and command in the editor:
1. Register the Custom Button
Modify core database configurations to add the AI review button:
<command name="content:reviewWithAI" type="MyNamespace.AIReviewCommand, MyNamespace" />
2. Implement the AI Review Command
Create AIReviewCommand.cs:
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;
using System.Net.Http;
using System.Threading.Tasks;
public class AIReviewCommand : Command
{
public override void Execute(CommandContext context)
{
var serializedContent = GetSerializedPageContent(context);
var reviewResponse = GetAIReview(serializedContent).Result;
SheerResponse.Alert(reviewResponse);
}
private async Task<string> GetAIReview(string content)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_AI_API_KEY");
var response = await client.PostAsJsonAsync("https://your-private-gpt.com/review", new { content });
return await response.Content.ReadAsStringAsync();
}
}
}
This command fetches serialized page content, calls the AI review API, and shows the AI-generated comments in a pop-up.
);
}
This ensures we send structured content to the AI API for review.
Step 3: Serializing Page Content for AI Analysis
For accurate AI recommendations, we need to serialize the page content before sending it to the AI model. We include:
- Page fields (title, body, meta descriptions)
- Content blocks
- Localization details
Serializing Content in Sitecore
private string GetSerializedPageContent(CommandContext context)
{
Item item = context.Items[0];
var contentData = new
{
Title = item["Title"],
Body = item["Body"],
MetaDescription = item["Meta Description"],
Language = item.Language.Name,
Url = Sitecore.Links.LinkManager.GetItemUrl(item)
};
return JsonConvert.SerializeObject(contentDataStep 2: Integrating AI Review Button in Sitecore XM Cloud
Next, we add a “Review with AI” button in the Sitecore XM Cloud editor. When clicked, it will:
Serialize the page content
Send the data to the AI API
Display AI-generated review comments
Creating a Custom Sitecore Command
We create a custom Sitecore Ribbon Button and command in the editor:
1. Register the Custom Button
Modify core database configurations to add the AI review button:
<command name="content:reviewWithAI" type="MyNamespace.AIReviewCommand, MyNamespace" />
2. Implement the AI Review Command
Create AIReviewCommand.cs:
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;
using System.Net.Http;
using System.Threading.Tasks;
public class AIReviewCommand : Command
{
public override void Execute(CommandContext context)
{
var serializedContent = GetSerializedPageContent(context);
var reviewResponse = GetAIReview(serializedContent).Result;
SheerResponse.Alert(reviewResponse);
}
private async Task<string> GetAIReview(string content)
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_AI_API_KEY");
var response = await client.PostAsJsonAsync("https://your-private-gpt.com/review", new { content });
return await response.Content.ReadAsStringAsync();
}
}
}
This command fetches serialized page content, calls the AI review API, and shows the AI-generated comments in a pop-up.
);
}
This ensures we send structured content to the AI API for review.
Step 5: Displaying AI Review Comments in Sitecore
Once the API returns review comments, we display them in Sitecore.
Enhancing UI with AI Feedback Panel
Modify the Sitecore command to display AI feedback elegantly:
SheerResponse.ShowModalDialog("/sitecore/shell/Applications/AIReviewPanel.aspx?comments=" + HttpUtility.UrlEncode(reviewResponse));
In AIReviewPanel.aspx, display comments in a custom review panel.
<div class="ai-feedback">
<h2>AI Content Review</h2>
<p><%= Request.QueryString["comments"] %></p>
</div>
This approach enables one-click AI content review in Sitecore XM Cloud/XP/XM, providing real-time feedback aligned with brand voice. By leveraging private AI models, we ensure brand consistency while optimizing content creation.
✅ Key Benefits:
- Ensures brand tone and voice compliance
- Provides instant feedback for content authors
- Uses private AI for customized recommendations
🚀 Next Steps:
- Extend AI feedback to inline suggestions
- Implement sentiment analysis for user engagement insights
- Enhance AI model with real-time content analytics
What’s your take on AI-powered content optimization? Let me know your thoughts!