Design Adaptive Cards with AI in SharePoint (Microsoft community call demo)

Maintaining the same contact details on several SharePoint pages creates unnecessary work. A phone number changes, a new colleague joins, and suddenly several pages need updating. My Flexible Data Card Designer addresses this by displaying selected information from a central SharePoint list wherever it is needed. With the integrated Copilot assistant, page authors can also describe their preferred Adaptive Card layout in natural language and receive a design proposal directly in the web part.

In this article, I explain the business scenario, the configuration options, and the implementation behind the AI experience, based on my community call presentation.

The business requirement: Maintain data centrally and present it where it matters

The first version of the solution, created in 2021, focused on displaying contact information from SharePoint lists. The requirement was straightforward: maintain the data in one place and show the appropriate contacts on different pages.

For example, a company might store its contacts in a list on the intranet home site. An HR page displays the relevant HR contacts, while a project site shows its project representatives. Each page uses the same source list but selects the records and fields appropriate to its audience.

Cross-site access is essential for this scenario. The web part can point to a list on another SharePoint site within the tenant, subject to the user's access permissions. Authors can therefore choose the source independently of the page on which they place the web part.

This also separates content maintenance from presentation. Updating a record in the source list makes that updated information available to the cards that load it. Authors can adjust a page's layout without creating another copy of the underlying contact data.

What the Flexible Data Card Designer provides

The solution supports more than a fixed contact card. Authors choose the fields to display and configure how those fields appear. The main features include:

  • Cross-site data access: Select a source site and a list within the SharePoint tenant.
  • Explicit record selection: Enter the IDs of the list items to display.
  • Configurable fields: Choose the output fields and assign labels and icons.
  • Support for different field types: Resolve values such as images, links, and addresses for presentation.
  • Three output layouts: Choose Default, Aligned, or Adaptive Card.
  • Import and export: Reuse web part settings on other pages.
  • AI assistance: Use Copilot to propose and refine an Adaptive Card layout.

Handling field types is an important part of the implementation. A field containing an image or a link needs different processing from a simple text value. The web part resolves supported field values so the selected layout can display the appropriate information.

Configuration: From a SharePoint list to a card

After adding the web part to a page, an author configures the data source and the output in the property pane.

  1. Select the source site. Choose the SharePoint site that contains the list.
  2. Select the source list. The web part loads the available lists from that site. After list selection, it loads the column information needed for field configuration.
  3. Specify the item IDs. Enter a comma-separated selection, such as 1,2, to display those records.
  4. Define the output fields. Choose the fields to include and configure their labels and icons where needed.
  5. Choose the output format. Select one of the predefined layouts or use an Adaptive Card template.

I deliberately chose selection by item ID for this scenario. When a page needs a few specific contacts, entering their IDs is easier than creating a separate filtered list view for each combination. The implementation loads the selected records rather than retrieving the entire list for display.

Import and export help when the same configuration is needed elsewhere. An author can reuse an existing setup and then adapt the selected records or presentation for the destination page.

Three layouts for different presentation requirements

The output format determines how the configured fields appear. The presentation distinguishes the layouts as follows:

Layout How it works Suitable use
Default Places fields at configured row and column positions using a Fluent UI grid. The first row is reserved for the card image. Cards that need control over field placement.
Aligned Arranges labels and values in a compact two-column CSS grid. Contact details and other structured lists of facts.
Adaptive Card Renders a Microsoft Adaptive Card from a JSON template. Custom card designs, including layouts created with AI assistance.

The predefined layouts provide a quick starting point. Adaptive Cards offer further flexibility, but their JSON structure can be difficult for authors who do not work with it regularly. That is the reason for adding the Copilot designer.

Designing an Adaptive Card through conversation

The AI experience appears as a chat panel inside the web part. An author describes the desired presentation, and Copilot generates a layout proposal. Follow-up messages can refine the design within the same conversation.

For example, an author could ask:

Show the full name as a clickable heading. Keep the contact details hidden initially and expand them when the user clicks the name.

This follows the interaction shown in the presentation: a compact contact heading with details that can be expanded through a click. The assistant translates the request into the Adaptive Card structure used by the web part.

Authors retain access to the generated JSON through the web part properties. They can inspect the proposal, make a precise manual adjustment, or continue the conversation to request another change.

The AI designer and the manual editor use the same stored template property. As a result, an author can move between conversational design and direct JSON editing while working on the same card layout.

The AI assistant requires a valid Microsoft 365 Copilot license for the user accessing the Copilot functionality. This requirement applies to the integrated Copilot experience described here.

How Copilot receives the SharePoint list context

A useful layout proposal needs to match the available list fields. A request such as “create a contact card” is insufficient if the assistant does not know the field names or data types.

The implementation therefore treats the first message differently. The buildInitialCopilotMessage method combines the author's request with the context needed to create the card. The buildListDataStructure method prepares the field information.

As illustrated in the slides, the prompt-building code describes the configured fields through information such as FieldName, Datatype, and Label. This gives Copilot a concrete description of the data available for the layout.

The prompt also asks for a JSON response containing two properties:

  • Layout: The proposed Adaptive Card layout.
  • Description: An explanation of the proposed design or changes.

Requesting a consistent response structure makes it easier for the application to extract the layout and display the accompanying explanation. A prompt alone cannot guarantee valid output, so parsing and validation remain necessary. The implementation shown in the slides parses and validates the returned card JSON before applying it to the template property.

The implementation behind the card

The solution is a custom SharePoint Framework web part. Its data-loading flow starts with the property pane configuration: source site, target list, selected item IDs, and field definitions.

The technical slides identify fetchListColumns() and fetchListItems() in src/core/sp.service.ts. These methods use SharePoint REST through SPHttpClient to retrieve column metadata and the selected records. The data-access layer shown does not use PnPjs.

The web part merges current column type information into its stored field configuration. The ListDataAsCard.tsx component then passes the items to the selected layout implementation.

For Adaptive Card output, the slides show AdaptiveCardHost from @pnp/spfx-controls-react. The implementation substitutes field placeholders in the template with the corresponding item values.

The AI-generated layout is saved in adaptiveCardTemplate, the same property used by the manual JSON editor. This keeps the rendering path consistent regardless of how the author creates the design.

Connecting the assistant to Microsoft 365 Copilot

The CopilotCardDesigner component uses the sendCopilotChatMessage service method to communicate with Microsoft 365 Copilot through Microsoft Graph. The integration uses the Copilot Chat API.

The API creates a conversation through the following endpoint:

POST https://graph.microsoft.com/beta/copilot/conversations

The returned conversation ID identifies the thread. Subsequent synchronous messages use:

POST https://graph.microsoft.com/beta/copilot/conversations/{conversationId}/chat

Keeping the conversation ID allows authors to refine the current design over several messages. They can ask for a more compact layout or a different arrangement without restarting the design process.

The slides also describe localized chat text in English and German, together with a readable error message for a licensing-related access failure. These details help make the assistant usable within the page-authoring experience.

Preview status and solution availability

The Copilot Chat API used by this integration is documented as a preview API under Microsoft Graph /beta. Microsoft states that beta APIs can change and are not supported for production applications.

At the time of the presentation, the Marketplace version of my solution did not include AI support. I explained that the AI version used the beta endpoint and announced plans to publish it to the PnP app gallery. These statements describe the status and plans at presentation time, rather than confirming a later release.

For implementation details and current API requirements, consult the Microsoft documentation linked below.

Less repeated maintenance, more control for page authors

The Flexible Data Card Designer combines centralized SharePoint data with configurable presentation on individual pages. Authors can select the records they need, choose the relevant fields, and reuse their settings elsewhere.

Adding Copilot reduces the effort involved in preparing a custom Adaptive Card layout. Authors can start with a description of the result they want, refine the proposal through conversation, and edit the JSON directly when necessary.

Watch the accompanying presentation to see the configuration and AI design experience in context, including how the web part prepares list metadata and applies the generated layout.

Kommentare

Beliebte Posts aus diesem Blog

SPFx: Be prepared for the Content Security Policy (CSP) in SharePoint Online

Power Automate: Abrufen von SharePoint Listenelementen mit ODATA-Filter

SharePoint Online: Optimale Bildgrößen für Seiten (Teil 1)