简体   繁体   中英

Suggested Actions not visible in Microsoft Teams

I'll send a pro-active message from a bot to Microsoft Teams with 2 suggested actions that the user can take. But in Microsoft Teams the message is shown like this:

Notice that the message shows no suggested messages! At the Bot Framework Emulator, the same message looks like this:

What's wrong in Teams or my code?

Below is my code to authenticate, generate and send the message:

private async Task BotCallback(ITurnContext turnContext, CancellationToken cancellationToken)
{
    string serviceUrl = turnContext.Activity.RelatesTo.ServiceUrl;

    ConnectorClient Connector = new ConnectorClient(
        new Uri(serviceUrl),
        microsoftAppId: "[MicrosoftAppId]",
        microsoftAppPassword: "[MicrosoftAppPassword]"
    );

    AppCredentials.TrustServiceUrl(serviceUrl);
    ChannelAccount from = turnContext.Activity.From;
    IMessageActivity activity = MessageFactory.SuggestedActions(
        new string[] { "First action", "Second action" },
        $"Hi {userName},\r\nYou've missed some lorem ipsum dolor sit amet:\r\n- **consectetur:** Ut porttitor\r\nChoose an action from below to add them."
    );

    await Connector.Conversations.SendToConversationAsync(
        turnContext.Activity.Conversation.Id, 
        activity as Activity, 
        cancellationToken
    );
}

Suggested actions are not supported in Teams. If you want to display buttons, you could use Cards in Teams.

Echoing the other response, but perhaps a bit more detail. As explained, the way to do this in Teams (and other clients) is to use " Cards " - kind of like mini windows inside the chat. Teams supports a few different kinds of cards to suit different interactions, but the most prominent are called Adaptive Cards . You can play more with these at the designer here and there's even a "designer" experience built into App Studio (where you can even have App Studio's bot "send" you the card to see what it looks like in a "real" conversation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM