Skip to main content

Best Practices

When sending messages using AI, Teams recommends a number of best practices to help with both user and developer experience.

AI-Generated Indicator​

When sending messages using AI, Teams recommends including an indicator that the message was generated by AI. This can be done by calling the .AddAIGenerated() method on outgoing messages. This will help users understand that the message was generated by AI, and not by a human and can help with trust and transparency.

var messageActivity = new MessageActivity
{
Text = "Hello!",
}.AddAIGenerated();

AI Generated Indicator

Gather feedback to improve prompts​

AI Generated messages are not always perfect. Prompts can have gaps, and can sometimes lead to unexpected results. To help improve the prompts, Teams recommends gathering feedback from users on the AI-generated messages. See Feedback for more information on how to gather feedback.

This does involve thinking through a pipeline for gathering feedback and then automatically, or manually, updating prompts based on the feedback. The feedback system is an point of entry to your eval pipeline.

Citations​

AI generated messages can hallucinate even if messages are grounded in real data. To help with this, Teams recommends including citations in the AI Generated messages. This is easy to do by using the AddCitation method on the message.

warning

Citations are added with a position property. This property value needs to also be included in the message text as [<position>]. If there is a citation that's added without the associated value in the message text, Teams will not render the citation

var messageActivity = new MessageActivity
{
Text = result.Content,
}.AddAIGenerated();

for (int i = 0; i < citedDocs.Length; i++)
{
messageActivity.Text += $"[{i + 1}]";
messageActivity.AddCitation(i + 1, new CitationAppearance
{
Name = citedDocs[i].Title,
Abstract = citedDocs[i].Content
});
}

AI Generated Indicator

Suggested actions​

Suggested actions help users with ideas of what to ask next, based on the previous response or conversation. Teams recommends including suggested actions in your messages. You can do that by using the WithSuggestedActions method on the message. See Suggested actions for more information on suggested actions.

var message = new MessageActivity
{
Text = result.Content,
}.WithSuggestedActions(
new Microsoft.Teams.Api.SuggestedActions() {
To = [context.Activity.From.Id],
Actions = [
new Microsoft.Teams.Api.Cards.Action(ActionType.IMBack) {
Title = "Thank you!",
Value = "Thank you very much!"
}
]
}).AddAIGenerated();
await context.Send(message);