Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI labels - Csharp-Updating code #1271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions samples/bot-conversation/csharp/AppManifest/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"name": {
"short": "TeamsConversationBot",
"full": "TeamsConversationBot"
"full": "This sample showcases usage of various conversation events for teams bot."
},
"description": {
"short": "TeamsConversationBot",
"full": "TeamsConversationBot"
"short": "This sample showcases usage of various conversation events for teams bot.",
"full": "This sample showcases usage of various conversation events for teams bot for both personal and teams scope."
},
"accentColor": "#FFFFFF",
"bots": [
Expand Down Expand Up @@ -58,6 +58,22 @@
{
"title": "MessageAllMembersUsingAadId",
"description": "Send 1 to 1 message to all members of the current conversation using their AADId"
},
{
"title": "AI label",
"description": "AI label added to your bot message specifies that the message is generated by AI"
},
{
"title": "sensitivity",
"description": "Sensitivity label added to your bot message specifies the confidentiality of a message"
},
{
"title": "Feedback buttons",
"description": "Feedback buttons that helps to provide feedback for a bot message"
},
{
"title": "citation",
"description": "Used to cite the sources of the bot message"
}
]
}
Expand All @@ -83,7 +99,7 @@
}
},
"validDomains": [
"${{BOT_DOMAIN}}",
"*.ngrok-free.app"
"*.ngrok-free.app",
"${{BOT_DOMAIN}}"
]
}
54 changes: 54 additions & 0 deletions samples/bot-conversation/csharp/Bots/TeamsConversationBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using System.Collections.Concurrent;
using System.Collections;
using Microsoft.AspNetCore.Http;
using static System.Net.Mime.MediaTypeNames;

namespace Microsoft.BotBuilderSamples.Bots
{
Expand Down Expand Up @@ -67,6 +69,10 @@ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivi
await CheckReadUserCount(turnContext, cancellationToken);
else if (text.Contains("reset"))
await ResetReadUserCount(turnContext, cancellationToken);
else if (text.Contains("label"))
await addAILabel(turnContext, cancellationToken);
else if (text.Contains("feedback"))
await addFeedbackButtons(turnContext, cancellationToken);
else
await CardActivityAsync(turnContext, false, cancellationToken);
}
Expand All @@ -82,6 +88,42 @@ protected override async Task OnTeamsMembersAddedAsync(IList<TeamsChannelAccount
}
}

private async Task addAILabel(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
await turnContext.SendActivityAsync(
new Activity
{
Type = ActivityTypes.Message,
Text = "Hey I'm a friendly AI bot. This message is generated via AI",
Entities = new List<Entity>
{
new Entity
{
Type = "https://schema.org/Message",
Properties = JObject.FromObject(new Dictionary<string, object>
{
{ "@type", "Message" },
{ "@context", "https://schema.org" },
{ "additionalType", new List<string> { "AIGeneratedContent" } }
})
}
}
}
);
}

private async Task addFeedbackButtons(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
await turnContext.SendActivityAsync(
new Activity
{
Type = ActivityTypes.Message,
Text = "This is an example for sensitivity label that help users identify the confidentiality of a message",
ChannelData = new { feedbackLoopEnabled = true },
}
);
}

/// <summary>
/// Checks the count of members who have read the message sent by MessageAllMembers command
/// </summary>
Expand Down Expand Up @@ -199,6 +241,18 @@ private async Task CardActivityAsync(ITurnContext<IMessageActivity> turnContext,
Type = ActionTypes.MessageBack,
Title = "Reset read count",
Text = "reset"
},
new CardAction
{
Type = ActionTypes.MessageBack,
Title = "AI label",
Text = "label"
},
new CardAction
{
Type = ActionTypes.MessageBack,
Title = "Feedback buttons",
Text = "feedback"
}
}
};
Expand Down
21 changes: 21 additions & 0 deletions samples/bot-conversation/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,27 @@ You can interact with this bot in Teams by sending it a message, or selecting a
- Message is restored
![message-undelete](Images/messageUndelete.png)

7. **Format AI bot messages**
- Consists features such as citations, feedback buttons, and sensitivity label that enables better user engagement

- `AI label` - enables user to identify that the message was generated using AI.
![AI-label](Images/AI-label.png)

- `Citations` - enables user to refer to the source of the bot's message through in-text citations and the reference.
![Citations](Images/softDeleteMessage.png)

- `Feedback buttons` - enables user to provide positive or negative feedback based on their experience.
![Feedback-buttons](Images/Feedback-buttons.png)

![Feedback-buttons1](Images/Feedback-buttons1.png)

![Feedback-buttons2](Images/Feedback-buttons2.png)

![Feedback-buttons3](Images/Feedback-buttons3.png)

- `Sensitivity label` - enables user to understand the confidentiality of the bot's message.
![Sensitivity-label](Images/Sensitivity-label.png)

You can select an option from the command list by typing ```@TeamsConversationBot``` into the compose message area and ```What can I do?``` text above the compose area.

## Deploy the bot to Azure
Expand Down