Enhance AI-generated bot messages
AI label, citation, feedback buttons, and sensitivity label in your bot’s messages improve user engagement and foster transparency and trust.
- AI label enables users to identify that the message was generated using AI.
- Citation enables users to refer to the source of the bot message through in-text citations and references.
- Feedback buttons enable users to provide positive or negative feedback to the bot messages.
- Sensitivity label enables users to understand the confidentiality of the bot message.
The following screenshots show how bot messages can be enhanced with AI label, citation, feedback buttons, and sensitivity label:
Note
- AI label, citation, feedback button, and sensitivity label are available in public developer preview for one-on-one and group chats, but aren't supported in channels.
- AI label, citation, feedback button, and sensitivity label are available only Teams web, desktop, and mobile clients.
- AI label, citation, feedback buttons, and sensitivity label are available in Government Community Cloud (GCC), GCC High, and Department of Defense (DOD) environments.
AI label
An AI label on your bot message indicates it’s generated by AI. While AI-powered bots using Large Language Models (LLMs) are generally reliable, the label helps prevent confusion about the information's source.
Add AI label
If you're using Teams AI library to build yout bot, AI label is automatically enabled for all AI-powered bot messages in the ai
module within the PredictedSayCommand
action. For more information, see AIEntity interface.
If you're using Microsoft Bot Framework SDK to build your bot, include additionalType
under the entities
array of the message
entity object. Following is an example code snippet:
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
}
]
});
Property | Type | Required | Description |
---|---|---|---|
additionalType |
Array | Yes | Enables the AI label in the bot message. Allowed value: AIGeneratedContent . |
After adding an AI label, your bot’s message shows an "AI generated" label next to the bot’s name. A disclaimer hovers stating, "AI-generated content may be incorrect." The AI label and disclaimer cannot be customized for AI-powered bots.
Note
The AI generated label is available only when you send a new message using SendActivity
. If you update a message using UpdateActivity
, the Edited label is added.
Error handling
Error code | Description |
---|---|
400 | Multiple root message entities found under entities array. |
400 | Error parsing message entity from entities array. |
Citations
Citing sources in bot messages helps users ask follow-up questions or conduct independent research. Cite data sources like files, messages, emails, and work items to provide valuable insights. Citations are crucial for bots using techniques like Retrieval-Augmented Generation (RAG).
Citations to your bot message include in-text citation, details of citation reference, and sensitivity label for the content referenced.
- In-text citation denotes the citation numbers added to the bot message in the [#] format, each corresponding to a reference. A citation can be inserted anywhere within the text.
- Details of citation reference include the title, keywords, abstract, hyperlink, and sensitivity information. References appear as pop-up windows for each in-text citation.
- Sensitivity labels to citation indicate the confidentiality of the citation content referenced and aren't added automatically. To add a sensitivity label for a citation, see add sensitivity label.
Note
- A maximum of 10 citation are displayed in a message.
- Adaptive Cards aren't rendered in the citation pop-up window. However, Adaptive Cards can be rendered in the bot's message.
Add citations
If you're using Teams AI library to build your bot, citations are added to an AI-powered bot message automatically through PredictedSayCommand
action. You can also modify the PredictedSayCommand
action to add citations to your bot message. For more information, see ClientCitation interface.
If you're using Bot Framework SDK to build your bot, include citation
under the entities
array. Following is an example code snippet:
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
keywords: ["keyword 1", "keyword 2", "keyword 3"], // Appears in the citation pop-up window
},
},
],
},
],
})
Property | Type | Required | Description |
---|---|---|---|
citation |
Object | Yes | Details of the citation. |
citation.@type |
String | Yes | Object of the citation. Allowed value: Claim . |
citation.position |
Integer | Yes | Displays the citation number. The values are limited to less than eight. |
citation.appearance |
Object | Yes | Information about the appearance of the citation. |
citation.appearance.@type |
String | Yes | Object of the citation appearance. Allowed value: DigitalDocument . |
citation.appearance.name |
String | Yes | Title of the referenced content. |
citation.appearance.url |
String | No | URL of the referenced content. |
citation.appearance.abstract |
String | No | Extract of the referenced content and is limited to less than 1,000 characters. |
citation.appearance.keywords |
Array | No | Keywords from the referenced content. You can't add more than three keywords. |
After you enable citations, the bot message includes in-text citations and references. The in-text citations display the reference details when users hover over the citation.
Error handling
Error code | Description |
---|---|
400 | Multiple root message entities found under entities array |
400 | Error parsing message entity from entities array |
400 | Bot message with more than 10 citations |
400 | The appearance object is empty |
400 | Error while parsing citation entity with ID: X |
Feedback buttons
Feedback buttons in bot messages are essential for tracking user engagement, identifying errors, and gaining insights into bot performance. These insights enable targeted enhancements of the bot’s conversational capabilities. Enable feedback buttons to allow users to like or dislike messages and provide detailed feedback.
When the user selects a feedback button, a respective feedback form appears based on the user's selection.
Feedback buttons are located at the footer of the bot’s message and include a 👍 (thumbs up) and a 👎 (thumbs down) button that the user to choose. You can collect feedback on bot responses from one-on-one and group chats.
Add feedback buttons
For a bot built using Teams AI library, Teams enables feedback buttons to all bot messages when enable_feedback_loop
is set to true
in the ai
module.
export const app = new Application<ApplicationTurnState>({
ai: {
planner: planner,
enable_feedback_loop: true
},
For more information, see the const app variable.
After you enable feedback buttons, all SAY
commands from the bot have feedbackLoopEnabled
automatically set to true
in the channelData
object.
To enable feedback buttons in a bot built using Bot Framework SDK, add a channelData
object in your bot message and set the value of feedbackLoopEnabled
to true
.
await context.sendActivity({
type: ActivityTypes.Message,
text: `Hey! I'm a friendly AI bot!`,
channelData: {
feedbackLoopEnabled: true // Enable feedback buttons
},
});
Property | Type | Required | Description |
---|---|---|---|
feedbackLoopEnabled |
Boolean | Yes | Enables feedback buttons in the bot's message |
Handle feedback
The bot receives user input from the feedback form through a bot invoke flow. For bots built using Teams AI library, the bot invoke request is automatically handled. To manage feedback, use the app.feedbackLoop method to register a feedback loop handler when the user provides feedback.
app.feedbackLoop(async (context, state, feedbackLoopData) => {
// custom logic here...
});
For more information, see the asynchronous callback function.
For a bot built using Bot Framework SDK, you must have an onInvokeActivity
handler to process the feedback. Ensure that you return a status code 200
with an empty JSON object as a response.
The following code snippet shows how to handle feedback received in a bot invoke and return a response with the status code 200
:
public async onInvokeActivity(context: TurnContext): Promise<InvokeResponse> {
try {
switch (context.activity.name) {
case "message/submitAction":
console.log('Your feedback is ' + JSON.stringify(context.activity.value))
// Your feedback is {"actionName":"feedback","actionValue":{"reaction":"like","feedback":"{\"feedbackText\":\"This is my feedback.\"}"}}
return CreateInvokeResponse(200, {});
default:
return {
status: 200,
body: `Unknown invoke activity handled as default- ${context.activity.name}`,
};
}
} catch (err) {
console.log(`Error in onInvokeActivity: ${err}`);
return {
status: 500,
body: `Invoke activity received- ${context.activity.name}`,
};
}
}
export const CreateInvokeResponse = (
status: number,
body?: unknown
): InvokeResponse => {
return { status, body };
};
Store the feedback by saving message IDs and content of messages your bot sends and receives. When your bot gets an invoke request with feedback, match the message ID with the corresponding feedback.
Note
Teams doesn't store or process feedback. It doesn't provide an API or a storage mechanism.
If a user uninstalls your bot and still has access to the bot chat, Teams removes the feedback buttons from the bot messages to prevent the user from providing feedback to the bot.
Error handling
Error code | Description |
---|---|
400 | message/submitAction invoke response isn't empty. |
Sensitivity label
Bot responses might contain confidential information or be accessible only to certain individuals within the organization. Add a sensitivity label to help users identify the confidentiality of a message, enabling them to exercise caution when sharing it.
Note
Add a sensitivity label to your bot's messages only when they contain sensitive information.
Add sensitivity label
For bots built using Teams AI library, sensitivity label can be added through PredictedSayCommand
action. For more information, see SensitivityUsageInfo interface.
For bots built using Bot Framework SDK, add a sensitivity label to your bot message by modifying the message to include usageInfo
in the entities
object.
The following code snippet shows how to add sensitivity labels to both bot messages and citation reference:
await context.sendActivity({
type: ActivityTypes.Message,
text: `Hey, I'm a friendly AI bot. This message is generated through AI [1]`,
entities: [
{
type: "https://schema.org/Message",
"@type": "Message",
"@context": "https://schema.org",
usageInfo: {
"@type": "CreativeWork",
name: "Sensitivity title",
description: "Sensitivity description",
},
},
],
});
Property | Type | Required | Description |
---|---|---|---|
usageInfo.@type |
String | Yes | Enables the sensitivity label in the bot message. |
citation.usageInfo.@id |
String | Yes | Enables the sensitivity label in the citation reference. It's required when adding a sensitivity label to citation reference. |
usageInfo.name |
String | Yes | Specifies the title of the sensitivity label. |
usageInfo.description |
String | No | Specifies the pop-up window message that appears when a user hovers over the sensitivity label. |
After adding the sensitivity label, your bot message displays a shield icon. Users can hover over the icon to see a disclaimer about the message's sensitivity.
Error handling
Error code | Description |
---|---|
400 | Multiple root message entities found under entities array |
400 | Error parsing message entity from entities array |
400 | Citation level usageInfo.@id value doesn't match the message level usageInfo.@id in at least one instance |
400 | There are multiple citation-level usageInfo properties with the same @id , but their name and description properties are different. |
Modify PredictedSayCommand
For a bot built using Teams AI library, the PredictedSayCommand
provides control on how AI label, citation, feedback button, and sensitivity label are added to the bot's activity. Following is the code snippet to modify PredictedSayCommand
:
app.ai.action<PredictedSayCommand>(AI.SayCommandActionName, async (context, state, data, action) => {
// custom logic here...
await context.sendActivity(data.content);
return "";
});
For more information about PredictedSayCommand
, see PredictedSayCommand interface.
Code sample
Sample name | Description | Node.js | C# |
---|---|---|---|
Teams conversation bot | This sample app displays the AI label, citation, feedback buttons, and sensitivity label in messages. | View | NA |
Azure OpenAI on your data | This conversational bot uses Teams AI library and contains the AI label, feedback buttons, sensitivity label, and citation in its generated messages. | NA | View |
See also
Platform Docs