QNA 聊天机器人 "say the feedback" 与 Cortana

QNA chatbot "say the feedback" with Cortana

我在 Azure 中创建了一个 QNA (qnamaker.ai) 和一个聊天机器人。他们联系在一起,做他们应该做的事。我在 azure 上激活了 Cortana 通道,如果我使用正确的调用方法,它会给出正确的反馈,只是它根本不说话。我看到如果你用语音调用或查询,Cortana 会口头回答,但似乎不起作用。

我尝试重新创建整个应用程序,但它并没有解决我的问题。 我创建了一个基本的 C# UWP 应用程序,其中包含基本问题和 Cortana 对话。

现在的代码是微软默认的聊天机器人代码。

如果我遗漏了一些设置或者我只需要修改代码,我会问你的建议?

感谢您的帮助。

嘉宝

    protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
    {
        var httpClient = _httpClientFactory.CreateClient();

        var qnaMaker = new QnAMaker(new QnAMakerEndpoint
        {
            KnowledgeBaseId = _configuration["QnAKnowledgebaseId"],
            EndpointKey = _configuration["QnAAuthKey"],
            Host = GetHostname()
        },
        null,
        httpClient);

        _logger.LogInformation("Calling QnA Maker");

        // The actual call to the QnA Maker service.
        var response = await qnaMaker.GetAnswersAsync(turnContext);
        if (response != null && response.Length > 0)
        {
            await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
        }
        else
        {
            await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
        }

机器人样本不会调用适当的 API 来说明结果。您需要为语音和输入提示添加参数。请看

https://github.com/microsoft/cortana-skills-samples/blob/master/Consumer/CSharp/V4Patches/11.qnamaker.diff

这表明要进行此更改

                 await turnContext.SendActivityAsync(msg, speak: msg, inputHint: InputHints.AcceptingInput, cancellationToken: cancellationToken);