【发布时间】:2018-09-10 16:55:28
【问题描述】:
我在 Azure 中部署了一个机器人。使用最新的 >net bot 框架 (v3)。 前端使用香草网络聊天。我正在尝试从 BOT 向客户端发送一个事件,以触发对网络聊天可见历史记录的擦除。 当我的机器人尝试发送事件消息时,我收到了无用的 502 错误。
在我的前端设置网络聊天和直线的 JS 是:
var botConnection = new BotChat.DirectLine({
secret: {secret removed..becuase secret},
//token: params['t'],
//domain: params['domain'],
webSocket: "true" // defaults to true
});
BotChat.App({
bot: bot,
botConnection: botConnection,
resize: 'detect',
user: user,
chatTitle: false,
showUploadButton: false
}, document.getElementById('bot'));
//backchannel communication setup
botConnection.activity$
.filter(function (activity) {
return activity.type === 'event' && activity.name === 'clearChatHistory';
})
.subscribe(function (activity) {
console.log('"clearChatHistory" received');
clearChatHistory();
});
function clearChatHistory() {
$(".wc-message-wrapper").remove();
}
这里的想法是,我的机器人代码将创建一条“活动”类型的消息,其值为“clearChatHistory”。这会触发我客户端上的代码。
发送此消息的代码是:
internal static async Task SendClearChatHistoryEvent(Activity activity)
{
Trace.TraceInformation($"Utility::SendClearChatHistoryEvent");
Activity clearMessage = activity.CreateReply();
clearMessage.Type = "event";
clearMessage.Value = "clearChatHistory";
Trace.TraceInformation(JsonConvert.SerializeObject(clearMessage));
Trace.TraceInformation($"Utility::SendClearChatHistoryEvent::ServiceURL:{activity.ServiceUrl}");
var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await connector.Conversations.SendToConversationAsync(clearMessage);
}
机器人失败发生在“SendToConversationAsync”调用中
我最接近错误的是客户端 “https://directline.botframework.com/v3/directline/conversations/5OSJJILizNqGG4H7SaV6fQ/activities502(坏网关)”
Visual Studio 输出窗口显示 'Microsoft.Rest.TransientFaultHandling.HttpRequestWithStatusException' 和'Microsoft.Bot.Connector.ErrorResponseException 例外
任何关于我可能做错了什么或这里发生的事情的见解将不胜感激。
【问题讨论】:
标签: botframework direct-line-botframework