Analyze page content using brand review
In this walkthrough, you combine multiple GraphQL queries with the Brand Review REST API to build a content analyzer that evaluates page content against brand guidelines. When the SitecoreAI Page builder user clicks a button, your app retrieves the site structure, fetches all page content and data sources, extracts meaningful text, and generates a comprehensive brand compliance review.
Consider building such an interaction if you're building an app that helps content authors ensure their content complies with brand standards. For more information, see example scenarios for using the Brand Review REST API in your Marketplace app.

This walkthrough describes how to:
-
Complete the SDK quick start and initialize the
xmcandaipackages.In this walkthrough, you update the code you added to your project in the quick start.
-
Open your Marketplace app in the SitecoreAI Page builder context panel extension point.
-
We recommend that you familiarize yourself with single operations, such as making a GraphQL query and making a Brand Review API request.
-
Retrieve your brand kit ID and section IDs using the Brand Management REST API. You use these IDs to make requests to the Brand Review REST API from your Marketplace app.
Create components and set up state
Before you can analyze page content, you need to create the necessary components and set up state management to pass data between them.
To create the necessary components and set up state:
-
In the
srcfolder, create a component for the GraphQL queries, and another one for the brand review request. You'll update the file contents in the next procedure: -
Update the file where you run the
useMarketplaceClienthook by importing the new components, creating state variables for the content to review, the brand review results, and the page context, and then include the new components in the return statement: -
In the same file, in the Effect Hook, below the
"application.context"query, subscribe to page events to reset the review results when the user opens a different page. This ensures the user can click the button again to analyze the new page:
Retrieve page content and send it for brand review
After creating the components and setting up state, you make a GraphQL query that retrieves detailed page content including data sources. Then, you send the content to the Brand Review REST API for brand review.
To retrieve page content and send it for brand review:
-
In
components/GraphQLQuery.tsx, create the query and render a button Analyze Page Content: -
Below the query and above the default function, paste the following helper functions that collect and sanitize meaningful text from a page:
-
In the
makeGraphQLQueryfunction, retrieve the Context ID from the application context, and information about the current page from the page context: -
Immediately below the page information check, add a try-catch block. This block makes the GraphQL request, combines the page contents into a single string, and generates the brand review for that string:
Replace the brand kit placeholders with your brand kit details. To retrieve these details, use the Brand Management REST API.
Display the brand review
After creating all the API requests, you display the brand review results to the user.
To display the brand review:
-
In
components/BrandReview.tsx, create a component to display the brand review response: -
Save all your file changes and start your app.
-
In the SitecoreAI Page builder, open your web browser's Network tab, refresh the page, then open your Marketplace app.
-
In the Marketplace app, click Analyze Page Content.
-
On the Network tab, find POST requests made to
graphql?and togenerate?. These are the requests you made to the GraphQL API and the Brand Review API when you clicked the button in your app. -
Your app displays the brand review.
Next steps
You've now built a content analyzer that combines multiple GraphQL queries with the Brand Review REST API to evaluate page content against brand guidelines.
Next, you can:
-
Explore the Authoring and Management GraphQL API to make other complex queries and mutations. For example, to update the contents of the page using the recommendations returned by the Brand Review API.
Then, develop the functionality of your app that reloads the canvas after updating the page contents.