Choose a test setup and debug your Teams app

Teams apps can include conversational agents or bots, tabs, and other capabilities. Choose one of the following testing setups based on the capability you're testing and whether you need to validate it inside Teams:

  • Purely local: Use Microsoft 365 Agents Playground to test agents and bots that expose a local messaging endpoint. It simulates conversations without requiring a tunnel or Teams app and bot registration. Declarative agents aren't supported in this environment. For web content, run it locally and open it in your browser using http://localhost.
  • Locally hosted in Teams: Run your app's services locally and expose them through an HTTPS tunnel using Microsoft dev tunnels. Then create a Teams app package and upload it to Teams. Interact with the app in Teams while debugging its services locally. You can use IDE breakpoints and step debugging in both this setup and purely local testing.
  • Cloud-hosted in Teams: Host your app's services on an externally accessible server or cloud provider of your choice. Then create a Teams app package and upload it to Teams to validate the app against its cloud-hosted services.

The following sections explain how to configure each setup.

Note

For production-scale debugging and testing, we recommend that you follow your own company guidelines to ensure you are able to support testing, staging, and deployment through your own processes.

Use multiple manifests and packages to maintain separation between production and development services. For example, you might choose to register separate development and production bots and create appropriate packages to upload them in your testing environment. We also recommend that you upload and test your production package before submitting your app for publishing in our Microsoft Teams Store or distributing to customers.

Purely local

Use Microsoft 365 Agents Playground to test your agent's or bot's core logic, exchange messages, and preview Adaptive Cards in a browser. This workflow applies to agents and bots with a locally running messaging endpoint, not declarative agents. You can also use mock data and activity triggers to simulate supported Teams scenarios, such as a member joining a team. You don't need a Microsoft 365 developer tenant for anonymous local testing.

Note

Agents Playground simulates supported Teams activities and APIs, including roster calls, with mock data. It doesn't process your app manifest or reproduce every Teams feature. For supported scenarios and restrictions, see Agents Playground limitations. Test your app in the Teams client to validate real service integration and features that aren't supported in Agents Playground.

Before launching Playground, choose the channel and authentication settings for your local project:

  • To simulate Teams-specific activities, select the msteams channel. Agents Toolkit launches Playground with the emulator channel by default. Change it with the DEFAULT_CHANNEL_ID environment variable or use --channel-id msteams for a standalone launch. For more information, see Multiple channel support.
  • Agents Playground supports anonymous and authenticated testing. For anonymous testing, use your project's local development configuration. If your agent or bot requires authentication, configure Microsoft Entra ID app registrations for Playground and the agent or bot runtime. These identity configurations are distinct from the Teams app package and bot registration. For setup details, see Configure Agents Playground for authentication. Keep local development settings separate from production settings, and don't disable production authentication for local testing.

To debug an agent or bot project with Microsoft 365 Agents Toolkit in Visual Studio Code:

  1. Install the Agents Playground prerequisites.
  2. Open your agent or bot project. If it doesn't have an Agents Playground debug configuration, follow Debug an existing app with Agents Playground to configure it.
  3. Apply the channel and authentication settings described above to your local debug configuration. If you change environment variables after Playground starts, stop and restart the debug session to apply them.
  4. Set breakpoints in your agent's or bot's message or activity handlers.
  5. Open Run and Debug (Ctrl+Shift+D), select the Debug in Microsoft 365 Agents Playground configuration, and press F5. The configuration might include (Preview) in its name. Agents Playground opens in a browser.
  6. Send a message to your agent or bot, inspect its responses and Adaptive Cards, and step through your code when a breakpoint is reached. Use activity triggers to test events supported by the selected channel.

If you run your agent or bot runtime independently of Agents Toolkit, install and launch the standalone Playground as described in Test your agent locally in Microsoft 365 Agents Playground. Run the runtime locally and set Playground's --app-endpoint option to its actual messaging endpoint, using the port configured in your project.

Locally hosted

For HTTPS-based testing in Teams, the services your app uses must be publicly accessible over HTTPS. You can publish your code to the cloud or expose your app's locally running services with tunneling software. For a conversational capability, the agent or bot runtime runs locally, while you interact with the agent or bot through the Teams client over a public HTTPS tunnel.

Use Microsoft dev tunnels to create a public HTTPS address for your locally running service.

To create and host a dev tunnel:

  1. Install the devtunnel CLI for your operating system. For instructions, see Install dev tunnels.

  2. Start your local service and note the port where it listens.

  3. In a separate terminal, sign in, create a tunnel, configure its port, and start hosting it. The following example uses port 3978. Replace 3978 with your local service's port before running the commands.

    devtunnel user login
    devtunnel create --allow-anonymous
    devtunnel port create -p 3978
    devtunnel host
    

    The --allow-anonymous option lets Teams reach the tunnel without an interactive tunnel sign-in. You still need to sign in to host the tunnel.

    Caution

    Anonymous tunnel access makes your local endpoint publicly accessible. Use development services only, and keep your agent or bot's authentication enabled. Tunnel access settings don't replace application authentication.

  4. Copy the HTTPS service URL printed by devtunnel host, such as https://<tunnel-id>-3978.<region>.devtunnels.ms. Don't copy the inspection URL. Leave the tunnel running.

To let Teams reach your locally hosted services through the tunnel, update the URLs that point to those services to use the dev tunnel HTTPS address. Depending on your app's capabilities, these URLs may appear in your code, configuration files, or manifest.json. Preserve the required URL paths and leave unrelated URLs unchanged.

For an agent or bot built with Teams SDK, also update the messaging endpoint in its bot registration. This setting tells Teams where to deliver messages to the locally running agent or bot. Set it to the dev tunnel HTTPS address followed by /api/messages, for example, https://<tunnel-id>-3978.<region>.devtunnels.ms/api/messages. A conversational agent also uses a bot registration to configure message delivery.

To update an existing bot registration in Developer Portal for Teams:

  1. Go to Tools > Bot management and select your existing bot.
  2. Select Configure.
  3. Under Delivery method, select HTTPS endpoint, enter the dev tunnel HTTPS URL followed by /api/messages, and select Save.

For details, see Configure the agent's bot registration. If you manage an Azure Bot resource in the Azure portal instead, see Configure messaging endpoint.

Note

Creating a different tunnel changes its address. If the address changes, update the affected service URLs and the messaging endpoint in your existing bot registration before testing again. You don't need to create a new bot registration. If you haven't registered your agent or bot yet, see Register, install, and chat in Teams.

After updating these settings, keep the agent or bot runtime and the dev tunnel running. Upload and install the Teams app package that includes the agent or bot, then send it a message in Teams to verify connectivity and test Teams-specific functionality.

Cloud-hosted

You can use any externally addressable service to host your development and production code and their HTTPS endpoints. There's no expectation that your capabilities reside on the same service. We require all domains to be accessed from your Teams apps listed in the validDomains object in the manifest.json file.

Note

To ensure a secure environment, be explicit about the exact domain and subdomains you reference and those domains must be in your control. For example, *.azurewebsites.net is not recommended, however contoso.azurewebsites.net is recommended.

Load and run your experience

To load and run your experience within Teams, create a Teams app package and upload it into Teams. The package includes the app manifest that defines the app's capabilities; it doesn't contain the agent or bot runtime code. Packaging and uploading aren't required for testing in Agents Playground. Always test your Teams app in the Teams client before moving it to production. For more information, see:

Next step

See also