1
votes

I am trying to mention a user in ms teams channel with the help of an adaptive card but there is no proper documentation for it and examples of the solution that is given here is not working? Has anybody has tried it please help with it

2

2 Answers

1
votes

Are you using JS? I just posted a similar question, but it has a working solution for Users. I'm attempting to mention a bot though. Here is the post I just submitted

CardFactory.adaptiveCard({
  $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
  type: 'AdaptiveCard',
  msteams: {
    entites: [
      {
        type: 'mention',
        text: '<at>(username)</at>',
        mentioned: {
          id: <userID>,
          name: <username>,
          role: 'user'
        }
      }
    ]
  }
  body: [
    {
      type: 'TextBlock',
      text: '<at>(userName)</at>',
    }
  ]
});

This is the example I give

0
votes

I used to use html to format cards in conversation bot. I think html is very flexible and here is my code.

private async Task showTeamStatus(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
    {
        MyInfo myInfo = new MyInfo();
        List <BotDataEntity> res = await myInfo.RunAsync();

        var card = new HeroCard();
        card.Title = "xxxx";
        var html = "<div>" +
            "<div style='height:40px;line-height:40px;text-align:center;'>" +
                "<div style='width:26%;float:left;text-align:left;'>Name</div>" +
                "<div style='width:20%;float:left;'>Log</div>" +
                "<div style='width:14%;float:left;'>Case</div>" +
                "<div style='width:14%;float:left;'>Task</div>" +
                "<div style='width:26%;float:left;'>IPD</div>" +
            "</div>";
        for (int i = 0; i < res.Count; i++)
        {
            html += "<div style='height:28px;line-height:28px;text-align:center;'>" +
                "<div style='float:left;width:26%;font-size:10px;text-align:left;'>" + res[i].userName + "</div>" +
                "<div style='float:left;width:20%;'>" + res[i].log + "</div>" +
                "<div style='float:left;width:14%;'>" + res[i].case + "</div>" +
                "<div style='float:left;width:14%;'>" + res[i].task + "</div>" +
                "<div style='float:left;width:26%;'>" + res[i].ipd + "</div>" +
            "</div>";
        }
        html += "</div> ";
        card.Text = html;

        var activity = MessageFactory.Attachment(card.ToAttachment());
        await turnContext.SendActivityAsync(activity, cancellationToken);
    }

You want to 'mention a user in ms teams channel', I think this document may help you. It provides a sample on 'Post a proactive message in a Teams channel and mention a user in it'.