Skip to content

Latest commit

 

History

History

README.md

Azure Open API Agent using TypeSpec for Microsoft 365 Copilot

Summary

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.

Get started with the template

Prerequisites

To run this app template in your local dev machine, you will need:

Minimal path to awesome

  1. Clone this repository or download this solution as a .ZIP file then unzip it.

  2. 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
  3. 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.

  1. Rename the .env.dev.example file to .env.dev and 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}
```
  1. Update the instructions and agent details within the main.tsp as appropriate for your use case.

  2. Update SERVER_URL, MODEL and other hard coded parameters in actions.tsp

  3. From Teams Toolkit, sign-in to your Microsoft 365 account.

  4. From Teams Toolkit, provision the solution to create the Teams app.

  5. Go to https://www.office.com/chat?auth=2 URL and enable the developer mode by using the -developer on prompt.

  6. Use one of the conversation starters to start the agent.

solution

What's included in the template

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.

Extend the template

Help

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.

Addition information and references

Disclaimer

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.