This app template is built on top of Teams AI library and OpenAI Assistants API. It showcases how to build an intelligent chat bot in Teams capable of helping users accomplish a specific task using natural language right in the Teams conversations, such as solving a math problem.
Prerequisites
To run the AI Assistant Bot template in your local dev machine, you will need:
- Node.js, supported versions: 16, 18
- A Microsoft 365 account for development
- Teams Toolkit Visual Studio Code Extension version 5.0.0 and higher or Teams Toolkit CLI
- An account with OpenAI.
Note
Teams AI Library is currently in preview version.
Before running or debugging your bot, please follow these steps to setup your own OpenAI Assistant.
If you haven't setup any Assistant yet
This app template provides script
src/creator.ts
to help create assistant. You can change the instructions and settings in the script to customize the assistant.After creation, you can change and manage your assistants on OpenAI.
-
Open terminal and run command
npm install
to install all dependency packages> npm install
-
After
npm install
completed, run commandnpm run assistant:create -- <your-openai-api-key>
> npm run assistant:create -- xxxxxx
-
The above command will output something like "Created a new assistant with an ID of: asst_xxx..."
-
Fill in both OpenAI API Key and the created Assistant ID into
env/.env.*.user
SECRET_OPENAI_API_KEY=<your-openai-api-key> SECRET_OPENAI_ASSISTANT_ID=<your-openai-assistant-id>
If you already have an Assistant created
- Fill in both OpenAI API Key and the created Assistant ID into
env/.env.*.user
SECRET_OPENAI_API_KEY=<your-openai-api-key> SECRET_OPENAI_ASSISTANT_ID=<your-openai-assistant-id>
- First, select the Teams Toolkit icon on the left in the VS Code toolbar.
- In the Account section, sign in with your Microsoft 365 account if you haven't already.
- Press F5 to start debugging which launches your app in Teams using a web browser. Select
Debug (Edge)
orDebug (Chrome)
. - When Teams launches in the browser, select the Add button in the dialog to install your app to Teams.
- You will receive a welcome message from the bot, or send any message to get a response.
Congratulations! You are running an application that can now interact with users in Teams:
Folder | Contents |
---|---|
.vscode |
VSCode files for debugging |
appPackage |
Templates for the Teams application manifest |
env |
Environment files |
infra |
Templates for provisioning Azure resources |
src |
The source code for the application |
The following files can be customized and demonstrate an example implementation to get you started.
File | Contents |
---|---|
src/index.ts |
Sets up and configures the AI Chat Bot. |
src/app.ts |
Handles business logics for the AI Chat Bot. |
src/config.ts |
Defines the environment variables. |
src/creator.ts |
One-time tool to create OpenAI Assistant. |
The following are Teams Toolkit specific project files. You can visit a complete guide on Github to understand how Teams Toolkit works.
File | Contents |
---|---|
teamsapp.yml |
This is the main Teams Toolkit project file. The project file defines two primary things: Properties and configuration Stage definitions. |
teamsapp.local.yml |
This overrides teamsapp.yml with actions that enable local execution and debugging. |
You can follow Get started with Teams AI library to extend the AI Assistant Bot template with more AI capabilities.