· 5 min read

Create Microsoft 365 Copilot declarative agents with Teams Toolkit CLI

Are you looking to build Microsoft 365 Copilot agents? you can either use Teams Toolkit Visual Studio Code Extension OR use the Teams Toolkit CLI by quickly scaffolding them with a command and some good news, in the recent change to Microsoft Copilot licensing you can now do this for FREE! 🎉🥳

Are you looking to build Microsoft 365 Copilot agents? you can either use Teams Toolkit Visual Studio Code Extension OR use the Teams Toolkit CLI by quickly scaffolding them with a command and some good news, in the recent change to Microsoft Copilot licensing you can now do this for FREE! 🎉🥳

I’m quite excited by the recent changes and am personally exploring aspects of Teams Toolkit with Microsoft 365 Copilot extensibility. In this post, I will use the CLI to explore creating a framework to build these solutions more quickly or incorporate them as part of a future script.

If you prefer a more interactive experience, you can create an agent using Visual Studio Code and the Teams Toolkit Extension.

What is the Teams Toolkit CLI

This is a command line utility that you can use to create, deploy, setup and manage Teams Toolkit based Microsoft Teams apps using the terminal. Useful for quickly setting up an app or continuous deployment scenarios.

Setup

For initial starting point, lets assume you are running this on your developer machine, using Node v18.20.4 (version I am running at time of writing this post) installed with NVM to allow switching of versions. To get this installed quickly, this winget command can get this installed:

winget install -e --id CoreyButler.NVMforWindows
nvm install v18.20.4

Using Teams Toolkit CLI (at time of writing this is v3.0.7), installable from NPM registry using npm install -g @microsoft/teamsapp-cli to confirm run:

teamsapp -h

What license do I Need?

Interestingly Microsoft has changed the game recently, and for declarative agents you can create this now using the free Microsoft 365 Copilot Chat license, see this post for details: Copilot for all: Introducing Microsoft 365 Copilot Chat | Microsoft Blog which opens up to develop a range of agents for Microsoft 365 Copilot - in the above post, there is a image that describes what you can and cannot do with the extensibility.

So what can you create

To get the list of templates, run teamsapp new -h you can create:

Result

TemplateDescription
Custom Search Results
id: search-message-extension
Display data directly in Teams search results from search or the chat area
Declarative Agent
id: declarative-agent
Create your own agent by declaring instructions, actions, & knowledge to suit your needs.
Basic AI Chatbot
id: custom-copilot-basic
Build a basic AI chatbot in Teams
Chat With Your Data
id: custom-copilot-rag
Expand AI bot’s knowledge with your content to get accurate answers to your questions
AI Agent
id: custom-copilot-agent
Build an AI agent in Teams that can make decisions and perform actions based on LLM reasoning

…Options omitted for brevity

As you may notice, these options are related to Copilot extensibility so let’s see one example of these templates.

I want just a declarative agent what are my options

So lets get going creating a Microsoft 365 Copilot declarative agent in non-interactive mode:

teamsapp new --capability "declarative-agent" --app-name "My New Declarative Agent" -folder "MyAgent" --interactive false --debug --verbose --with-plugin no 

Note: Do not specify the language, there is no template and no language is used in the template as the agent is JSON based. I found out this the hard way.

Of course, change the folder and app name according to what you want to create.

I have used --debug and ```—verbose“ options to see what happens when this command runs, but at the end, I get a scaffolded application, ready for me to start to tailor to my requirement.

Creating an agent with the Terminal

Go to the folder and launch Visual Studio Code:

cd "MyAgent/My New Declarative Agent"
code .

Opening the agent with Visual Studio Code

(I opened the Readme.md in the screenshot 😉)

What is next after running this command and do you have examples.

After this, you can customise the application to your scenario. If you want some examples to take inspiration from, check out my blog post: Building a blog post helper agent for Microsoft 365 Copilot | pkbullock.com

Alternatively, you can explore the Microsoft 365 Community (PnP) Copilot Pro Dev scenarios: Microsoft 365 Copilot samples | Sample Solution Gallery

How do I deploy?

You can deploy an app using Teams Toolkit CLI options:

teamsapp auth login m365

If you are using other template options, you also need to login into Azure to provision the services required to run the app, but for putely declarative agents this is not needed. Follow the login process to Microsoft 365 then run:

teamsapp install

Deploying the agent to Microsoft 365

and to see this in Microsoft Copilot navigate to https://m365.cloud.microsoft/ in your tenant (for this example, I am using the FREE Microsoft 365 Chat experience):

The vanilla agent working in Microsoft 365 Copilot Chat

Conclusion

This is only a very small example of what you can do with the Teams Toolkit CLI, as there are other templates, API options, and Custom Engine Agent options you can use to very quick create the scaffolding of these applications. Declarative agents are not hard to get going which leads you to think about the scenarios can potentially fulfil using these new capabilities.

I hope that you can get started and build something cool, why not submit a PR to the PnP Copilot Pro Dev repository to share with the community, all contributions welcomed!

Resources

The following resource could be useful for you to learn further:

Enjoy!

Back to Blog