The following is a custom copilot that uses the Azure OpenAI Chat Completions API Azure OpenAI On Your Data feature to facilitate RAG (retrieval augmented generation). You can chat with your data in Azure AI Search, Azure Blob Storage, URL/web address, Azure Cosmos DB for MongoDB vCore, uploaded files, and Elasticsearch.
- Azure OpenAI On Your Data
You can deploy to a standalone Teams app (preview) directly from Azure OpenAI Studio, enabling you to bring conversational experience to your users in Teams to improve operational efficiency and democratize access of information. This Teams app is configured to users within a single tenant and personal chat (non-group chat) scenarios. See the Enable your Custom Copilot for Group Chats and Channels section to enable group chat scenarios noting that the AI response quality from Azure OpenAI On Your Data has not been fully tested for group chats.
This guide will show you have the set up your custom copilot for Teams using Azure OpenAI Studio and Teams Toolkit.
Install | For using... |
---|---|
Visual Studio Code | Typescript build environments. Use the latest version. |
Teams Toolkit (5.3.x or greater) | Microsoft Visual Studio Code extension that creates a project scaffolding for your app. Use the latest version. |
Node.js (16 or 18) | Back-end JavaScript runtime environment. Recommended to use Node Version 16.x or 18.x, Node version >=19 is not supported. For more information, see Node.js version compatibility table for project type |
Microsoft Teams | Access to a Microsoft Teams account with the appropriate permissions to install an app, enable custom Teams apps, and turn on custom app uploading. |
Azure OpenAI | Deploy Azure OpenAI large language models and test your custom copilot ideas in the Azure OpenAI Studio Playground. If you want to host your app or access resources in Microsoft Azure, you must create an Azure OpenAI service. |
Azure CLI | The Azure Command-Line Interface (CLI) is a cross-platform command-line tool to connect to Azure and execute administrative commands on Azure resources. For more information on setting up environment variables, see the Azure SDK documentation. |
Cognitive Services OpenAI User Role | Your Azure account has been assigned “Cognitive Services OpenAI user” or “Cognitive Services OpenAI Contributor” role of the Azure OpenAI resource you are using allowing your account to make Azure OpenAI API calls. For more information see Using your data with Azure OpenAI securely and Add role assignment to an Azure OpenAI resource for instructions on setting this role in the Azure portal. |
-
Follow the use your data quickstart instructions to add your data using Azure OpenAI Studio chat playground.
-
After adding your data, click
Deploy to
and thenA new Teams app(preview)
. -
Enter the name of your Teams app.
-
Click
download
to download your Teams app as a zip file. -
Open the location of where you downloaded the zip file and extract the zip file.
Note: Testing this sample requires that you are logged into Azure CLI and you have Cognitive Services OpenAI User role assigned to you per the prerequisites.
-
Go to Visual Studio Code.
-
Select
File > Open Folder
. -
Go to the location where you extracted your Teams app folder and select it.
-
If you chose
API key
in data connection, manually copy and paste your Azure AI Search key insrc\prompts\chat\config.json
file. Your Azure AI Search Key can be found in Azure OpenAI Studio Playground by clicking theView code
button and looking under Azure Search Resource Key. If you chosesystem assigned managed identity
, you can skip this step. Learn more about different data connection options in the Data connection section . -
Open the Visual Studio terminal by selecting
View > Terminal
and log into Azure CLI selecting the Azure account that you assigned Cognitive Service OpenAI User role to. Use the following command to log in:az login
-
To debug your app, press the
F5
key or from the left pane, selectRUN AND DEBUG ▷
(Ctrl+Shift+D) and then selectDebug in (Test tool)
from the dropdown list. SelectRun > Start Debugging
(F5). The Test Tool opens in a webpage where you can chat with your custom copilot.
After you've tested your copilot, you can provision, deploy, and publish your Teams app by selecting the Teams Toolkit Extension on the left pane in Visual Studio. Run the separate provision, deploy, and publish stages in Lifecycle section. You may be asked to sign into your Microsoft 365 account where you have permissions to upload custom apps and your Azure Account.
IMPORTANT As this sample uses managed identity, for your custom copilot to generate responses you must assign Cognitive Service OpenAI User role to your custom copilot’s App Service resource group after deploying your app to Azure.
As this sample uses managed identity, you must enable assign Cognitive Service OpenAI User role to your custom copilot’s App Service resource group after deploying your app to Azure in order for your deployed custom copilot to receive responses from Azure OpenAI.
-
Go to Azure portal and select resource groups
-
Select the resource group you deployed your custom copilot to
-
Select the
App Service
resource -
Go to
settings > identity
and enable system assigned identity by selectingOn
-
Select
Save
to enable system assigned identity. -
Click
Azure role assignments
-
Click
add role assignments
. -
Under Scope select
Resource group
-
Under Subscription select the Azure subscription of your Azure OpenAI resource
-
Under Resource group select your Azure OpenAI resource
-
Under Role select
Cognitive Service OpenAI user
-
Select
save
to finish assigning the role
Now, your published custom copilot Teams app is ready for use.
This custom copilot sample is pre-configured for only personal chats (1 on 1) during preview due to ongoing testing from Azure OpenAI On Your Data to determine the effects of group chats on AI response quality. Group chats can be enabled with the understanding that the AI response quality has not been fully tested for these scenarios.
A custom copilot can be mentioned ("@customcopilotname") in a channel if it has been added to the team. Note that additional replies to a custom copilot in a channel require @ mentioning the custom copilot. It will not respond to replies where it isn't mentioned. See here for more information.
To enable group chats:
-
Go to appPackage\manifest.json file
-
Add the team and groupchat parameters to your bots' scopes in additional to the existing personal scope.
"bots": [ { "botId": "${{BOT_ID}}", "scopes": [ "personal", "team", "groupchat" ],
You can modify the settings in the Data parameters section in src\prompts\chat\config.json file.
The in_scope parameter configures the chatbot's approach to handling queries unrelated to the data source or when search documents are insufficient for a complete answer. When this setting is set to false
, the model supplements its responses with its own knowledge in addition to your documents.
By default, the in_scope parameter is set to true
resulting in the model attempting to only rely on your documents for responses. Out of scope questions may receive the following response:
“The requested information is not available in the retrieved data. Please try another query or topic.”
For more information please see Runtime parameters