Edit

Share via


Build your first agent

Agents use AI to automate and execute business processes, working alongside or on behalf of a person, team, or organization. Agents range from simple prompt-and-response agents to more advanced, fully autonomous agents.

Tools you'll need

To build an agent in Teams, you’ll need the following:

Install For using...
Visual Studio Code JavaScript, TypeScript, or Python build environments. Use the latest version.
Teams SDK A simplified SDK for building intelligent agents. Now GA for JavaScript and C#, and in public preview for Python.
Microsoft 365 Agents Toolkit Microsoft Visual Studio Code extension that creates a project scaffolding for your agent. Use the latest version.
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 agents and apps for chat, meetings, and calls all in one place.
Azure OpenAI First create your OpenAI API key to use OpenAI's Generative Pretrained Transformer (GPT). If you want to host your agent or access resources in Azure, you must create an Azure OpenAI service.

Set up your environment

  1. Install the latest versions of Visual Studio Code, Node.js, and the Microsoft 365 Agents Toolkit.
  2. If you want to use Azure OpenAI service to access large language model (LLM) for your agent, create an Azure OpenAI service on the Azure portal and get your API key.

For more information about setting up Azure OpenAI services, see:

Create an agent using Microsoft 365 Agents Toolkit

  1. Open Visual Studio Code.

  2. Select the Microsoft 365 Agents Toolkit icon in the Visual Studio Code Activity Bar.

  3. Select Create a New Agent/App.

    Screenshot shows the location of the option to create a new agent using Microsoft 365 Agents Toolkit sidebar.

  4. From the New Project menu, select Teams Agents and Apps.

    Screenshot shows the location of the option to create a new agent or app in Teams.

  5. Select General Teams Agent to create an agent.

    Screenshot shows the location of the option to create a new agent in Teams.

  6. Select a service to access large language model (LLM) for your agent.

    Screenshot shows the location of the option to select an appropriate LLM for your agent.

    Select one of the following options:

    • Select Azure OpenAI if you've got the OpenAI key from Azure. Following this, you must:

      1. Enter Azure OpenAI key in Azure OpenAI service key.
      2. Enter the endpoint in Azure OpenAI service endpoint.
      3. Enter the deployment name in Azure OpenAI deployment name.
    • Select OpenAI Key and enter the OpenAI key.

  7. Select the Programming Language for developing your agent.

    Screenshot shows the option to select the programming language for your agent.

  8. Select the Default folder as the Workspace Folder for your agent project.

    Screenshot shows the field to select the workspace forlder for your agent project.

  9. Enter the agent name and then select Enter.

    Screenshot shows the field to add the agent name.

    The toolkit displays a message that the agent has been successfully created. You can also provision the agent at this time or later. If the toolkit displays a message to confirm if you trust the author, select Yes, I trust the authors.

    Screenshows the message for confirming if you trust the authors of the agent.

Take a tour of the agent source code

Microsoft 365 Agents Toolkit creates your agent project and scaffolds the project workspace. Here's a look at the folder structure:

Folder Contents
.vscode Visual Studio Code files for debugging.
appPackage Templates for the Teams manifest.
env Environment files.
infra Templates for provisioning Azure resources.
src The source code for the project.

Run and use your agent in Teams

  1. Open your agent project in Visual Studio Code.

  2. Select Run > Start Debugging, or alternatively, select the F5 key.

    If all prerequisites are installed, Visual Studio Code uploads and opens your agent in Microsoft Teams.

    Screenshot shows the agent opened in Microsoft Teams.

  3. To use your agent, select one of the prompts shown by the agent.

    Screenshot shows how to select a prompt from the agent.

    When you select the prompt, it shows up in the comment box, and you can select the Send icon. The agent responds to the prompt.

    Screenshot shows the agent response to the user prompt.

Congratulations! You've created and ran your first agent in Teams.

Choose your programming language

Teams SDK is available for JavaScript, C#, and Python (dev preview). It provides a simplified SDK, support for Model Context Protocol (MCP), Agent-to-Agent communication (A2A), and streamlined tools to enable developers to build intelligent agents for Teams.

Description

            Choose your build environment

Build with ...

C#

Code sample

Sample name Description .NET Node.js Python
Contoso knowledge hub An intelligent agent built on the Teams SDK that is designed to empower students in their academic and career journeys. The agent offers personalized support for course selection, study strategies, career development planning, and academic roadmap creation. View View View

See also

Agents user experience