This template showcases a bot app that responds to user questions like an AI assistant. This enables your users to talk with the AI assistant in Teams to find information.
The app template is built using the Teams AI library, which provides the capabilities to build AI-based Teams applications.
Prerequisites
To run the AI Chat Bot template in your local dev machine, you will need:
- Node.js, supported versions: 16, 18
- 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.
- First, select the Teams Toolkit icon on the left in the VS Code toolbar.
- In file env/.env.testtool.user, fill in your OpenAI key
SECRET_OPENAI_API_KEY=<your-key>
. - Press F5 to start debugging which launches your app in Teams App Test Tool using a web browser. Select
Debug in Test Tool
. - 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 App Test Tool:
Above steps use OpenAI as AI service, optionally, you can also use Azure OpenAI as AI service.
Prerequisites
- Prepare your own Azure OpenAI resource.
- In file env/.env.local.user, fill in your Azure OpenAI key
SECRET_AZURE_OPENAI_API_KEY=<your-key>
and endpointSECRET_AZURE_OPENAI_ENDPOINT=<your-endpoint>
. - In
src/app.ts
, comment out "Use OpenAI" part and uncomment "use Azure OpenAI" part, e.g.// Use OpenAI /** const planner = new OpenAIPlanner({ apiKey: config.openAIKey, defaultModel: "gpt-3.5-turbo", useSystemMessage: true, logRequests: true }); */ // Uncomment the following lines to use Azure OpenAI const planner = new AzureOpenAIPlanner({ apiKey: config.azureOpenAIKey, endpoint: config.azureOpenAIEndpoint, defaultModel: "gpt-35-turbo", useSystemMessage: true, logRequests: true, });
- In
src/app.ts
, updatedefaultModel
to your own model deployment name.
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/prompts/chat/skprompt.txt |
Defines the prompt. |
src/prompts/chat/config.json |
Configures the prompt. |
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. |
teamsapp.testtool.yml |
This overrides teamsapp.yml with actions that enable local execution and debugging in Teams App Test Tool. |
You can follow Get started with Teams AI library to extend the AI Chat Bot template with more AI capabilities.