当我在聊天机器人中发送信息时,我正面临着问题。我已经采取了以下步骤来创建聊天机器人。
当我键入并发送消息(使用web客户端)时,我会在浏览器控制台上得到以下错误(代码错误502)。
发布https://directline.botframework.com/v3/directline/conversations/7IqYgcAzBp4EObQvFzK2fF/activities 502 (坏网关)
Directline和Web通道日志将错误消息显示为
向bot发送此消息时出错: HTTP状态代码禁止。
下面是请求头的详细信息。

下面是Bot (.bot)文件的详细信息。注意,应用程序ID和密码是空的,如果这是问题的话?
{
"name": "Chatbot",
"services": [
{
"type": "endpoint",
"name": "development",
"endpoint": "http://localhost:3978/api/messages",
"appId": "",
"appPassword": "",
"id": "1"
},
{
"type": "endpoint",
"name": "production",
"endpoint": "https://<my_app_name>.azurewebsites.net/api/messages",
"appId": "<YOUR APP ID>",
"appPassword": "<YOUR APP PASSWORD>",
"id": "2"
}
],
"padlock": "",
"version": "2.0"
}我尝试在不同的订阅上重新创建所有这些,但是我得到了相同的错误。我有另一个正在启动和运行的bot,如果我在同一个web客户端中使用该bot的Directline通道键,它可以正常工作。
我在网上找了一些参考资料,但这些都没有帮助。如果我遗漏了什么东西,谁能帮帮我吗?如果我能提供更多的细节,请告诉我。
发布于 2019-02-13 16:45:19
如果您是bot正在使用集成库,则使用.bot文件的启动代码通常具有以下内容(除其他外):
var secretKey = Configuration.GetSection("botFileSecret")?.Value;
var botFilePath = Configuration.GetSection("botFilePath")?.Value;
BotConfiguration botConfig = BotConfiguration.Load(botFilePath, secretKey);
var environment = _isProduction ? "production" : "development";
var service = botConfig.Services.FirstOrDefault(s => s.Type == "endpoint" && s.Name == environment);
services.AddBot<BasicBot>(options =>
{
options.CredentialProvider = new SimpleCredentialProvider(endpointService.AppId, endpointService.AppPassword);
//other code
}注意从bot文件AppId和AppPassword创建的凭据提供程序。这个appid和apppassword可以从appid检索,如下所示:
options.CredentialProvider = new SimpleCredentialProvider(Configuration[MicrosoftAppCredentials.MicrosoftAppIdKey],
Configuration[MicrosoftAppCredentials.MicrosoftAppPasswordKey]);注意:您的端点也应该是正确的:
"endpoint": "https://<my_app_name>.azurewebsites.net/api/messages",https://stackoverflow.com/questions/54670566
复制相似问题