Go to main content Go to main menu

Extending support to Commerce

By default, AI Assistant operates only on content within Optimizely CMS. If your solution also includes Optimizely Commerce, you need to extend the assistant's scope by registering additional site contributors. This allows AI Assistant to recognize these sources as valid content roots and include them in its analysis and generation workflows.

Overview

AI Assistant is built on a site-based abstraction model, where each "site" defines a root content scope. These roots act as entry points that the assistant can traverse, and use as contextual input during generation.

  • CMS: Automatically registered (Start Page root)
  • Commerce: Requires manual registration (Catalog root)
  • CMP: Requires manual registration (CMP content root)

To include additional sites, you must implement and register ISiteContributor interface.

1. Implement a Commerce site contributor

The following implementation maps the Commerce Catalog root into the AI Assistant's site.

Implement Commerce site contributor

using Epinova.CMS.AiAssistant.AiTools.Sites;
using EPiServer;
using EPiServer.Core;
...
public class CommerceSiteContributor : ISiteContributor
{
    private readonly IContentLoader _contentLoader;
    private readonly ReferenceConverter _referenceConverter;

    public CommerceSiteContributor(
        IContentLoader contentLoader,
        ReferenceConverter referenceConverter)
    {
        _contentLoader = contentLoader;
        _referenceConverter = referenceConverter;
    }

    public int Priority => 10;

    public IEnumerable<Site> GetSites()
    {
        var catalogRoot = _referenceConverter.GetRootLink();

        if (_contentLoader.TryGet<IContent>(catalogRoot, out var catalog))
        {
            yield return new Site(
                catalog.ContentGuid,
                catalog.Name,
                catalogRoot);
        }
    }
}
  • ReferenceConverter.GetRootLink() resolves the Commerce Catalog root
  • IContentLoader ensures the content exists and is accessible
  • Site encapsulates:
    • Unique identifier
    • Display name
    • Root reference
  • Use Priority to control ordering if multiple contributors exist
    • Lower values = higher precedence

2. Register the contributor

Register your implementation in the DI container:

services.AddScoped<ISiteContributor, CommerceSiteContributor>();

3. Verify AI Assistant scope expansion

After registration, the new site appears in the site selector on the management UI (for example, Alt Text Manager, Metadata Manager and FAQ Manager).