The AI Knowledge Portability Problem – Part 4: Getting My Copilot Conversations Out with Microsoft Graph

This entry is part 4 of 5 in the series The AI Knowledge Portability Problem

In Part 3, I described how Copilot could find my old conversations and give me links to them, but couldn’t reliably retrieve their complete contents. Microsoft Graph seemed to offer another way to get at that history, so I decided to see what I could actually recover.

A Note About How I’m Doing This

I’ve been using Copilot extensively throughout this project, both to help write the PowerShell scripts and to draft and edit these blog posts. GitHub Copilot has also been helping me review and improve the code. When I say “we” in this series, I mean Copilot and me.

I’m directing the work, testing the results, questioning the assumptions, and making the decisions about what stays and what changes. As you’ve probably gathered from this series, that doesn’t mean Copilot always gets things right. In fact, some of the more interesting discoveries have come from challenging its answers and figuring out where it led me astray.

Getting the Data Out

Microsoft provides an API called getAllEnterpriseInteractions, which lets authorized applications retrieve Copilot interaction records. It’s not something most people will casually use. You need an Entra application registration, appropriate Graph permissions, administrator consent, and a way to authenticate.

Fortunately, I’m comfortable with PnP.PowerShell, so I decided to use that rather than introduce another tool. I registered an application, configured certificate authentication, and started building a script to retrieve the interaction records for my account.

The API returns results in pages, so the script needed to keep requesting pages until there were no more. I also wanted to preserve the original JSON rather than immediately turn everything into summaries. If I was going to create an archive, I wanted to keep the underlying evidence.

My first complete export returned 28,644 interaction records across 1,360 sessions. I ran it again the next day and got:

  • 29,142 interaction records
  • 1,378 conversation sessions
  • 306 pages of results

That’s a lot of accumulated history, going back to January 19, 2024. It’s also considerably more than Copilot’s conversation search had been able to find.

Are the Records Actually Stable?

Having two exports gave me an opportunity to compare them. I wanted to know whether the second export contained everything from the first, whether records had disappeared, and whether previously stored conversations had changed.

The initial comparison was encouraging. All 28,644 original interaction IDs were still present, and the newer export contained 498 additional records.

But there was a surprise. Nearly 8,000 existing records appeared to have changed. That seemed like a problem for an archive. If historical conversations change between exports, how do I know which version to preserve?

We dug into one of the changed records and discovered that the actual conversation text was identical. What had changed was an internal attachment identifier. Since some Copilot responses are stored as attachments, that identifier also appeared in the message body.

We adjusted the comparison to account for those identifiers and ran it again. All 7,969 apparent changes were attributable to attachment identifiers, with no changes to the underlying message content detected by our comparison.

That doesn’t prove every future export will behave the same way, but it gives me some confidence that the records are stable enough to build an archive around.

Turning Records into Conversations

Getting the JSON was only the beginning. I still needed to turn those interaction records into something readable.

Microsoft Graph returns user prompts, Copilot responses, timestamps, session identifiers, and other information. But the response content isn’t always ordinary text. Some answers are stored in Adaptive Cards, which are structured JSON objects containing the information Copilot displayed.

We discovered this while examining my conversation about subscribing to The Exonian. Graph returned my original question and an intermediate “Searching…” response, but the actual answer was inside an Adaptive Card attachment. Once we looked there, we recovered the answer.

There were other complications. Some records contained internal processing activity rather than messages I’d actually seen. And a single session could contain conversations about unrelated subjects, sometimes separated by days. That meant we couldn’t simply group records by session ID and assume we’d reconstructed a coherent conversation.

We went through several iterations of the reconstruction script, improving how it extracted readable text and distinguished substantive messages from internal activity. At one point, I stopped us to ask whether we were heading down another rabbit hole 🐰. We were spending a lot of time perfecting Markdown files without being entirely clear about how I’d use them.

The answer was to remember the original goal. The Markdown files are evidence for the knowledge I want to move, not an end in themselves.

Making the Knowledge Portable

We eventually settled on a workflow that made sense to me.

First, export the available Graph interactions and reconstruct readable conversation evidence. Then use our Portable Topic Knowledge skill to find information about a particular topic, create a concise knowledge document, and package that document with the supporting conversations.

The resulting ZIP contains both the accumulated knowledge and the original evidence behind it.

I tested this with three topics of increasing complexity.

The Exonian was a small test, essentially one substantive exchange. Brownell Library was more complicated, with 14 reconstructed conversation files covering website administration, accessibility, board governance, and meeting minutes.

The third test was my personal health history, which produced 18 conversation-evidence files. Those conversations also tended to be much longer, with more variation in their contents. That required additional privacy checks to make sure I wasn’t inadvertently transferring client or other third-party medical information.

I copied the approved archives into my personal Microsoft 365 tenant and extracted the Markdown files into OneDrive. Then I asked Copilot questions about the imported knowledge, without attaching the files.

It found them, answered appropriately, and cited the original conversation evidence. With Brownell Library, for example, it recovered corrections we’d made to board minutes and distinguished actual Board decisions from things we’d merely discussed.

That’s exactly the kind of context I wanted to preserve.

One Script Instead of Several

Along the way, we’d accumulated multiple PowerShell scripts for exporting, comparing, reconstructing, and validating the data. That wasn’t going to be particularly useful to someone trying this for themselves.

So, we consolidated the process into a single, well-commented PowerShell 7 script. Someone with the necessary Graph permissions can run it, provide their tenant and authentication information, choose an export location, and get both the original JSON and readable Markdown conversations.

The script is now available on Github, along with installation instructions and a test script. It isn’t simple, and I spent considerable time working with GitHub Copilot to make it as secure and reliable as I reasonably could, given the sensitive information it could be handling.

What the Script Does

Once the necessary Microsoft Graph permissions are configured, the script handles the process:

  1. Prompts for configuration: Tenant, application ID, certificate, user, and export destination.
  2. Connects to Microsoft Graph using PnP.PowerShell.
  3. Exports available Copilot interactions, handling pagination and interrupted downloads.
  4. Preserves the original JSON as the authoritative evidence.
  5. Consolidates and validates interaction records, including duplicate detection.
  6. Reconstructs readable Markdown conversations, including supported Adaptive Card responses.
  7. Generates indexes and reports documenting the results.

It can also process previously downloaded Graph JSON files without calling Graph again.

What the User Receives

FolderContents
RawOriginal JSON responses from Microsoft Graph, saved in numbered batches.
ConsolidatedA single CopilotInteractions.json file containing the interaction records.
ConversationsIndividual Markdown files containing reconstructed conversations, organized by session.
ReportsCSV indexes, export statistics, duplicate information, and download state.

The original Graph records remain available for reference, while the Markdown files provide readable conversation evidence that can be used with the Portable Topic Knowledge skill.

The script doesn’t automatically transfer anything between tenants. That’s a separate step, and one where it’s important to review what you’re moving, especially if your conversations contain client or organizational information.

Getting the Script Ready for Others

I also used GitHub Copilot in VS Code to review and improve the script. It identified some genuine problems, including the fact that our original export code was parsing and reserializing JSON rather than preserving the response as returned by Graph.

We corrected that, improved duplicate handling and resumability, and added checks to prevent an export from accidentally mixing records from different users or tenants. We also tightened the handling of pagination URLs and interrupted file writes.

One particularly useful improvement was reducing memory consumption. On a synthetic 30,000-record dataset, peak memory dropped from 605 MB to about 131 MB, without increasing the runtime significantly.

That’s a good example of where GitHub Copilot contributed something beyond simply generating code. It helped identify a performance problem, propose a better approach, implement it, and test the results.

The automated tests passed, including a larger-scale performance test. We also ran the finished script against Microsoft Graph, successfully retrieving two pages, and then processed the complete December 1 export of 29,142 records into 1,378 Markdown session files.

I’m comfortable making the script available for others to try, but I wouldn’t claim that every possible Copilot response format is handled perfectly. The raw JSON is preserved precisely because the reconstruction may improve over time.

The GitHub repository includes the script, tests, setup instructions, and known limitations. Issues and pull requests are welcome.

Where This Leaves Me

I now have a practical way to recover considerably more of my Copilot conversation history than Copilot’s own conversation search provides. I can organize that information by topic, preserve the supporting evidence, and move the resulting knowledge into another tenant.

It’s not perfect. The reconstructed conversations aren’t guaranteed to contain every original message, and importing them doesn’t recreate native Copilot chat history. They become documents that Copilot can find and use.

That’s a meaningful improvement over where I started. I’ve now transferred several topics, including some fairly substantial ones, and I have a repeatable process for continuing to move my personal knowledge out of my work tenant.

The process still requires more technical work than I think it should, particularly for someone without administrative access. But at least I have a way forward that doesn’t involve manually opening hundreds of conversations.

In the final part of this series, I want to step back from the scripts and skills and look at the larger issue. We’re accumulating more and more knowledge through AI assistants, but we still have remarkably little control over how that knowledge is preserved, organized, and moved between platforms.

I think that needs to change.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.