无法将Bot链接到Bot框架仿真器 [英] Cannot link bot to bot framework emulator

查看:78
本文介绍了无法将Bot链接到Bot框架仿真器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将机器人加载到bot Framework Emulator中时,这是当前屏幕:

This is my current screen when I have tried to load my bot into the bot Framework Emulator:

这是我在机器人设置中输入的内容:

And this is what I have entered within the setting for my bot:

但是由于某种原因,我的bot框架模拟器仍然为空. 我还尝试将端点URL设置为 http://localhost:3979/api/messages 但没有运气.我试图在Visual Studio的本地运行它.

But for some reason my bot framework emulator remains empty. I have also tried setting the Endpoint URL to http://localhost:3979/api/messages but no luck. I am trying to run this locally off of visual studio.

对此有任何帮助,深表感谢!

Any help with this is much appreciated!

推荐答案

L.如果您遵循指令从模板创建QnA机器人,您将需要对代码进行一些调整以使其在本地运行,然后在模拟器中运行.

L. Full, if you followed the instructions from the Azure portal to create a QnA bot from a template, you will need to tweak the code a bit to have it work locally, and in turn work in the emulator.

使用模板创建漫游器(听起来好像已经完成)之后,在 ABS ,转到 Build (在Bot Management下)> 下载zip文件" ,您将在本地获得项目的副本.

After you have created your bot using the template (which it sounds like you have done), in ABS, going to Build (under Bot Management)> "Download zip file", you get a copy of your project locally.

如果您查看模板Bot代码,则该代码可在Azure中使用,因为总而言之,它是从Azure门户内的应用程序设置"中访问您的QnA凭据,但是在本地,您需要将凭据放在.配置文件.

If you look at the template Bot code, it works in Azure, because in summary, it is accessing your QnA credentials from within your Application Settings inside the Azure portal, but locally you will need to put the credentials somewhere like your .config file.

最终,我们现在要做的就是将您的QnA凭据插入到项目的.config文件中,因为下载zip时不会自动将其下载到代码中.

Ultimately what we'll have to do now is plug in your QnA credentials into your .config file of your project, as this is not automatically downloaded into the code when you download the zip.

下面,我仅使用可以在Azure门户中找到的QnA Template bot(创建资源> AI +机器学习> Web应用程序Bot,其中Bot模板为问答")

Below I'm just using the QnA Template bot that you can find in the Azure portal (Create Resource > AI + Machine Learning > Web App Bot with Bot template of "Question and Answer")

  1. Web.config 中添加AzureWebJobsStorage(如果使用),QnAAuthKey,QnAKnowledgebaseId和QnAEndpointHostName的键值对 您自己的凭据值可以在Azure门户的应用程序设置下找到

  1. In Web.config add key-value pairs for AzureWebJobsStorage (if using), QnAAuthKey, QnAKnowledgebaseId, and QnAEndpointHostName Your own credential values can be found under Application Settings of the Azure portal

<appSettings>

<!-- update these with your Microsoft App Id and your Microsoft App Password-->
<add key="MicrosoftAppId" value="" />
<add key="MicrosoftAppPassword" value="" />

<add key="AzureWebJobsStorage" value="DefaultEndpointsProtocol=https...."/>
<add key="QnAAuthKey" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
<add key="QnAKnowledgebaseId" value="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" />
<add key="QnAEndpointHostName" value="https://YOURQNA.azurewebsites.net/qnamaker" />
<add key="QnASubscriptionKey" value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</appSettings>

  • 在对话框中(截至7/5/18的QnA模板具有名为BasicQnAMakerDialog.cs的默认对话框文件),代替了 Utils (模板中的默认设置),我们将使用 ConfigurationManager.AppSettings ["KeyName"] 访问您刚刚放置在Web.config中的值: 在下面,您可以看到我已更改QnA模板中的变量(注释掉)以使用ConfigurationManager.AppSettings检索值.您还可能还必须在if语句中编辑变量,具体取决于您自己的应用所需的逻辑.

  • In your Dialog (QnA template as of 7/5/18 has default dialog file named BasicQnAMakerDialog.cs), instead of Utils (default in template), we'll use ConfigurationManager.AppSettings["KeyName"] to access the values you just placed in your Web.config: Below you can see I've changed the variables (commented out) in QnA template to retrieve values using ConfigurationManager.AppSettings. You may also have to edit the variables in your if-statement as well, depending on the logic your own app needs.

    在根对话框"中

    private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
    
                    var message = await result as Activity;
    
                    // OLD 
                    //var qnaAuthKey = GetSetting("QnAAuthKey"); 
                    //var qnaKBId = Utils.GetAppSetting("QnAKnowledgebaseId");
                    //var endpointHostName = Utils.GetAppSetting("QnAEndpointHostName"); 
    
                    // NEW
                    var qnaAuthKey = ConfigurationManager.AppSettings["QnAAuthKey"];
                    var qnaKBId = ConfigurationManager.AppSettings["QnAKnowledgebaseId"];
                    var endpointHostName = ConfigurationManager.AppSettings["QnAEndpointHostName"]; 
    
                    // QnA Subscription Key and KnowledgeBase Id null verification
                    if (!string.IsNullOrEmpty(qnaAuthKey) && !string.IsNullOrEmpty(qnaKBId))
                    {
                        // Forward to the appropriate Dialog based on whether the endpoint hostname is present
                        if (string.IsNullOrEmpty(endpointHostName))
                            await context.Forward(new BasicQnAMakerPreviewDialog(), AfterAnswerAsync, message, CancellationToken.None);
                        else
                            await context.Forward(new BasicQnAMakerDialog(), AfterAnswerAsync, message, CancellationToken.None);
    
                    }
                    else
                    {
                        await context.PostAsync("Please set QnAKnowledgebaseId, QnAAuthKey and QnAEndpointHostName (if applicable) in App Settings. Learn how to get them at https://aka.ms/qnaabssetup.");
                    }
    
                }
    

    1. 在由您的根调用的子对话框中(例如,BasicQnAMakerDialog),请确保也将所有需要QnA密钥的内容替换为ConfigurationManager.AppSettings ["KeyName"] .
    2. li>
    1. In the children Dialogs that get called by your root (BasicQnAMakerDialog for example), be sure to also replace anything that calls for a QnA key with ConfigurationManager.AppSettings["KeyName"].

    例如在BasicQnAMakerDialog中:

    For example in BasicQnAMakerDialog:

    [Serializable]
    public class BasicQnAMakerDialog : QnAMakerDialog
    {
            static readonly string qnaAuthKey = ConfigurationManager.AppSettings["QnAAuthKey"]; 
            static readonly string qnaKBId = ConfigurationManager.AppSettings["QnAKnowledgebaseId"];
            static readonly string endpointHostName = ConfigurationManager.AppSettings["QnAEndpointHostName"]; 
    
            public BasicQnAMakerDialog() : base(new QnAMakerService(
                new QnAMakerAttribute
                (
                    qnaAuthKey, 
                    qnaKBId,
                    "No good match in FAQ.", 
                    0.5, 
                    1, 
                    endpointHostName
                )))
            {
    
            }
        }
    

    这篇关于无法将Bot链接到Bot框架仿真器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆