### Scaffold New Teams Tab App with CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/tabs/getting-started.md This command utilizes the Teams CLI to scaffold a new tab application. It creates a project named 'my-first-tab-app' with an embedded toolkit (`--tk embed`) and a tab specific template (`--template tab`), serving as the initial setup for a new Teams tab app project. ```sh teams new my-first-tab-app --tk embed --template tab ``` -------------------------------- ### Scaffold New Teams Tab App with CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/tabs/getting-started.md This command uses the Teams CLI to scaffold a new tab application project. It leverages the Microsoft 365 Agents Toolkit configuration and a template for embedding, simplifying the initial setup for a Teams tab app. ```sh teams new my-first-tab-app --tk embed --template tab ``` -------------------------------- ### Install Teams AI Agent Project Dependencies Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Installs all required Node.js packages and dependencies for the Teams AI agent project, as specified in its `package.json` file. This step ensures all necessary libraries are available for the agent to run. ```sh npm install ``` -------------------------------- ### Start Teams AI Agent Development Server Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Launches the local development server for the Teams AI agent, enabling real-time testing and interaction. This command typically starts both the main application server and a separate devtools server for debugging. ```sh npm run dev ``` -------------------------------- ### Navigate to Agent Project Directory Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Changes the current working directory to the newly created Teams AI agent project, which is necessary before installing dependencies or running the agent. ```sh cd quote-agent ``` -------------------------------- ### Install Teams CLI Globally Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/quickstart.md Installs the Microsoft Teams Command Line Interface (CLI) globally using npm. This tool is essential for creating and managing Teams applications, simplifying the development process. ```Shell npm install -g @microsoft/teams.cli@preview ``` -------------------------------- ### Run Your C# Teams AI Agent Locally Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/quickstart.md A sequence of commands to navigate into the newly created agent's directory, restore its .NET dependencies, and start the development server. This process makes the agent accessible locally via HTTP and launches a devtools server for debugging and testing. ```Shell cd Quote.Agent/Quote.Agent ``` ```C# dotnet restore ``` ```C# dotnet run ``` -------------------------------- ### Install Teams CLI Globally Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Installs the Microsoft Teams Command Line Interface globally using npm, allowing access to `teams` commands from any directory. This is a prerequisite for creating and managing Teams applications. ```sh npm install -g @microsoft/teams.cli@preview ``` -------------------------------- ### Teams AI Agent Development Server Output Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Displays the console output when the Teams AI agent development server starts. This output confirms nodemon is running, shows watched files, and indicates the listening ports for the main server (3978) and the devtools server (3979). ```sh > quote-agent@0.0.0 dev > npx nodemon -w "./src/**" -e ts --exec "node -r ts-node/register -r dotenv/config ./src/index.ts" [nodemon] 3.1.9 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): src/** [nodemon] watching extensions: ts [nodemon] starting `node -r ts-node/register -r dotenv/config ./src/index.ts` [WARN] @teams/app/devtools ⚠️ Devtools are not secure and should not be used production environments ⚠️ [INFO] @teams/app/http listening on port 3978 🚀 [INFO] @teams/app/devtools available at http://localhost:3979/devtools ``` -------------------------------- ### Implement Teams AI App with OAuth and Message/Event Handling Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx This example illustrates the setup of a Teams AI `App` using the `@microsoft/teams.apps` SDK, including OAuth configuration. It defines handlers for `/signout` messages to manage user sessions, general `message` events to prompt sign-in if needed, and a `signin` event to confirm successful authentication. The app is then started asynchronously. ```TypeScript import { App } from '@microsoft/teams.apps'; import { ConsoleLogger } from '@microsoft/teams.common/logging'; const app = new App({ oauth: { defaultConnectionName: process.env.connectionName } }); app.message('/signout', async ({ send, signout, isSignedIn }) => { if (!isSignedIn) return; await signout(); await send('You have been signed out.'); }); app.on('message', async ({ send, signin, isSignedIn }) => { if (!isSignedIn) { return await signin(); } }); app.event('signin', async ({ send }) => { await send('You have been signed in.'); }); (async () => { await app.start(); })(); ``` -------------------------------- ### Add Agents Toolkit OAuth Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/user-authentication/quickstart.md Adds relevant Agents Toolkit files to the current project, specifically configuring it for OAuth authentication. This command integrates the necessary components for handling user authentication flows within the Teams app, building upon the initial app setup. ```sh teams config add atk.oauth ``` -------------------------------- ### Initialize Teams Client App Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/tabs/using-the-app.md This code snippet demonstrates how to initialize the `@microsoft/teams.client` App. It imports the `App` class, creates a new instance with a `clientId`, and then calls the `start()` method to begin the app's lifecycle, which includes TeamsJS initialization and MSAL setup. ```typescript import { App } from '@microsoft/teams.client'; const app = new App(clientId); await app.start(); ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/README.md Installs all required Node.js packages and dependencies for the Docusaurus website using npm. ```Shell $ npm install ``` -------------------------------- ### Start Local Development Server Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/README.md Initiates a local development server for the website, automatically opening it in a browser. This command supports live reloading for most changes. ```Shell $ npm run start ``` -------------------------------- ### Create a New Teams AI Agent Project Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/quickstart.md Generates a new TypeScript project for a Teams AI agent using the `echo` template. This command creates a new directory, bootstraps source files, and sets up the necessary app manifest for sideloading into Teams. ```sh teams new typescript quote-agent --template echo ``` -------------------------------- ### Initialize and Start Teams Client App Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/tabs/using-the-app.md This snippet demonstrates the basic steps to initialize and start the `@microsoft/teams.client` App. It shows how to import the `App` class, create an instance by providing a client ID, and then call `app.start()` to begin the application's lifecycle, which includes initializing TeamsJS and MSAL. ```typescript import { App } from '@microsoft/teams.client'; const app = new App(clientId); await app.start(); ``` -------------------------------- ### Starting the Teams Application Server Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/code-basics.md Illustrates the asynchronous call to `app.start()` which initializes the application server and prepares it for sending and receiving messages. ```typescript (async () => { await app.start(); })(); ``` -------------------------------- ### Create New Teams AI App with Graph Template Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/user-authentication/quickstart.md This command initializes a new Teams AI application directory named `oauth-app` and bootstraps it with the `graph` agent template files. It also generates the necessary manifest files for sideloading the app into Teams. ```sh teams new oauth-app --template graph ``` -------------------------------- ### Implement Simple Chat Generation with Teams AI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/chat.mdx This example illustrates the fundamental setup for basic chat generation. It shows how to initialize an OpenAIModel, configure a ChatPrompt, and send a user message to receive a direct response from the AI model within a Teams application. ```typescript // Create an AI model const model = new OpenAIModel({ apiKey: process.env.OPENAI_API_KEY, defaultModel: 'gpt-3.5-turbo' }); // Create a ChatPrompt const chatPrompt = new ChatPrompt({ model: model, prompt: 'You are a helpful AI assistant.', history: new ConversationHistory() }); // Send a message application.message('/chat', async (context, state) => { const response = await chatPrompt.complete(context, state); await context.sendActivity(response); }); ``` -------------------------------- ### Install Teams CLI Globally Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/main/welcome.md This command installs the Microsoft Teams CLI globally using npm. The CLI is essential for bootstrapping new Teams AI projects and managing development workflows. ```bash npm install -g @microsoft/teams.cli@preview ``` -------------------------------- ### BotBuilder: Restify Server and Authentication Setup Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx Initializes a Restify server instance and configures Bot Framework authentication using environment variables. This forms the basic setup for a BotBuilder application's backend. ```typescript const server = restify.createServer(); const auth = new ConfigurationBotFrameworkAuthentication(process.env); ``` -------------------------------- ### Teams AI Application Project Structure Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/ai/setup-and-prereqs.md Illustrates the recommended directory layout for a Teams AI application, highlighting the location of the application package, source code, and environment variables file. ```plaintext my-app/ |── appPackage/ # Teams app package files ├── src/ │ └── index.ts # Main application code |── .env # Environment variables ``` -------------------------------- ### Install Teams CLI for AI Library v2 Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/README.md Installs the Microsoft Teams CLI globally using npm, allowing users to bootstrap new Teams AI agents. This is a preview version of the CLI. ```sh npm install -g @microsoft/teams.cli@preview ``` -------------------------------- ### Create New Teams App with Graph Template Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/user-authentication/quickstart.md Initializes a new Teams application directory named `oauth-app` and bootstraps it with the `graph` agent template files. This command sets up the basic structure for a Teams app integrated with Microsoft Graph authentication, including manifest and placeholder icons. ```sh teams new oauth-app --template graph ``` -------------------------------- ### Registering a Time Logging Middleware in TypeScript Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/observability/middleware.md This example demonstrates how to register a simple middleware using `app.use` in TypeScript. The middleware captures the start time, allows subsequent handlers to execute, and then logs the total elapsed time. ```typescript app.use(async ({ log, next }) => { const startedAt = new Date(); await next(); log.debug(new Date().getTime() - startedAt.getTime()); }); ``` -------------------------------- ### Add Microsoft 365 Agents Toolkit OAuth Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/user-authentication/quickstart.md Run this command from within your `oauth-app/` directory to integrate the Microsoft 365 Agents Toolkit's OAuth configuration files into your project, enabling authentication features. ```sh teams config add atk.oauth ``` -------------------------------- ### Interact with TeamsJS, Graph, and Remote Agents using Teams Client App Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/tabs/using-the-app.md After the app has successfully started, this example illustrates how to leverage the initialized `@microsoft/teams.client` App instance. It demonstrates how to retrieve the TeamsJS context, make calls to Microsoft Graph API endpoints (e.g., fetching user presence), and invoke remote agent functions using the `app.exec()` method. ```typescript import * as teamsJs from '@microsoft/teams-js'; import { App } from '@microsoft/teams.client'; const app = new App(clientId); await app.start(); // you can now get the TeamsJS context... const context = await teamsJs.app.getContext(); // ...call Graph end points... const presenceResult = await app.graph.me.presence.get(); // ...end call remote agent functions... const agentResult = await app.exec('hello-world'); ``` -------------------------------- ### Create a New C# Teams AI Echo Agent Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/quickstart.md Generates a new C# Teams AI project named 'quote-agent' using the 'echo' template. This command bootstraps template files, creates a basic agent that repeats messages, and generates necessary manifest files, including 'manifest.json', required for sideloading into Teams. ```Shell teams new csharp quote-agent --template echo ``` -------------------------------- ### Recommended Project Structure for Teams AI Applications Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/setup-and-prereqs.md Illustrates the typical directory layout for a Teams AI application, emphasizing the placement of the `.env` file at the project's root for managing environment variables securely. ```plaintext my-app/ |── appPackage/ # Teams app package files ├── src/ │ └── index.ts # Main application code |── .env # Environment variables ``` -------------------------------- ### OpenAI API Key Environment Variable Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/ai/setup-and-prereqs.md Specifies the environment variable for setting the OpenAI API key, which is essential for authenticating requests to the OpenAI platform. ```env OPENAI_API_KEY=sk-your-openai-api-key ``` -------------------------------- ### Install MCP Client Package Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/mcp/mcp-client.mdx This command installs the `@microsoft/teams.mcpclient` package, which provides the necessary components for integrating an MCP client into your application. This package allows your AI agent to connect to and utilize remote MCP servers. ```bash npm install @microsoft/teams.mcpclient@preview ``` -------------------------------- ### Install Teams CLI Globally via npm Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/main/developer-tools/cli.md This command installs the Teams CLI globally using npm, allowing the `teams` command to be executed directly from any terminal. It installs the `@microsoft/teams.cli@preview` package. ```sh npm install -g @microsoft/teams.cli@preview ``` -------------------------------- ### Install McpPlugin for MCP Server Capabilities Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/mcp/mcp-server.mdx This command installs the `@microsoft/teams.mcp` package from npm. This package provides the `McpPlugin` which is essential for transforming a standard Teams application into an MCP server, enabling it to communicate and share capabilities with other MCP clients. ```bash npm install @microsoft/teams.mcp@preview ``` -------------------------------- ### Add OAuth Configuration using Teams CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/user-authentication/setup.mdx This command utilizes the `teams` CLI to add basic Agents Toolkit setup and configurations for authenticating users with Microsoft Entra ID to access Microsoft Graph APIs. It automatically generates required files like `aad.manifest.json` and Azure Bicep files for provisioning the Application Entra ID and Azure bot with OAuth configurations. ```sh teams config add atk.oauth ``` -------------------------------- ### Implement Middleware for Activity Logging (C# Controller/Minimal API) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/on-activity/README.mdx Illustrates the middleware pattern for activity handlers by showing how to log information globally before passing control to the next handler in the chain. This example uses next() or context.Next() to ensure subsequent handlers are invoked. ```csharp [Message] public void OnMessage([Context] MessageActivity activity, [Context] ILogger logger, [Context] IContext.Next next) { Console.WriteLine("global logger"); next(); // pass control onward } ``` ```csharp app.OnMessage(async context => { Console.WriteLine("global logger"); context.Next(); // pass control onward return Task.CompletedTask; }); ``` -------------------------------- ### Install A2A Package for Teams AI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/a2a/README.md Command to install the experimental A2A package, `@microsoft/teams.a2a@preview`, which enables Agent-to-Agent communication within Teams applications. ```bash npm install @microsoft/teams.a2a@preview ``` -------------------------------- ### Azure OpenAI Environment Variables Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/ai/setup-and-prereqs.md Provides the necessary environment variables for configuring an Azure OpenAI service connection, including the API key, model deployment name, endpoint URL, and the specific API version to use. ```env AZURE_OPENAI_API_KEY=your-azure-openai-api-key AZURE_OPENAI_MODEL_DEPLOYMENT_NAME=your-azure-openai-model AZURE_OPENAI_ENDPOINT=you-azure-openai-endpoint AZURE_OPENAI_API_VERSION=your-azure-openai-api-version ``` -------------------------------- ### Configure OAuth for Agents Toolkit using Teams CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/user-authentication/setup.mdx This command facilitates the setup of basic OAuth configurations for the Microsoft 365 Agents Toolkit. It enables user authentication with Microsoft Entra ID to access Microsoft Graph APIs, automatically generating essential configuration files such as `aad.manifest.json` and Azure bicep files for resource provisioning. ```sh teams config add atk.oauth ``` -------------------------------- ### End-to-End Adaptive Card Example: Task Form in TypeScript Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/adaptive-cards/building-adaptive-cards.mdx Presents a complete example of building a task management form using the Adaptive Card builder pattern in TypeScript. This comprehensive snippet showcases how various input types, column sets, and actions can be combined to create an interactive and maintainable UI, highlighting the readability benefits of the builder approach. ```typescript import { Card, TextBlock, Input, Action, ColumnSet, Column, ToggleInput, DateInput, ChoiceSetInput, SubmitAction } from '@microsoft/teams.cards'; const taskFormCard = new Card() .addBody( new TextBlock('Task Management Form') .setSize('large') .setWeight('bolder') ) .addBody( new Input.Text('taskTitle', 'Task Title') .setPlaceholder('e.g., Complete documentation') .setIsRequired(true) ) .addBody( new Input.Text('taskDescription', 'Description') .setPlaceholder('Provide details about the task') .setIsMultiline(true) ) .addBody( new ColumnSet() .addColumn( new Column() .addItem(new TextBlock('Due Date')) .addItem(new DateInput('dueDate')) ) .addColumn( new Column() .addItem(new TextBlock('Priority')) .addItem( new ChoiceSetInput('priority') .addChoice('High', 'high') .addChoice('Medium', 'medium') .addChoice('Low', 'low') .setIsCompact(true) .setValue('medium') ) ) ) .addBody( new ToggleInput('isCompleted', 'Mark as Completed') .setValue('false') ) .addAction( new SubmitAction('submitTask', 'Submit Task') .setTitle('Submit') ); console.log(JSON.stringify(taskFormCard.toJSON(), null, 2)); ``` -------------------------------- ### Sending Adaptive Cards with BotBuilder Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/turn-context/sending-activities.mdx This example demonstrates how to send a simple 'hello world' Adaptive Card using the `botbuilder` library. It utilizes `TeamsActivityHandler` to process incoming messages and `CardFactory.adaptiveCard` to construct and attach the Adaptive Card to the outgoing activity. ```typescript import { TeamsActivityHandler, CardFactory } from 'botbuilder'; export class ActivityHandler extends TeamsActivityHandler { constructor() { super(); this.onMessage(async (context) => { await context.sendActivity({ type: 'message', attachments: [ CardFactory.adaptiveCard({ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.0", "body": [{ "type": "TextBlock", "text": "hello world" }] }) ] }); }); } } ``` -------------------------------- ### Store Conversation ID on App Install (Minimal) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/sending-messages/proactive-messaging.mdx Illustrates an alternative, more minimal way to capture and store the conversation ID when the app is installed, using `app.OnInstall`. It saves the `AadObjectId` and `Conversation.Id` to storage and sends a welcome message. ```csharp app.OnInstall(async context => { // Save the conversation id in context.Storage.Set(activity.From.AadObjectId!, activity.Conversation.Id); await context.Send("Hi! I am going to remind you to say something to me soon!"); notificationQueue.AddReminder(activity.From.AadObjectId!, Notifications.SendProactive, 10_000); }); ``` -------------------------------- ### Teams AI Configuration Routes Reference Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/essentials/on-activity/activity-ref.md Details the routes used for application configuration, including opening and submitting configuration dialogs when the app is installed or updated. ```APIDOC Route Invoke Path Responsibility config.open config/fetch When app is installed, the user may configure it via a dialog config.submit config/submit Configuration dialog submission tab.open tab/fetch Initializes tab configuration experiences tab.submit tab/submit Processes tab configuration submissions ``` -------------------------------- ### C# Teams AI Message Handling Implementations Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/code-basics.mdx Presents two approaches for handling incoming messages in a C# Teams AI application: a controller-based approach using `MainController.cs` with attributes, and a minimal, functional approach directly in `Program.cs`. Both examples demonstrate sending a typing indicator and echoing the received message. ```csharp [TeamsController("main")] public class MainController { [Message] public async Task OnMessage([Context] MessageActivity activity, [Context] IContext.Client client) { await client.Typing(); await client.Send($"you said \"{activity.Text}\""); } } ``` ```csharp app.OnMessage(async context => { await context.Typing(); await context.Send($"you said \"{context.activity.Text}\""); }); ``` -------------------------------- ### Lifecycle Routes API Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/essentials/on-activity/activity-ref.md Describes routes triggered by the installation, uninstallation, and updates of the application within a team or chat, as well as handoff events. ```APIDOC Route: install.add Responsibility: Triggered when the app is newly installed to a team or chat Route: install.remove Responsibility: Triggered when the app is uninstalled from a team or chat Route: install.update Responsibility: Triggered when the app is updated in a team or chat Route: handoff.action Responsibility: Manages handoffs from a different agent to your application ``` -------------------------------- ### Add Teams Configuration Files via CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/running-in-teams.md This command uses the `npx` utility to execute the `@microsoft/teams.cli` tool, adding basic configuration files for the Microsoft 365 Agents Toolkit. These files include environment setup, Teams app manifest, debug instructions, and automation files necessary for Teams development. ```bash npx @microsoft/teams.cli config add atk.basic ``` -------------------------------- ### Environment Variables for Azure OpenAI Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/setup-and-prereqs.md Provides the essential environment variables required to connect and authenticate with Azure OpenAI services. These variables include the API key, the name of the deployed model, the service endpoint, and the specific API version to use. ```env AZURE_OPENAI_API_KEY=your-azure-openai-api-key AZURE_OPENAI_MODEL_DEPLOYMENT_NAME=your-azure-openai-model AZURE_OPENAI_ENDPOINT=you-azure-openai-endpoint AZURE_OPENAI_API_VERSION=your-azure-openai-api-version ``` -------------------------------- ### Sending Generic Attachments with BotBuilder Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/turn-context/sending-activities.mdx This example demonstrates the general structure for sending various types of attachments using the `botbuilder` library. It shows how to include an array of attachments within the `sendActivity` method of a `TeamsActivityHandler`. ```typescript import { TeamsActivityHandler } from 'botbuilder'; export class ActivityHandler extends TeamsActivityHandler { constructor() { super(); this.onMessage(async (context) => { await context.sendActivity({ type: 'message', attachments: [ ... ] }); }); } } ``` -------------------------------- ### Environment Variable for OpenAI API Key Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/ai/setup-and-prereqs.md Specifies the environment variable used to store the OpenAI API key. This key is crucial for authenticating requests to OpenAI's services and should be kept secure. ```env OPENAI_API_KEY=sk-your-openai-api-key ``` -------------------------------- ### BotBuilder: Restify Server Setup (Deprecated) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx Demonstrates setting up a Restify server to listen for incoming messages on a specified port and route them to the BotBuilder adapter for processing. This snippet appears to be part of a deprecated or removed configuration. ```javascript server.use(restify.plugins.bodyParser()); server.listen(process.env.port || process.env.PORT || 3978, function() { console.log(`\n${ server.name } listening to ${ server.url }`); }); server.post('/api/messages', async (req, res) => { await adapter.process(req, res, (context) => bot.run(context)); }); ``` -------------------------------- ### Adaptive Card Action Types Reference Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/adaptive-cards/executing-actions.mdx A reference guide to the various action types supported by the Teams AI Library for Adaptive Cards, detailing their purpose and typical use cases. ```APIDOC Action Types: Action.Execute: Purpose: Server-side processing Description: Send data to your bot for processing. Best for forms & multi-step workflows. Action.Submit: Purpose: Simple data submission Description: Legacy action type. Prefer Execute for new projects. Action.OpenUrl: Purpose: External navigation Description: Open a URL in the user's browser. Action.ShowCard: Purpose: Progressive disclosure Description: Display a nested card when clicked. Action.ToggleVisibility: Purpose: UI state management Description: Show/hide card elements dynamically. ``` -------------------------------- ### Microsoft Teams AI CLI Commands Overview Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/running-in-teams.md This section provides an overview of the command-line interface tools relevant to Microsoft Teams AI development. It details the purpose and functionality of the `teams` CLI for Teams AI v2 library setup and the `atk` CLI for managing provisioning, deployment, and in-client debugging within Teams. ```APIDOC Cmd name | CLI name | Description ---|---|--- `teams` | Teams AI v2 | A tool for setting up and utilizing the Teams AI v2 library including integration with Agents Toolkit, if desired. `atk` | Agents Toolkit | A tool for managing provisioning, deployment, and in-client debugging for Teams. ``` -------------------------------- ### Configure McpPlugin for Teams AI App Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/ai/mcp/mcp-server.mdx This TypeScript snippet demonstrates how to configure the `McpPlugin` from `@microsoft/teams.mcp` to enable MCP server capabilities within a Teams AI application. It shows basic plugin setup, including optional path configuration for the MCP endpoint. ```typescript import { McpPlugin } from '@microsoft/teams.mcp'; const mcpPlugin = new McpPlugin({ transport: { path: '/mcp' // Default path, can be customized }, // Other configurations like tools, resources, prompts }); ``` -------------------------------- ### Teams AI: App Initialization and Authentication Handlers Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx Initializes a Teams AI application with OAuth configuration. It defines handlers for '/signout' messages, general messages (to trigger sign-in if not authenticated), and a 'signin' event handler to confirm successful sign-in. The application is started asynchronously. ```javascript const app = new App({ oauth: { defaultConnectionName: process.env.connectionName } }); app.message('/signout', async ({ send, signout, isSignedIn }) => { if (!isSignedIn) return; await signout(); await send('You have been signed out.'); }); app.on('message', async ({ send, signin, isSignedIn }) => { if (!isSignedIn) { return await signin(); } }); app.event('signin', async ({ send }) => { await send('You have been signed in.'); }); (async () => { await app.start(); })(); ``` -------------------------------- ### Create New Teams AI Agent Project Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/main/developer-tools/cli.md This command initializes a new Teams AI agent project. Users specify the project type (TypeScript or C#) and the desired application name, which also becomes the directory name. Optional parameters allow for template selection, immediate project start, and inclusion of Microsoft 365 Agents Toolkit configurations. ```sh teams new ``` -------------------------------- ### Teams AI Middleware for Global Logging Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/essentials/on-activity/README.md Illustrates the middleware pattern in Teams AI activity handlers. This TypeScript example logs a message globally for every 'message' activity and then calls `next()` to pass control to the next handler in the chain, allowing further processing. ```typescript app.on('message', async ({ next }) => { console.log('global logger'); next(); // pass control onward }); ``` -------------------------------- ### Conditionally Pass Control in Activity Middleware (C# Controller/Minimal API) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/on-activity/README.mdx Shows how to conditionally pass control to the next handler in the middleware chain based on the activity content. In this example, if the message is '/help', a specific response is sent, and then context.Next() is called to allow further processing. ```csharp [Message] public async Task OnMessage(IContext context) { if (context.Activity.Text == "/help") { await context.Send("Here are all the ways I can help you..."); } // Conditionally pass control to the next handler context.Next(); } ``` ```csharp app.OnMessage(async context => { if (context.Activity.Text == "/help") { await context.Send("Here are all the ways I can help you..."); } // Conditionally pass control to the next handler context.Next(); }); ``` -------------------------------- ### Migrating BotBuilder Adapters to Teams AI Plugins Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/adapters.mdx This collection of snippets demonstrates how to integrate existing BotBuilder adapters and activity handlers into a Teams AI Library v2 application using the `BotBuilderPlugin`. It covers the main application setup, adapter configuration, and activity handler implementation to ensure seamless migration and continued bot communication. ```typescript import { App } from '@microsoft/teams.apps'; import { BotBuilderPlugin } from '@microsoft/teams.botbuilder'; import adapter from './adapter'; import handler from './activity-handler'; const app = new App({ // highlight-next-line plugins: [new BotBuilderPlugin({ adapter, handler })], }); app.on('message', async ({ send }) => { await send('hi from teams...'); }); (async () => { await app.start(); })(); ``` ```typescript import { CloudAdapter } from 'botbuilder'; // replace with your BotAdapter // highlight-start const adapter = new CloudAdapter( new ConfigurationBotFrameworkAuthentication( {}, new ConfigurationServiceClientCredentialFactory({ MicrosoftAppType: tenantId ? 'SingleTenant' : 'MultiTenant', MicrosoftAppId: clientId, MicrosoftAppPassword: clientSecret, MicrosoftAppTenantId: tenantId, }) ) ); // highlight-end export default adapter; ``` ```typescript import { TeamsActivityHandler } from 'botbuilder'; // replace with your TeamsActivityHandler // highlight-start export class ActivityHandler extends TeamsActivityHandler { constructor() { super(); this.onMessage(async (ctx, next) => { await ctx.sendActivity('hi from botbuilder...'); await next(); }); } } // highlight-end const handler = new ActivityHandler(); export default handler; ``` -------------------------------- ### Fetch Conversation Members in C# Activity Handler Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/api.mdx This example demonstrates how to retrieve members of a conversation using the ApiClient instance, which is passed as a context parameter to an activity handler. It shows both a controller-based approach and a minimal handler setup. ```csharp [Message] public async Task OnMessage([Context] MessageActivity activity, [Context] ApiClient api) { var members = await api.Conversations.Members.Get(context.Conversation.Id); } ``` ```csharp app.OnMessage(async context => { var members = await context.Api.Conversations.Members.Get(context.Conversation.Id); }); ``` -------------------------------- ### Example Terminal Output During Teams Debugging Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/running-in-teams.md This snippet shows typical console output when an application starts debugging with Agents Toolkit, indicating the local server listening address, devtools availability, and application lifecycle events. ```sh [INFO] Microsoft.Hosting.Lifetime Now listening on: http://localhost:3978 [WARN] Echo.Microsoft.Teams.Plugins.AspNetCore.DevTools ⚠️ Devtools are not secure and should not be used production environments ⚠️ [INFO] Echo.Microsoft.Teams.Plugins.AspNetCore.DevTools Available at http://localhost:3978/devtools [INFO] Microsoft.Hosting.Lifetime Application started. Press Ctrl+C to shut down. [INFO] Microsoft.Hosting.Lifetime Hosting environment: Development ``` -------------------------------- ### Migrate BotBuilder ActivityHandler to Teams AI App Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/activity-handlers.mdx This example demonstrates how to incrementally migrate existing BotBuilder `ActivityHandler` patterns to the Teams AI Library v2 activity routing system. It shows how to use the `BotBuilderPlugin` to integrate an existing `ActivityHandler` instance with a new Teams AI `App`, allowing both systems to route activities. The `index.ts` file initializes the Teams AI `App` with the `BotBuilderPlugin`, `adapter.ts` configures the `CloudAdapter` for bot communication, and `activity-handler.ts` defines a custom `TeamsActivityHandler` to process messages. ```typescript import { App } from '@microsoft/teams.apps'; import { BotBuilderPlugin } from '@microsoft/teams.botbuilder; import adapter from './adapter'; import handler from './activity-handler'; const app = new App({ plugins: [new BotBuilderPlugin({ adapter, handler })], }); app.on('message', async ({ send }) => { await send('hi from teams...'); }); (async () => { await app.start(); })(); ``` ```typescript import { CloudAdapter } from 'botbuilder'; // replace with your BotAdapter const adapter = new CloudAdapter( new ConfigurationBotFrameworkAuthentication( {}, new ConfigurationServiceClientCredentialFactory({ MicrosoftAppType: tenantId ? 'SingleTenant' : 'MultiTenant', MicrosoftAppId: clientId, MicrosoftAppPassword: clientSecret, MicrosoftAppTenantId: tenantId, }) ) ); export default adapter; ``` ```typescript import { TeamsActivityHandler } from 'botbuilder'; // replace with your TeamsActivityHandler export class ActivityHandler extends TeamsActivityHandler { constructor() { super(); this.onMessage(async (ctx, next) => { await ctx.sendActivity('hi from botbuilder...'); await next(); }); } } const handler = new ActivityHandler(); export default handler; ``` -------------------------------- ### Pre-warm Specific Scopes for Teams AI App Consent Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/tabs/app-options.md This example shows how to configure the Teams AI App to pre-warm a specific set of scopes. By listing required scopes in `msalOptions.prewarmScopes`, the app will prompt the user for consent to these particular scopes if they haven't already been granted, ensuring necessary permissions are obtained early. ```typescript import { App } from '@microsoft/teams.client'; const app = new App(clientId, { msalOptions: { prewarmScopes: ['User.Read', 'Chat.ReadBasic'] }, }); // if the user hasn't already given consent for each listed scope, // this will prompt them await app.start(); ``` -------------------------------- ### C# Teams AI Application Startup Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/code-basics.mdx Demonstrates the `Program.cs` file's role in configuring a C# Teams AI application. It shows how to add Teams services, DevTools, and register `MainController` for dependency injection, followed by building and running the application. ```csharp using Microsoft.Teams.Plugins.AspNetCore.DevTools.Extensions; using Microsoft.Teams.Plugins.AspNetCore.Extensions; using Quote.Agent; var builder = WebApplication.CreateBuilder(args); builder.AddTeams(); builder.AddTeamsDevTools(); builder.Services.AddTransient(); var app = builder.Build(); app.UseTeams(); app.Run(); ``` -------------------------------- ### Teams AI C# Project Directory Structure Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/code-basics.mdx Illustrates the typical directory layout for a new C# Teams AI application, highlighting key files like `Program.cs` for startup, `MainController.cs` for activity handling, and `appPackage/` for Teams manifest files required for sideloading. ```text Quote.Agent/ |── appPackage/ # Teams app package files ├── Program.cs # Main application startup code ├── MainController.cs # Main activity handling code ``` -------------------------------- ### Utilize Teams Client App for Graph API and Remote Agent Calls Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/tabs/using-the-app.md After the Teams client app has started, this example shows how to interact with various services. It demonstrates fetching the TeamsJS context, making calls to Microsoft Graph API endpoints (e.g., `app.graph.me.presence.get()`), and invoking remote agent functions using the `app.exec()` method. This showcases the app's capabilities for integrating with Microsoft 365 services and custom backend agents. ```typescript import * as teamsJs from '@microsoft/teams-js'; import { App } from '@microsoft/teams.client'; const app = new App(clientId); await app.start(); // you can now get the TeamsJS context... const context = await teamsJs.app.getContext(); // ...call Graph end points... const presenceResult = await app.graph.me.presence.get(); // ...end call remote agent functions... const agentResult = await app.exec('hello-world'); ``` -------------------------------- ### C# Teams AI Application Server Initialization Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/code-basics.mdx Shows the essential lines of code responsible for initializing and running the Teams AI application server. This step prepares the application to send and receive messages after configuration. ```csharp var app = builder.Build(); app.UseTeams(); app.Run(); ``` -------------------------------- ### Build Static Website Content Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/README.md Generates the static HTML, CSS, and JavaScript files for the website into the 'build' directory. The output can then be served by any static content hosting service. ```Shell $ npm run build ``` -------------------------------- ### Store Conversation ID on App Install (Controller) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/sending-messages/proactive-messaging.mdx Demonstrates how to capture and store the conversation ID during the app installation process using a controller-based approach. It saves the `AadObjectId` and `Conversation.Id` to storage and sends an initial welcome message to the user. ```csharp // Installation is just one place to get the conversation id. All activities // have the conversation id, so you can use any activity to get it. [Install] public async Task OnInstall([Context] InstallUpdateActivity activity, [Context] IContext.Client client, [Context] IStorage storage) { // Save the conversation id in storage.Set(activity.From.AadObjectId!, activity.Conversation.Id); await client.Send("Hi! I am going to remind you to say something to me soon!"); notificationQueue.AddReminder(activity.From.AadObjectId!, Notifications.SendProactive, 10_000); } ``` -------------------------------- ### Microsoft Graph API Endpoint for User-App Chat ID Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/essentials/graph.md This is the raw Microsoft Graph API endpoint to retrieve the chat instance ID between a user and an installed application. It requires the user ID or user principal name and the app installation ID to form the request URL. ```APIDOC GET /users/{user-id | user-principal-name}/teamwork/installedApps/{app-installation-id}/chat ``` -------------------------------- ### Initializing the Teams App Class Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/code-basics.md Demonstrates how to initialize the core `App` class in a Teams application, including importing necessary modules and configuring plugins like `DevtoolsPlugin`. ```typescript import { App } from '@microsoft/teams.apps'; import { ConsoleLogger } from '@microsoft/teams.common/logging'; import { DevtoolsPlugin } from '@microsoft/teams.dev'; const app = new App({ plugins: [new DevtoolsPlugin()] }); ``` -------------------------------- ### Teams Application Project Structure Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/getting-started/code-basics.md Illustrates the basic directory structure generated for a new Teams application, highlighting the `appPackage/` for manifest files and `src/` for main application code. ```plaintext quote-agent/ |── appPackage/ # Teams app package files ├── src/ │ └── index.ts # Main application code ``` -------------------------------- ### Handle Basic Teams Messages (C# Controller/Minimal API) Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/on-activity/README.mdx Demonstrates a basic message handler for Teams activities. It shows how to capture incoming MessageActivity and send a response back to the user, illustrating both the controller-based approach with attributes and the minimal API style using app.OnMessage. ```csharp [TeamsController] public class MainController { [Message] public async Task OnMessage([Context] MessageActivity activity, [Context] IContext.Client client) { await client.Send($"you said: {activity.Text}"); } } ``` ```csharp app.OnMessage(async context => { await context.Send($"you said: {context.activity.Text}"); }); ``` -------------------------------- ### Teams and Agents Toolkit CLI Tools Overview Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/running-in-teams.md Overview of the `teams` and `atk` command-line interface tools, detailing their purpose and integration with the Teams AI v2 library and Agents Toolkit for managing provisioning, deployment, and debugging of Teams applications. ```APIDOC teams: CLI name: Teams AI v2 Description: A tool for setting up and utilizing the Teams AI v2 library including integration with ATK, if desired. atk: CLI name: Agents Toolkit Description: A tool for managing provisioning, deployment, and in-client debugging for Teams. ``` -------------------------------- ### App Class Component Flowchart Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/essentials/app-basics.md Illustrates the internal flow and responsibilities of the `App` class, showing how Teams interacts with core plugins, events, activity routing, and application logic, including authentication and utilities. ```mermaid flowchart LR %% Layout Definitions direction LR Teams subgraph AppClass CorePlugins["Plugins"] Events["Events"] subgraph AppResponsbilities direction TB ActivityRouting["Activity Routing"] Utilities["Utilities"] Auth["Auth"] end Plugins2["Plugins"] end ApplicationLogic["Application Logic"] %% Connections Teams --> CorePlugins CorePlugins --> Events Events --> ActivityRouting ActivityRouting --> Plugins2 Plugins2 --> ApplicationLogic Auth --> ApplicationLogic Utilities --> ApplicationLogic %% Styling style Teams fill:#2E86AB,stroke:#1B4F72,stroke-width:2px,color:#ffffff style ApplicationLogic fill:#28B463,stroke:#1D8348,stroke-width:2px,color:#ffffff ``` -------------------------------- ### Initialize App with Default MSAL Configuration Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/in-depth-guides/tabs/app-options.md Demonstrates the default behavior of the Teams AI `App` when no MSAL instance or configuration is provided. The app automatically constructs a simple MSAL configuration suitable for multi-tenant apps and forwards MSAL logs. ```typescript import { App } from '@microsoft/teams.client'; const app = new App(clientId); await app.start(); // app.msalInstance is now available, and any logging is forwarded from // MSAL to the app.log instance. ``` -------------------------------- ### BotBuilder: SignInDialog for OAuth Authentication Flow Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx Implements a `ComponentDialog` to manage the OAuth sign-in and sign-out flow. It uses `OAuthPrompt` for authentication and a `WaterfallDialog` to guide the user through the process, including an interrupt for '/signout' commands. ```typescript export class SignInDialog extends ComponentDialog { private readonly _connectionName: string; constructor(id, connectionName: string) { super(id); this._connectionName = connectionName; this.addDialog(new OAuthPrompt('OAuthPrompt', { connectionName: connectionName, text: 'Please Sign In', title: 'Sign In', timeout: 300000 })); this.addDialog(new WaterfallDialog('Main', [ this.promptStep.bind(this), this.loginStep.bind(this) ])); this.initialDialogId = 'Main'; } async run(context, accessor) { const dialogSet = new DialogSet(accessor); dialogSet.add(this); const dialogContext = await dialogSet.createContext(context); const results = await dialogContext.continueDialog(); if (results.status === DialogTurnStatus.empty) { await dialogContext.beginDialog(this.id); } } async promptStep(stepContext) { return await stepContext.beginDialog('OAuthPrompt'); } async loginStep(stepContext) { await stepContext.context.sendActivity('You have been signed in.'); return await stepContext.endDialog(); } async onBeginDialog(innerDc, options) { const result = await this.interrupt(innerDc); if (result) return result; return await super.onBeginDialog(innerDc, options); } async onContinueDialog(innerDc) { const result = await this.interrupt(innerDc); if (result) return result; return await super.onContinueDialog(innerDc); } async interrupt(innerDc) { if (innerDc.context.activity.type === ActivityTypes.Message) { const text = innerDc.context.activity.text.toLowerCase(); if (text === '/signout') { const userTokenClient = innerDc.context.turnState.get(innerDc.context.adapter.UserTokenClientKey); const { activity } = innerDc.context; await userTokenClient.signOutUser(activity.from.id, this.connectionName, activity.channelId); await innerDc.context.sendActivity('You have been signed out.'); return await innerDc.cancelAllDialogs(); } } } } ``` -------------------------------- ### Configure Teams AI App with Pre-existing MSAL Instance Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/in-depth-guides/tabs/app-options.md Demonstrates how to initialize a Teams AI application (`@microsoft/teams.client.App`) by providing an already configured `IPublicClientApplication` instance from MSAL. This approach helps prevent the creation of multiple MSAL instances, which is cautioned against by MSAL. ```typescript import * as msal from '@azure/msal-browser'; import { App } from '@microsoft/teams.client'; const msalInstance = await msal .createNestablePublicClientApplication(/* custom MSAL configuration */); await msalInstance.initialize(); const app = new App(clientId, { msalOptions: { msalInstance } }); await app.start(); ``` -------------------------------- ### Install Teams AI DevTools Package Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/main/developer-tools/devtools/chat.md This command adds the Teams AI v2 dev package to your Teams app's dependencies using npm. This package is essential for enabling the DevTools functionality. ```bash $: npm install @microsoft/teams.dev@preview ``` -------------------------------- ### Add Teams Configuration Files with Teams CLI Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/csharp/getting-started/running-in-teams.md This command uses the `npx` utility to execute the `@microsoft/teams.cli` tool, adding basic configuration files for the Agents Toolkit. This sets up environment variables, the Teams app manifest, debug instructions, and ATK automation files for a project. ```bash npx @microsoft/teams.cli config add atk.basic ``` -------------------------------- ### Configure Bot Framework Adapter and Restify Server for Messages Source: https://github.com/lukefrugia/teams-ai/blob/v2-preview/teams.md/docs/typescript/migrations/BotBuilder/user-authentication.mdx This snippet demonstrates how to initialize a Bot Framework `CloudAdapter` with authentication, set up state management using `MemoryStorage`, `ConversationState`, and `UserState`, and configure an `ActivityHandler`. It then integrates these components with a Restify server to listen for incoming messages on a specified port and process them via the bot. ```JavaScript const adapter = new CloudAdapter(auth); const memoryStorage = new MemoryStorage(); const conversationState = new ConversationState(memoryStorage); const userState = new UserState(memoryStorage); const handler = new ActivityHandler( process.env.connectionName, conversationState, userState, ); server.use(restify.plugins.bodyParser()); server.listen(process.env.port || process.env.PORT || 3978, function() { console.log(`\n${ server.name } listening to ${ server.url }`); }); server.post('/api/messages', async (req, res) => { await adapter.process(req, res, (context) => bot.run(context)); }); ```