在 Microsoft Teams 中看不到建议的操作

H. *_*lyn 2 c# botframework microsoft-teams

我将从机器人向 Microsoft Teams 发送一条主动消息,其中包含用户可以采取的 2 项建议操作。但在 Microsoft Teams 中,消息显示如下:

请注意,该消息未显示任何建议消息!在 Bot Framework Emulator 中,相同的消息如下所示:

Teams 或我的代码有什么问题?

下面是我验证、生成和发送消息的代码:

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
    );
}
Run Code Online (Sandbox Code Playgroud)

Gou*_*gum 7

Teams 不支持建议的操作。如果要显示按钮,可以在 Teams 中使用Cards