Skip to content

Lab BMA4 - Bring your agent to Microsoft 365 Copilot

Your agent already runs in Microsoft Teams. Bringing it into Microsoft 365 Copilot is a manifest change, not a code change โ€” you declare the agent as a custom engine agent and Microsoft 365 Copilot surfaces it alongside every other agent the user has.

Note

If you want to start directly from this lab without completing the previous ones, you can download the agent's complete source code (as it is at the end of the previous lab) from here. Remember to add your own AIServices settings to appsettings.json as described in "Lab BMA3".

Lab objectives

By the end of this lab you will be able to:

  • Declare a custom engine agent in the app manifest
  • Add conversation starters that help users get going
  • Test your agent inside Microsoft 365 Copilot

Exercise 1: Declare the agent for Microsoft 365 Copilot

Stop debugging first

Close the previous debugging session before starting this exercise.

Step 1: Update the manifest schema

Open M365Agent/appPackage/manifest.json and update the schema and version:

"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.22/MicrosoftTeams.schema.json",
"manifestVersion": "1.22",

Step 2: Add conversation starters and the copilotAgents block

Replace the bots section with the following, which adds a command list and the copilotAgents declaration:

"bots": [
  {
    "botId": "${{BOT_ID}}",
    "scopes": [
      "personal",
      "team",
      "groupChat"
    ],
    "supportsFiles": false,
    "isNotificationOnly": false,
    "commandLists": [
      {
        "scopes": [ "personal", "team", "groupChat" ],
        "commands": [
          {
            "title": "Emergency and Mental Health",
            "description": "What's the difference between Northwind Standard and Health Plus when it comes to emergency and mental health coverage?"
          },
          {
            "title": "PerksPlus Details",
            "description": "Can I use PerksPlus to pay for both a rock climbing class and a virtual fitness program?"
          },
          {
            "title": "Contoso Electronics Values",
            "description": "What values guide behavior and decision making at Contoso Electronics?"
          }
        ]
      }
    ]
  }
],
"copilotAgents": {
  "customEngineAgents": [
    {
      "id": "${{BOT_ID}}",
      "type": "bot"
    }
  ]
},

The copilotAgents.customEngineAgents block is what tells Microsoft 365 to expose this agent inside Copilot Chat. The commandLists entries become the conversation starters users see before their first message.


Exercise 2: Test your agent in Microsoft 365 Copilot

Step 1: Upload the app package

Select Start or press F5 to begin debugging. When Microsoft Teams opens in your browser, dismiss the app pop-up and instead select Apps > Manage your apps > Upload an app, then Upload a custom app.

Select ...\ContosoHRAgent\M365Agent\appPackage\build\appPackage.local.zip.

Step 2: Open the agent in Microsoft 365 Copilot

When the app pop-up appears, select Add. This time you'll also see Open with Copilot โ€” select it.

Choose ContosoHRAgentlocal from the agent list in Microsoft 365 Copilot Chat.

Step 3: Verify the behavior matches

Select one of the conversation starters, then ask a follow-up question.

Expected result:

  • The conversation starters you defined in the manifest appear before the first message.
  • Answers are grounded in your HR documents, exactly as they were in Teams.
  • Responses stream in and include the running message count.

CONGRATULATIONS!

๐ŸŽ‰ You've built a custom engine agent with the Microsoft 365 Agents SDK, Microsoft Foundry, and Microsoft Agent Framework!

Across this path you learned how to:

  • Create and ground an agent in Microsoft Foundry with instructions and File Search
  • Scaffold a Microsoft 365 Agents SDK host and test it locally
  • Resolve a published Foundry agent as an AIAgent with Microsoft Agent Framework
  • Stream responses and citations, and persist an AgentSession for conversation memory
  • Deliver the same agent to Microsoft Teams and Microsoft 365 Copilot

Where to go next

Want to build the agent's reasoning and grounding yourself instead of in the portal? Continue with Path 2 โ€” Start with Agent Framework, where you'll ground an agent with Foundry IQ and the Copilot Retrieval API.

Resources