将 Microsoft Bot 的 AudioCard 与 Microsoft Teams 一起使用请参阅 bot UI 显示 "Go back to the main window to see this content."

Use AudioCard of Microsoft Bot with Microsoft Teams see bot UI shows "Go back to the main window to see this content."

我可以 运行 这个 Teams Bot 示例: https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/57.teams-conversation-bot

当我需要添加一个音频卡来播放 mp3 歌曲时,我更新了我的代码:

    private async Task CardActivityAsync(ITurnContext<IMessageActivity> turnContext, bool update, CancellationToken cancellationToken)
    {
        var card = GetAudioCard();

        await SendUpdatedCardAudio(turnContext, card, cancellationToken);

    }

    private static AudioCard GetAudioCard()
    {
        var audioCard = new AudioCard
        {
            Title = "I am your father",
            Subtitle = "Star Wars: Episode V - The Empire Strikes Back",
            Text = "The Empire Strikes Back (also known as Star Wars: Episode V – The Empire Strikes Back)" +
                   " is a 1980 American epic space opera film directed by Irvin Kershner. Leigh Brackett and" +
                   " Lawrence Kasdan wrote the screenplay, with George Lucas writing the film's story and serving" +
                   " as executive producer. The second installment in the original Star Wars trilogy, it was produced" +
                   " by Gary Kurtz for Lucasfilm Ltd. and stars Mark Hamill, Harrison Ford, Carrie Fisher, Billy Dee Williams," +
                   " Anthony Daniels, David Prowse, Kenny Baker, Peter Mayhew and Frank Oz.",
            Image = new ThumbnailUrl
            {
                Url = "https://upload.wikimedia.org/wikipedia/en/3/3c/SW_-_Empire_Strikes_Back.jpg",
            },
            Media = new List<MediaUrl>
            {
                new MediaUrl()
                {
                    Url = "https://wavlist.com/wav/father.wav",
                },
            },
            Buttons = new List<CardAction>
            {
                new CardAction()
                {
                    Title = "Read More",
                    Type = ActionTypes.OpenUrl,
                    Value = "https://en.wikipedia.org/wiki/The_Empire_Strikes_Back",
                },
            },
        };

        return audioCard;
    }

    private static async Task SendUpdatedCardAudio(ITurnContext<IMessageActivity> turnContext, AudioCard card, CancellationToken cancellationToken)
    {
        var attachments = new List<Attachment>();
        var reply = MessageFactory.Attachment(attachments);

        reply.Attachments.Add(card.ToAttachment());

        await turnContext.SendActivityAsync(reply, cancellationToken);
    }

以上修改参考本例: https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/06.using-cards

当我在 Teams Bot 中测试它时,我看到以下回复: From Teams Bot

回复说:“回到主window看这个内容。”。

你知道为什么吗?谢谢。

回想一下,“Bot Framework”是 Microsoft 的通用 Bot 创建框架,Teams 只是一个特定的实现。因此,有些事情在 Teams 上下文中根本不受支持。在这种情况下,根据 here:

上的文档
The following cards are implemented by the Bot Framework, but are not supported by Teams:

- ..
- Audio cards
- ..

所以很遗憾,您需要实施另一种音频解决方案。相反,您可以做的是向音频文件或播放器提供 link 之类的东西。另一种选择是实施嵌入您自己的小型 html5 音频播放器的任务模块(基本上是 Teams 中的弹出窗口)。

那你呢