With the declarative agent, you can build a custom version of Copilot that can be used for specific scenarios, such as for specialized knowledge, implementing specific processes, or simply to save time by reusing a set of AI prompts. For example, a grocery shopping Copilot declarative agent can be used to create a grocery list based on a meal plan that you send to Copilot.
You can extend declarative agents using plugins to retrieve data and execute tasks on external systems. A declarative agent can utilize multiple plugins at the same time.
Prerequisites
To run this app template in your local dev machine, you will need:
- Node.js, supported versions: 18, 20, 22
- A Microsoft 365 account for development.
- Teams Toolkit Visual Studio Code Extension version 5.0.0 and higher or Teams Toolkit CLI
- Microsoft 365 Copilot license
- [Azure AI Services]
-
Clone this repository (or download this solution as a .ZIP file then unzip it)
-
Get a copy your Endpoint URL and KEY from the Azure OpenAI resource:
- Go to Azure portal
- Find or create your instance under Azure OpenAI resource
- Create a deployment, e.g 'gpt-4o'
- Under Overview, copy the Azure OpenAI endpoint value. It should look like
https://<your-azure-openai-service>.openai.azure.com// - Under Keys and Endpoint, copy the KEY 1 value
-
In the Teams developer portal under Tools, create a new API Key registration with the following information:
- API key: Add a secret with the Azure OpenAI Key you copied in step 2
- API key name: e.g., Azure OpenAI Key Name
- Base URL: The Azure OpenAI Endpoint URL you copied in step 2
- Target tenant: Home tenant
- Restrict usage by app: Any Teams app (when agent is deployed, use the Teams app ID)
Save the information. A new API key registration ID will be generated. Copy the key.
- Rename the
.env.dev.examplefile to.env.devand update the following values:
Replace {keyAPIRegistration} with the key copied in previous step
```bash
# Built-in environment variables
TEAMSFX_ENV=dev
APP_NAME_SUFFIX=dev
# Generated during provision, you can also add your own variables.
TEAMS_APP_ID=
TEAMS_APP_TENANT_ID=
M365_TITLE_ID=
M365_APP_ID=
# Update own variables.
APIKEYAUTH_REGISTRATION_ID={keyAPIRegistration}
MODEL=gpt-4o
API_VERSION=2025-01-01-preview
TEMPERATURE=0.7
MAX_TOKENS=800
TOP_P=0.95
FREQUENCY_PENALTY=0
PRESENCE_PENALTY=0
```
- Update the instruction.txt as appropriate for your use case.
- Update OpenAI Spec Server API URL in
appPackage\apiSpecificationFile\openapi.yaml
To ensure the OpenAPI specification correctly references your Azure OpenAI resource, update the server URL in the OpenAPI spec. This step is crucial for aligning the API calls with your deployed model and endpoint configuration.
Replace the placeholder server URL with the actual endpoint URL of your Azure OpenAI resource. For example:
servers:
- url: https://<your-resource-name>.openai.azure.com
description: Azure OpenAI service endpoint- From Teams Toolkit, sign-in to your Microsoft 365 account.
- From Teams Toolkit, provision the solution to create the Teams app.
- Go to https://www.office.com/chat?auth=2 URL and enable the developer mode by using the
-developer onprompt. - Use one of the conversation starters to start the agent.
| Folder | Contents |
|---|---|
.vscode |
VSCode files for debugging |
appPackage |
Templates for the Teams application manifest, the plugin manifest and the API specification |
env |
Environment files |
The following files can be customized and demonstrate an example implementation to get you started.
| File | Contents |
|---|---|
appPackage/declarativeCopilot.json |
Define the behaviour and configurations of the declarative agent. |
appPackage/manifest.json |
Teams application manifest that defines metadata for your declarative agent. |
The following are Teams Toolkit specific project files. You can visit a complete guide on Github to understand how Teams Toolkit works.
| File | Contents |
|---|---|
teamsapp.yml |
This is the main Teams Toolkit project file. The project file defines two primary things: Properties and configuration Stage definitions. |
