Skip to content
Petkir Blog
XLinkedinBluesky

The Christkind's - Fine-Tuning the Graph Connector for Better Copilot Answers

Code, Copilot, M365, Xmas20244 min read

Story

The Christkind found itself marveling at the Graph Connector it had set up earlier. It worked wonderfully, seamlessly pulling content from the production wiki into Microsoft 365 and making it available for Copilot. Yet, one nagging issue persisted: the answers generated by Copilot were too long and often missed the key points the Christkind needed.

Initially, the Christkind thought this might just be a limitation of Copilot. However, upon closer inspection, the Christkind realized something crucial: the indexed wiki pages contained multiple headlines and followed a consistent structure. Each page detailed various aspects of a product, including an overview, parts list, assembly steps, and troubleshooting tips, but Copilot struggled to identify the most relevant sections for each query.

To address this, the Christkind enhanced the properties in the Graph Connector to reflect the structure of the wiki pages. By doing so, Copilot gained a better understanding of the context and was able to generate concise, targeted answers.

After these adjustments, the Christkind was delighted to see Copilot's answers improve dramatically. Queries were resolved faster, and users no longer had to sift through overly verbose responses.

This experience taught the Christkind that unlocking the full potential of AI often requires enhancing the underlying data. The enriched Graph Connector properties not only improved Copilot’s performance but also laid a solid foundation for future innovations.

Implementation of the Graph Connector

Wiki Structure

The Christkind noticed that the HTML of the wiki pages followed a consistent format, making it easy to categorize content based on headlines (<h1> and <h2> tags).

<h1>Wiki Document1</h1>
<p>Summary of the Document</p>
<h2>Parts</h2>
<p>
...
</p>
<h2>Preperation</h2>
<p>
...
</p>
<h2>Assembly</h2>
<p>
...
</p>
<h2>Packaging</h2>
<p>
...
</p>
<h2>Troubleshooting</h2>
<p>
...
</p>

Each section represented distinct content that could be mapped to a specific property in the Graph Connector schema.

Extend the Schema

To ensure better query results, the Christkind added custom properties to reflect the distinct sections of the wiki

var schema = new Schema
{
BaseType = "microsoft.graph.externalItem",
Properties = new List<Property>
{
new Property { Name = "name", Type = PropertyType.String, IsQueryable = true, IsSearchable = true, IsRetrievable = true, IsRefinable = false, Labels = new List<Label?>() { Label.Title }},
...
new Property { Name = "parts", Type = PropertyType.String, IsQueryable = false, IsSearchable = true, IsRetrievable = true, IsRefinable = false },
new Property { Name = "preperation", Type = PropertyType.String, IsQueryable = false, IsSearchable = true, IsRetrievable = true, IsRefinable = false },
new Property { Name = "assemblyInstructions", Type = PropertyType.String, IsQueryable = false, IsSearchable = true, IsRetrievable = true, IsRefinable = false },
...
},
};

Extend the External Item with the new Properties

To integrate these new properties, the Christkind updated the ExternalItem with additional metadata fields:

var extItem = new ExternalItem
{
Id = item.Key,
Content = new ExternalItemContent
{
Type = ExternalItemContentType.Text,
Value = item.Body
},
Properties = new Properties
{
AdditionalData = new Dictionary<string, object>
{
{ "name", item.TeaName },
{ "description", item.Summary },
{ "parts", item.Parts },
{ "preperation", item.Preperation },
{ "assemblyInstructions", item.Assembly },
...
}
},
Acl = new List<Acl>
{
new Acl
{
AccessType = AccessType.Grant,
Type = AclType.EveryoneExceptGuests,
Value = settings.TenantId,
}
},
Activities = new() {
new() {
OdataType = "#microsoft.graph.externalConnectors.externalActivity",
Type = ExternalActivityType.Created,
StartDateTime = item.CreatedDateTime,
PerformedBy = new Microsoft.Graph.Models.ExternalConnectors.Identity {
Type = IdentityType.User,
Id = "8695b810-2b67-4f3d-9922-8ce1a7775f27"
}
}
}
};

Remark

This small but impactful adjustment significantly improved the usability of the Graph Connector for the Christkind’s team. It highlighted the importance of understanding the end user’s questions and tailoring the data accordingly.

Links

XMAS 2024 Overview