Virtal Assistant抛出“抱歉,好像出现了问题”

时间:2019-05-31 06:21:21

标签: azure botframework

我已经使用Microsoft虚拟助手模板创建了虚拟助手。在模拟器中进行测试时,无论我发送什么消息,我都会收到“出错的回复”。

我是整个bot框架生态系统的新手,并且变得非常困难。

我在日志中看到的是:

    [11:26:32]Emulator listening on http://localhost:65233
[11:26:32]ngrok not configured (only needed when connecting to remotely hosted bots)
[11:26:32]Connecting to bots hosted remotely
[11:26:32]Edit ngrok settings
[11:26:32]POST201directline.startConversation
[11:26:39]<-messageapplication/vnd.microsoft.card.adaptive
[11:26:39]POST200conversations.replyToActivity
[11:26:54]->messagehi
[11:26:55]<-traceThe given key 'en' was not present in the dictiona...
[11:26:55]POST200conversations.replyToActivity
[11:26:55]<-trace at System.Collections.Generic.Dictionary`2.get_...
[11:26:55]POST200conversations.replyToActivity
[11:26:55]<-messageSorry, it looks like something went wrong.
[11:26:55]POST200conversations.replyToActivity
[11:26:55]POST200directline.postActivity
[11:27:48]->messagehello
[11:27:48]<-traceThe given key 'en' was not present in the dictiona...
[11:27:48]POST200conversations.replyToActivity
[11:27:48]<-trace at System.Collections.Generic.Dictionary`2.get_...
[11:27:48]POST200conversations.replyToActivity
[11:27:48]<-messageSorry, it looks like something went wrong.
[11:27:48]POST200conversations.replyToActivity
[11:27:48]POST200directline.postActivity

据我了解,词典中不存在“ en”,因此我不确定这是什么意思。我在“响应”文件夹中签入,但看不到一个en文件,不确定是否是问题所在

enter image description here

我的模拟器屏幕快照已随附:

enter image description here

任何帮助都是有用的。

1 个答案:

答案 0 :(得分:1)

我相信您遇到的问题是MainDialog.cs内以下几行的问题:

var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
var cognitiveModels = _services.CognitiveModelSets[locale];

这试图使用语言环境(根据this documentation从当前线程检索)作为访问cognitivemodels.json文件中认知模型的键。

在您的cognitivemodels.json文件中,其外观应为:

{
  "cognitiveModels": {
    // This line below here is what could be missing/incorrect in yours
    "en": {
      "dispatchModel": {
        "type": "dispatch",
        "region": "westus",
        ...
      },
      "knowledgebases": [
        {
          "id": "chitchat",
          "name": "chitchat",
          ...
        },
        {
          "id": "faq",
          "name": "faq",
          ...
        },
      ],
      "languageModels": [
        {
          "id": "general",
          "name": "msag-test-va-boten_general",
          "region": "westus",
          ...
        }
      ]
    }
  },
  "defaultLocale": "en-us"
}

en对象内部的cognitiveModels键是代码试图用来检索您的认知模型的键,因此,如果从代码中拉出的localecognitivemodels.json中的区域设置键,那么您将得到字典键错误。

编辑

OP的问题是部署失败。我们采取的步骤是:

  • 检查deploy_log.txt文件夹中的Deployment是否存在错误。
    • 如果这种情况是空的-这不是一个好兆头。
  • 检查deploy_cognitive_models_log.txt文件夹中的Deployment是否存在错误。
    • Error: Cannot find module 'C:\Users\dip_chatterjee\AppData\Roaming\npm\node_modules\botdispatch\bin\dispatch.js存在错误。
      • 要解决此错误,我们按照this guide的第5步重新安装了所有必需的npm软件包,然后按照this guide运行了部署脚本。