0

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);
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.