Pages Menu
TwitterRssFacebook

Posted by on Jan 13, 2025 in Bot Framework, Microsoft Teams

Microsoft makes it easier for bot developers with built-in AI labels, citations, feedback & sensitivity

Microsoft makes it easier for bot developers with built-in AI labels, citations, feedback & sensitivity

Good luck making a bot these days that doesn’t includes some element of generative AI to improve answers to users.

Back in April 2024, Microsoft updated the Teams Store validation guidance for anyone who wanted to publish their apps to the Microsoft Teams App Store, telling developers that they needed to:

  • tell users when content is AI-generated, and
  • provide a way for users to report inappropriate content,

among other things.

At the time, I wrote:

“…there is some scope for Microsoft to make things even easier for developers, such as by allowing them to signify when sending a message respond whether it contains AI-generated content and then rendering a disclaimer message in the UI automatically. This would mean ISV-built applications would look similar to Copilot Chat and users would quickly learn to check in the same place for a consistent message about AI.”

Well.. now it looks like they have!

There’s a new page in Microsoft Learn with the title “Enhance AI-generated bot messages” which gives details of various different ways in which developers can add useful meta data to the messages they send.

There are 4 new types of information developers can add: AI labels, Citations, Feedback buttons, and Sensitivity labels.

AI Labels

These are the little “AI generated” pills you see attached to Copilot chat messages, and elsewhere in Microsoft 365 that uses generative AI to produce content. You can now add these to your own messages, with a simple property on the sendActivity function.

If you’re using Teams AI library, this is already being done for you, this is really for more traditional solutions built using the Bot Framework SDK

await context.sendActivity({
  type: ActivityTypes.Message,
  text: `Hey! I'm a friendly AI bot. This message is generated by AI.`,
  entities: [
    {
     type: "https://schema.org/Message",
     "@type": "Message",
     "@context": "https://schema.org",
     additionalType: ["AIGeneratedContent"], // Enables AI label
    }
  ]
});

Citations

Again, if you’re using Teams AI library, you already have citations and probably aren’t sure what the fuss is about. For everyone else though, you can pass citation information when sending a message and it will render in the same format:

await context.sendActivity({
  type: ActivityTypes.Message,
  text: `Hey I'm a friendly AI bot. This message is generated through AI [1]`, // cite with [1],
  entities: [
  {
    type: "https://schema.org/Message",
    "@type": "Message",
    "@context": "https://schema.org",
    citation: [
    {
      "@type": "Claim",
      position: 1, // Required. Must match the [1] in the text above
      appearance: {
        "@type": "DigitalDocument",
        name: "AI bot", // Title
        url: "https://example.com/claim-1", // Hyperlink on the title
        abstract: "Excerpt description", // Appears in the citation pop-up window
        text: "{\"type\":\"AdaptiveCard\",\"$schema\":\"http://adaptivecards.io/schemas/adaptive-card.json\",\"version\":\"1.6\",\"body\":[{\"type\":\"TextBlock\",\"text\":\"Adaptive Card text\"}]}", // Appears as a stringified Adaptive Card
        keywords: ["keyword 1", "keyword 2", "keyword 3"], // Appears in the citation pop-up window
        encodingFormat: "application/vnd.microsoft.card.adaptive",
        image: {
          "@type": "ImageObject",
          name: "Microsoft Word"
        },
       },
      },
    ],
  },
],
})

Feedback buttons

There’s a little bit more work here, but it’s still less work than rolling your own, and worth it to give your app a familiar look and feel.

Firstly, you enable feedback buttons when sending messages, as part of channelData:

await context.sendActivity({
  type: ActivityTypes.Message,
  text: `Hey! I'm a friendly AI bot!`,
  channelData: {
    feedbackLoop: { // Enable feedback buttons
        type: "custom"
  },
});

However, to actually get the feedback when it’s sent, you need to extend your onInvokeAction (or make one if you don’t have it already) and listen for the message/SubmitAction activity. For the JSON payload sent as part of this activity, the actionName value will be "feedback", and actionValue will contain both the reaction and any feedback, like this:

{
    "actionName": "feedback",
    "actionValue": {
        "reaction": "like",
        "feedback": "{\"feedbackText\":\"This is my feedback.\"}"
    }
}

Sensitivity Labels

Sensitivity labels are sometimes shown next to the “AI generated” labels and signifiy that the data is confidential, internal only or similar.

Developers can now provide their own wording here, which I’m sure will be welcomes by enterprises everywhere.

The implementation is slightly different between Teams AI library and the Bot Framework SDK.

Teams AI library users can specify this in the PredictedSayCommand, look for the SensitivityUsageInfo property of the AIEntity type.

For Bot Framework users, it’s another extension to the sendActivity command:

await context.sendActivity({
  type: ActivityTypes.Message,
  text: `This message is generated through AI.`,
  entities: [
    {
      type: "https://schema.org/Message",
      "@type": "Message",
      "@context": "https://schema.org",
      usageInfo: {
        "@type": "CreativeWork",
        name: "Sensitivity title",
        description: "Sensitivity description",
      },
    },
  ],
});

You should start using these.

If you’re producing AI-infused answers in your bots, then I really think you should look into adding these markers in, even if you’re already passing this sort of information to users. The reason is that it will create a consistent look and feel to users for how AI-infused interactions look, and give them tools they are familiar with – the AI badge, the feedback buttons, the citations with the super-script numbers etc. It’s a common look and feel: meaning that users are comfortable with your application and need less training.

I’m really pleased that Microsoft have added these capabilities, and implemented them in a way that is so easy to add to existing solutions. There’s really no reason not to!

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.