Teams AI library quick start guide
Get started with Teams AI library using the Chef bot sample, which is designed to to help you cook apps using the Teams AI Library. The bot uses the gpt-3.5-turbo model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.
Prerequisites
To get started, ensure that you have the following tools:
Install | For using... |
---|---|
Visual Studio Code or Visual Studio | JavaScript, TypeScript, or CSharp build environments. Use the latest version. |
Teams Toolkit | Microsoft Visual Studio Code extension that creates a project scaffolding for your app. Use the latest version. |
Git | Git is a version control system that helps you manage different versions of code within a repository. |
Node.js | Back-end JavaScript runtime environment. For more information, see Node.js version compatibility table for project type. |
Microsoft Teams | Microsoft Teams to collaborate with everyone you work with through apps for chat, meetings, and call-all in one place. |
OpenAI or Azure OpenAI | First create your OpenAI API key to use OpenAI's GPT. If you want to host your app or access resources in Azure, you must create an Azure OpenAI service. |
Microsoft Edge (recommended) or Google Chrome | A browser with developer tools. |
Microsoft 365 developer account | Access to Teams account with the appropriate permissions to install an app and enable custom Teams apps and turn on custom app uploading. |
If you ran the samples before or encounter a runtime error, follow these steps to start fresh:
- Check all the
.env
andenv/.env.*.*
files in the sample and delete any automatically populated values to ensure that Teams Toolkit generates new resources for you. - If you don’t want Teams Toolkit to generate the appId and password, update the
MicrosoftAppId
andMicrosoftAppPassword
in the.env
file with your own values. - Remove values or leave the values blank for SECRET_BOT_PASSWORD and TEAMS_APP_UPDATE_TIME in the
.env
file to avoid conflicts.
Teams Toolkit automatically provisionsMicrosoftAppId
and MicrosoftAppPassword
resources. If you want to use your own resources, you need to manually add them to the .env
file. Teams Toolkit doesn't auto-generate the following resources:
- An Azure OpenAI or OpenAI key
- A database or similar storage options
Build and run the sample app
Get started with Teams AI library using the ChefBot sample. It enables your computer’s localhost to quickly execute a Teams AI library-based sample.
Go to the sample.
Run the following command to clone the repository.
git clone https://github.com/microsoft/teams-ai.git
Go to Visual Studio Code.
Select File > Open Folder.
Go to the location where you cloned teams-ai repo and select the teams-ai folder.
Select Select Folder.
Select View > Terminal. A terminal window opens.
In the terminal window, run the following command to go to the JS folder:
cd .\js\
Run the following command to install dependencies:
yarn install
Run the following command to build dependencies:
yarn build
After the dependencies are installed, select File > Open Folder.
Go to teams-ai > js > samples> 04.ai.a.teamsChefBot and select Select Folder. All the files for the chef bot sample are listed under the EXPLORER section in Visual Studio Code.
Under EXPLORER, duplicate the
sample.env
file and update the duplicate file to.env
.In the sample folder, update the following code in the
.env
configuration file:OPENAI_KEY=<your OpenAI key>
From the left pane, select Teams Toolkit.
Under ACCOUNTS, sign in to the following:
- Microsoft 365 account
- Azure account
To debug your app, select the F5 key.
A browser tab opens a Teams web client requesting to add the bot to your tenant.
Select Add.
A chat window opens.
In the message compose area, send a message to invoke the bot.
The bot uses the GPT turbo 3.5 model to chat with Teams users and respond in a polite and respectful manner, staying within the scope of the conversation.
Note
If you're building a bot for the first time, it's recommended to use Teams Toolkit extension for Visual Studio code to build a bot, see Build your first bot app using JavaScript.
Build and run the sample app
Go to the sample.
Clone the repository to test the sample app.
git clone https://github.com/microsoft/teams-ai.git
Go to the dotnet folder.
cd teams-ai/dotnet
Go to the folder where you cloned the repository and select 04.ai.a.teamsChefBot.
Select TeamsChefBot.sln. The solution opens in Visual Studio.
In Visual Studio, update your OpenAI related settings in the
appsettings.Development.json
file."OpenAI": { "ApiKey": "<your-openai-api-key>" },
In the debug dropdown menu, select Dev Tunnels > Create a Tunnel...
Select the Account to use to create the tunnel. Azure, Microsoft Account (MSA), and GitHub are the account types that are supported. Update the following options:
- Name: Enter a name for the tunnel.
- Tunnel Type: Select Persistent or Temporary.
- Access: Select Public.
- Select OK. Visual Studio displays a confirmation message that a tunnel is created.
The tunnel you created is listed under Dev Tunnels > (name of the tunnel).
Go to Solution Explorer and select your project.
Right-click the menu and select Teams Toolkit > Prepare Teams App Dependencies.
If prompted, sign in to your Microsoft 365 account. You'll receive a message that Teams app is successfully prepared.
Select OK.
Select F5 or select Debug > Start.
Select Add. The app is added to Teams and a chat window opens.
In the message compose area, send a message to invoke the bot.
You can also deploy the samples to Azure using Teams Toolkit. To deploy, follow these steps:
- In Visual Studio, go to Solution Explorer and select your project.
- Right-click the menu and select Teams Toolkit > Provision in the Cloud. Toolkit provisions your sample to Azure.
- Right-click the menu and select Teams Toolkit > Deploy to the Cloud.
Additional tools
You can also use the following tools to run and set up a sample:
Teams Toolkit CLI: You can use the Teams Toolkit CLI to create and manage Microsoft Teams apps from the command line. For more information, see Teams Toolkit CLI set up instructions.
Bot Framework Emulator: The Bot Framework Emulator is a desktop application that allows you to test and debug your bot locally. You can connect to your bot by entering the bot’s endpoint URL and Microsoft App ID and password. You can then send messages to your bot and see its responses in real-time. For more information, see Bot Framework Emulator set up instructions.
Manual setup: If you prefer to set up your resources manually, you can do so by following the instructions provided by the respective services. For more information, see manual set up instructions.
Next step
Platform Docs
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for