How to send message in teams channel with @mention in.net 6 using webhook
string userId = "xxxxx";
string userName = "xxxx";
string userPrincipalname = "xxxx";
var adaptiveCardPayload = new
{
type = "message",
attachments = new[]
{
new
{
contentType = "application/vnd.microsoft.card.adaptive",
content = new
{
type = "AdaptiveCard",
version = "1.0",
body = new[]
{
new
{
type = "TextBlock",
text = $"Hello <at>@{mentiontext}</at>, this is a message with an @mention!",
wrap = true
}
},
mentions = new[]
{
new
{
mentioned = new
{
user = new
{
id = userId,
displayName = userName,
userPrincipalName = userPrincipalname
}
},
mentionText = $"@{mentiontext}",
id = userId
}
}
}
}
}
};
var jsonPayload = System.Text.Json.JsonSerializer.Serialize(adaptiveCardPayload);
string responsess = await _connector.ExecutePostToMicroservice(uriBuilder.Uri, "Add new Team msg", jsonPayload, currentUserToken: CurrentUserToken);