The sample is designed to demonstrate how to integrate Azure OpenAI services using TypeSpec. It provides a template for building conversational agents or plugins that leverage Azure OpenAI's capabilities, such as natural language processing and generative AI, within Microsoft Teams or other environments.
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.
- Microsoft 365 Agents Toolkit Visual Studio Code Extension version 5.0.0 and higher or Microsoft 365 Agents Toolkit CLI
- Microsoft 365 Copilot license
-
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}
```
-
Update the instructions and agent details within the
main.tspas appropriate for your use case. -
Update SERVER_URL, MODEL and other hard coded parameters in
actions.tsp -
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 application manifest, the GPT 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/manifest.json |
application manifest that defines metadata for your declarative agent. |
The following are Microsoft 365 Agents Toolkit specific project files. You can visit a complete guide on Github to understand how Microsoft 365 Agents Toolkit works.
| File | Contents |
|---|---|
m365agents.yml |
This is the main Microsoft 365 Agents Toolkit project file. The project file defines two primary things: Properties and configuration Stage definitions. |
The following are TypeSpec template files. You need to customize these files to configure your agent.
| File | Contents |
|---|---|
main.tsp |
This is the root file of TSP files. Please manually update this file to add your own agent. |
actions.tsp |
This is the actions file containing API endpoints to extend your declarative agent. |
- Add conversation starters: Conversation starters are hints that are displayed to the user to demonstrate how they can get started using the declarative agent.
- Add web content for the ability to search web information.
- Add OneDrive and SharePoint content as grounding knowledge for the agent.
- Add Microsoft Copilot Connectors content to ground agent with enterprise knowledge.
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
You can try looking at issues related to this sample to see if anybody else is having the same issues.
If you encounter any issues using this sample, create a new issue.
Finally, if you have an idea for improvement, make a suggestion.
THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
