我已经使用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文件,不确定是否是问题所在
我的模拟器屏幕快照已随附:
任何帮助都是有用的。
答案 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
键是代码试图用来检索您的认知模型的键,因此,如果从代码中拉出的locale
与cognitivemodels.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
存在错误。