This is a conversational bot for Microsoft Teams that thinks it's a Chef to help you cook apps using the Teams AI Library. The bot uses the gpt-4o model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.
This sample illustrates how to use Retrieval Augmented Generation (RAG) to easily inject contextual relevant information into the prompt sent to the model. This results in better and more accurate replies from the bot.
The sample uses a local Vector Database, called Vectra, and Semantic Search to find the most relevant information to include in the prompt for the users input. The index can be found in ./index/teams-ai and includes all of the projects Getting Started docs and the source code for the Teams AI Library. This means you can ask the Teams Chef Bot anything about the library and it can answer it. You can even ask it to write sample code for you!
- Clone the repository
git clone https://github.com/Microsoft/teams-ai.gitImportant
To prevent issues when installing dependencies after cloning the repo, copy or move the sample directory to it's own location first. If you opened this sample from the Sample Gallery in Teams Toolkit, you can skip to step 2.
cd path/to/04.ai-apps/a.teamsChefBot
code .- Add your OpenAI key to the
SECRET_OPENAI_KEYvariable in the./env/.env.local.userfile and comment out lines 90-93 in./src/index.tsfile.
If you are using Azure OpenAI then follow these steps:
- Comment the
SECRET_OPENAI_KEYvariable in the./env/.env.local.userfile. - Add your Azure OpenAI key and endpoint values to the
SECRET_AZURE_OPENAI_KEYandSECRET_AZURE_OPENAI_ENDPOINTvariables. - Open the
teamsapp.local.ymlfile and modify the last step to use Azure OpenAI variables instead:
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./.env
envs:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
#OPENAI_KEY: ${{SECRET_OPENAI_KEY}}
AZURE_OPENAI_KEY: ${{SECRET_AZURE_OPENAI_KEY}}
AZURE_OPENAI_ENDPOINT: ${{SECRET_AZURE_OPENAI_ENDPOINT}}- Open
./infra/azure.bicepand comment out lines of 'OPENAI_KEY' section and uncomment lines of 'AZURE_OPENAI_KEY' and 'AZURE_OPENAI_ENDPOINT' sections. - Open
./infra/azure.parameters.jsonand replace lines of "openAIKey" section with:
"azureOpenAIKey": {
"value": "${{SECRET_AZURE_OPENAI_KEY}}"
},
"azureOpenAIEndpoint": {
"value": "${{SECRET_AZURE_OPENAI_ENDPOINT}}"
}Please note: If you are using Azure OpenAI, you will need both a GPT model and embedding model deployment to get this sample working. See
OpenAIModelinindex.tsandOpenAIEmbeddingsinVectraDataSource.ts.
- Update
./src/prompts/chat/config.jsonand./src/index.tswith your model deployment name.
The easiest and fastest way to get up and running is with Teams Toolkit as your development guide. To use Teams Toolkit to automate setup and debugging, please continue below.
Otherwise, if you only want to run the bot locally and build manually, please jump to the BotFramework Emulator section. For different ways to test a sample see: Multiple ways to test
The simplest way to run this sample in Teams is to use Teams Toolkit for Visual Studio Code.
- Ensure you have downloaded and installed Visual Studio Code
- Install the Teams Toolkit extension
- Copy this sample into a new folder outside of teams-ai
- Select File > Open Folder in VS Code and choose this sample's directory
- Using the extension, sign in with your Microsoft 365 account where you have permissions to upload custom apps
- Verify that the Teams Toolkit extension is connected to your Teams account from the above step.
- Select Debug > Start Debugging or F5 to run the app in a Teams web client.
- In the browser that launches, select the Add button to install the app to Teams.
If you do not have permission to upload custom apps (sideloading), Teams Toolkit will recommend creating and using a Microsoft 365 Developer Program account - a free program to get your own dev environment sandbox that includes Teams.
If you are using Azure OpenAI then follow these steps:
- Comment the
SECRET_OPENAI_KEYvariable in the./env/.env.testtoolfile. - Add your Azure OpenAI key and endpoint values to the
SECRET_AZURE_OPENAI_KEYandSECRET_AZURE_OPENAI_ENDPOINTvariables - Open the
teamsapp.testtool.ymlfile and modify the last step to use Azure OpenAI variables instead:
- uses: file/createOrUpdateEnvironmentFile
with:
target: ./.localConfigs.testTool
envs:
TEAMSFX_NOTIFICATION_STORE_FILENAME: ${{TEAMSFX_NOTIFICATION_STORE_FILENAME}}
# OPENAI_KEY: ${{SECRET_OPENAI_KEY}}
AZURE_OPENAI_KEY: ${{SECRET_AZURE_OPENAI_KEY}}
AZURE_OPENAI_ENDPOINT: ${{SECRET_AZURE_OPENAI_ENDPOINT}}- Ensure you have downloaded and installed Visual Studio Code
- Install the Teams Toolkit extension
- Copy this sample into a new folder outside of teams-ai
- Select File > Open Folder in VS Code and choose this sample's directory
- From the left pane, select Run and Debug(Ctrl+Shift+D) and select Debug in Test Tool in dropdown list.
- Select Debug > Start Debugging or F5 to run the app.
- The browser will pop up to open Teams App Test Tool.
