本地主机上的 Botbuilder 机器人没有响应,但在 Azure 中有效

No response from Botbuilder bot on localhost, but works in Azure

我试图按照 this 教程进行操作,该教程要求我下载机器人代码,运行 将其下载到本地并使用 Botframework 模拟器对其进行测试。当我在模拟器中聊天时,它没有返回任何响应。

当我使用 Azure 的网络聊天模拟器时,它运行得很好!

我在 Azure 上使用 these 指令设置了机器人,因此所有必要的资源都已设置好并自动 运行ning。当我聊天时,节点控制台打印以下内容:

WARN: ChatConnector: receive - emulator running without security enabled. logger.js:24 ChatConnector: message received.

有时,它会出错:

Error: Failed to initialize azure table client. Error: Error: Failed to perform the requested operation on Azure Table. Message: connect ECONNREFUSED 127.0.0.1:10002. Error code: ECONNREFUSED UniversalBot.js:548

我不知道这是相关的还是一个单独的问题。

WARN: ChatConnector: receive - emulator running without security enabled. logger.js:24 ChatConnector: message received.

这只是一个警告,可能是由于在模拟器中使用 http URL: http://localhost:3978/api/messages 作为消息端点造成的。

Error: Failed to initialize azure table client. Error: Error: Failed to perform the requested operation on Azure Table.

如果您查看代码,您会发现它使用 Azure Table 存储来存储和管理您的机器人的状态数据:

var tableName = 'botdata';
var azureTableClient = new botbuilder_azure.AzureTableClient(tableName, process.env['AzureWebJobsStorage']);
var tableStorage = new botbuilder_azure.AzureBotStorage({ gzipData: false }, azureTableClient);

// Create your bot with a function to receive messages from the user
var bot = new builder.UniversalBot(connector);
bot.set('storage', tableStorage);

代码将使用'AzureWebJobsStorage'连接字符串来启动azureTableClient,如果您没有为'AzureWebJobsStorage'提供连接字符串,它会抛出上述错误。

请尝试为 'AzureWebJobsStorage' 设置环境变量或直接在代码中指定连接字符串。

var azureTableClient = new botbuilder_azure.AzureTableClient(tableName, '{your_storage_connection_string_here}');

请你试试。我认为它不起作用,因为您的端点和名称不正确