> ## Content Index
> Fetch the complete content index at: https://blog.bajonczak.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Adding YOUR Data to M365 declarative Copilot Agent
- URL: https://blog.bajonczak.com/adding-your-data-to-m365-declarative-copilot-agent/
- Published: 2024-09-27T13:48:48.000Z
- Updated: 2024-10-06T10:29:04.000Z
- Description: 🚀 Exciting news! Copilot Wave 2 is here! 🎉 Featuring Copilot Pages, Python in Excel 🐍, and the Declarative Copilot. I'll share a blog post on integrating custom data without pro-code plugins! 💡 #Copilot #AI #Python #NoCode #Tech #Automation #Excel #TeamsToolkit #PowerPlatform #DataIntegration
- Author: Sascha Bajonczak
- Tags: Microsoft 365, Microsoft Copilot, AI

Yep, Copilot Wave 2 was already announced. The main takeaways are Copilot Pages, Python in Excel with scripts generated from Copilot, and, yes, declarative Copilot. 

I will create a blog post about these new fancy features soon. For now, I will concentrate on the declarative copilot and how to add your custom data. 

In my [post](https://blog.bajonczak.com/how-to-integrate-your-sap-hcm-data-into-you-ai-model-part-2/) on integrating custom data into Copilot, I must create a plugin with pro-code, but I can assure you that this is no longer necessary for simple solutions. Before we start, we need something done before we can dive into creating a declarative Copilot.

# Prerequisites

First of all, the declarative copilot is in private preview. So, you must execute some PowerShell commands to enable the preview. 

```PowerShell
[Environment]::SetEnvironmentVariable("TEAMSFX_DECLARATIVE_COPILOT", 'true', "User")
[Environment]::SetEnvironmentVariable("KIOTA_CONFIG_PREVIEW", "true", "User")
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
```

Now, after that, you must install the required node package that will enable the teamsapp cli.

```Shell
npm install -g @microsoft/teamsapp-cli
npx teamsapp -h
```

Then, you must install the [Teams toolkit](https://marketplace.visualstudio.com/items?itemName=TeamsDevApp.ms-teams-vscode-extension&ref=blog.bajonczak.com) extension using Visual Studio code. Please pay attention to installing the preview version.   
Finally you must install the kiota runtimes with 

```
dotnet tool install --global Microsoft.OpenApi.Kiota
```

Now you are ready to go! Let's create the declarative copilot.

# Creating a declarative copilot

You can use the wizard to create a starting point for the scaffolded template. 

0:00 

/0:22 

1× 

Creating a declarative copilot

After that, you have the stater template loaded into the Visual Studio Code. In the folder appPackage you will see the file declarativeAgent.json with the following content:

```JSON
{
    "$schema": "https://aka.ms/json-schemas/copilot/declarative-agent/v1.0/schema.json",
    "version": "v1.0",
    "name": "MyTestDeclarativeCopilot",
    "description": "Declarative agent created with Teams Toolkit",
    "instructions": "$[file('instruction.txt')]",
}
```

Now, you will be able to create the following: 

- Conversation starters
- Add external "static" data
- Add Graph Connectors
- Add a custom plugin

I will focus only on adding the custom plugin  
First, some points on to deploy these declarative copilots:

# Deployment

I deploy the definition with the Teams Toolkit (Prerelease version). The only step is to provision the copilot within your tenant.

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2024/09/image-11.png)

After that, you can open the [copilot chat](https://www.microsoft365.com/chat?ref=blog.bajonczak.com). You will see the chat drawer next to the "New Chat" button. There will be places where our extension.

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2024/09/image-10.png)

From here, you can select YOUR Copilot and work with it. Now, let's dive deep into adding your custom data as a data source.

### Adding custom data

You must provide an open API definition to attach your data via a plugin. To keep it simple, I used the demo instance from Microsoft: [https://aka.ms/repairshub/openapi.json](https://aka.ms/repairshub/openapi.json?ref=blog.bajonczak.com) . In this definition you will a definition to get information of repairs. To use this definition, you can use the installed tool kiota.

```
kiota plugin add --openapi https://aka.ms/repairshub/openapi.json --plugin-name "RepairsHub" --type apiplugin --output appPackage
```

This will produce the following output

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2024/09/image-13.png)

Output when adding pluing with kiota tool

You will notice two new files within the project folder. 

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2024/09/image-14.png)

4

The JSON is the downloaded copy of the server, and the "yml" File contains the YAML translated representation.

The final step is to add an action into the declarativeAgent.json - File to enable the endpoint as a datasource. The modified one looks like this:

```JSON
{
    "$schema": "https://aka.ms/json-schemas/copilot/declarative-agent/v1.0/schema.json",
    "version": "v1.0",
    "name": "Teams Toolkit declarative copilot",
    "description": "Teams Toolkit declarative copilot",
    "instructions": "$[file('instruction.txt')]",
    "actions":[
        {
            "id": "repairsPlugin",
            "file": "repairshub-apiplugin.json"
        }
    ]
}
```

Modified JSON with custom plugin

Now, you can deploy and test the agent within the Chat Promt. I will try to get all reports from the endpoint. After a little bit of gathering time, you will be prompted with the results.

![](https://pub-3d6b5be904ac42e19eb06b614618c42e.r2.dev/images/2024/09/image-15.png)

Done! That was quick! 

#