Overview of the AI Assistant Bot template

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.

Get started with the AI Assistant Bot template

Prerequisites

To run the AI Assistant Bot template in your local dev machine, you will need:

Note

Teams AI Library is currently in preview version.

Create your own OpenAI Assistant

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.

  1. Open terminal and run command npm install to install all dependency packages

    > npm install
    
  2. After npm install completed, run command npm run assistant:create -- <your-openai-api-key>

    > npm run assistant:create -- xxxxxx
    
  3. The above command will output something like "Created a new assistant with an ID of: asst_xxx..."

  4. 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

  1. 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>
    

Run Teams Bot locally

  1. First, select the Teams Toolkit icon on the left in the VS Code toolbar.
  2. In the Account section, sign in with your Microsoft 365 account if you haven't already.
  3. Press F5 to start debugging which launches your app in Teams using a web browser. Select Debug (Edge) or Debug (Chrome).
  4. When Teams launches in the browser, select the Add button in the dialog to install your app to Teams.
  5. 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:

ai assistant bot in Teams

What's included in the template

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.

Extend the AI Assistant Bot template with more AI capabilities

You can follow Get started with Teams AI library to extend the AI Assistant Bot template with more AI capabilities.

Additional information and references