Pages Menu
TwitterRssFacebook

Posted by on Apr 2, 2024 in Microsoft 365 Copilot, Microsoft Teams

How to: Build and Deploy the Easiest – but most Impactful – Plugin for Microsoft 365 Copilot

How to: Build and Deploy the Easiest – but most Impactful – Plugin for Microsoft 365 Copilot

I wanted to put together a guide for people starting out building their first plugin for Copilot.

I didn’t want people to feel like they HAD to be seasoned developers to be able to build something.

I wanted to show how straightforward it was.

I also wanted to create something useful, not just another Hello World demo. I believe that this plugin genuinely has value and I’m using it daily.

In this guide, I start with an existing sample for a Microsoft Teams messaging extension, and then modify it in order to create a plugin for Microsoft 365 Copilot.

Everything I did is in this video, which is just over 30 minutes. That means you can follow the video – even if you’re not a developer – and have this running today.

If you’re still not sure, here are the high-level steps, with stills from the video. If you’ve already built messaging extensions for Microsoft Teams and are somewhat familiar with development & deployment then these screenshots might be all you need.

Communication Manifesto

Here’s what the app does. A Communication Manifesto is a set of rules that you create for yourself and that define how you should communicate with others. In this case, how you send email or Teams messages. The actual rules are up to you, but for instance, mine is:

  • Be kind.
  • Be honest.
  • Be open.
  • Be inclusive.
  • Be respectful.
  • If you criticize, do it constructively.
  • Keep emails short, under 200 words.
  • Use emojis to convey tone.

Having a list like this is all well and good, but actually using it every day and constantly referring to it is much, much harder. Until now, I would review the list every year, and sometimes print it out and put it on the wall in front of me, but I never had a good way of measuring whether or not I was actually managing to stick to my manifesto.

“I can get Copilot to call me out on things I’m doing that don’t align with how I said I wanted to work. That’s really powerful.”

Copilot can change that. Because Copilot has sight of my emails, I can combine the information about the manifesto with the information about my sent emails (or Teams messages, but I use email in this demo) I can get Copilot to call me out on things I’m doing that don’t align with how I said I wanted to work. That’s really powerful. That’s what we do in this demo.

The exciting thing about using messaging extensions as plugins is that they are an easy way to get Copilot to invoke code. In the AI space, this is known as Actions, and in some ways, Microsoft 365 Copilot is slightly ahead of the rest of the Azure AI game here with their built-in support for Actions via messaging extensions.

You could use this to invoke API calls and book flights, authorise holiday, turn lights on, send emails: really, any action you can perform in code. I’m choosing a deliberately simple example of returning a small piece of hard-coded information because I want to present the most simple sample I can. However, once you have this running you can easily expand out the capabilities of your plugin.

Code Walkthrough

I start off by creating a new Microsoft Teams messaging extension based on the Custom Search Results sample:
[jump to this point in the video]

This sample includes a simple messaging extension which search the NodeJS repository when text is entered via a search box. Choosing an entry builds an adaptive card with the name and description of the repository and returns it to the compose box:
[jump to this point in the video]

The first change I make is to replace this with code that always returns a communication manifesto. In the searchApp.js file, I remove the API call, the loop block and rewrite the data used to build the card to be hardcoded to the values of the manifesto. (In a real application, the manifesto would be built by the user, stored somewhere and retrieved here)

The new code looks like this (lines 19-27 only):

const template = new ACData.Template(helloWorldCard);
    const card = template.expand({
      $root: {
        name: "Your Communication Manifesto",
        description:
          "1. Be kind. 2. Be honest. 3. Be open. 4. Be inclusive. 5. Be respectful. 6. If you criticize, do it constructively. 7. Keep emails short, under 200 words. 8. Use emojis to convey tone.",
      },
    });
    const preview = CardFactory.heroCard("Your Communication Manifesto");

Testing this code out, you can see that now the manifesto is returned, regardless of the search string (because we never use the input for anything). It’s not the prettiest, but it doesn’t really matter: Copilot will still be able to read and use it:
[jump to this point in the video]

The other set of changes we need to make are to the manifest.json file. This is where we describe our plugin, so that Copilot knows what it does, can choose to invoke it at the right time, and knows how to populate the parameters required. What you write in your manifest for Copilot is really important, and I made a whole video about it:

For this project I replaced the name, description, command name, command description and parameter name and description with as much information as I could. If you find that your plugin isn’t being chosen by Copilot when you want it to, make sure this work is done to the highest standard possible:
[jump to this point in the video]

I used Teams Toolkit for Visual Studio Code to provision the resources needed to run this code in Microsoft Azure:
[jump to this point in the video]

Once the components were provisioned, I deployed the code to them, generated a ZIP file for the manifest, and side-loaded it in my Microsoft Teams client.

This meant that in Copilot chat for Microsoft Teams my new app was shown in the plugins list. (twice for me because I’d previously built one). It’s a good tip to know that side-loaded apps show in the plugin list as well as fully published apps:
[jump to this point in the video]

Finally, it’s time to put our plugin to the test.

I asked it to look at emails that I’d sent in the past 3 days, and pull out any that didn’t align to my communication manifesto. As you can see, it didn’t find any. This is a Good Thing – but I’ll keep asking it every few days just to make sure I’m not sending any emails I shouldn’t be!
[jump to this point in the video]

Written by Tom Morgan

Tom is a Microsoft Teams Platform developer and Microsoft MVP who has been blogging for over a decade. Find out more.
Buy the book: Building and Developing Apps & Bots for Microsoft Teams. Now available to purchase online with free updates.

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.