【发布时间】:2018-08-24 15:29:08
【问题描述】:
在本地机器人中工作正常,但在网络聊天频道“向您的机器人发送此消息时出错:HTTP 状态代码网关超时”发生错误,但机器人在第二次响应后正常运行
控制器代码
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
await Conversation.SendAsync(activity, () => new EchoDialog());
}
else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
IConversationUpdateActivity iConversationUpdated = message as IConversationUpdateActivity;
if (iConversationUpdated != null)
{
ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));
foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty<ChannelAccount>())
{
// if the bot is added, then
if (member.Id == iConversationUpdated.Recipient.Id)
{
var reply = ((Activity)iConversationUpdated).CreateReply("Hi, Welcome to Systenics.");
await connector.Conversations.ReplyToActivityAsync(reply);
await Conversation.SendAsync(message, () => new EchoDialog());
}
}
}
}
else
{
await HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
聊天对话框
public async Task StartAsync(IDialogContext context)
{
context.Wait(this.ShowOptions);
}
public virtual async Task ShowOptions(IDialogContext context, IAwaitable<IMessageActivity> activity)
{
var message = await activity;
var descriptions = new string[] { "Request a Quote", "More Information About Jobs" };
PromptDialog.Choice(
context: context,
resume: ChoiceReceivedAsync,
options: descriptions,
prompt: "Please select an option below:",
retry: "Selected option not available.",
promptStyle: PromptStyle.Auto
);
}
【问题讨论】:
-
你检查过日志吗?请分享有助于解决此问题的日志。
-
[12:52:53] -> POST 200 [conversationUpdate] [12:52:53] POST 200 [conversationUpdate] [12:52:56] POST 200 [message] 更多关于工作的信息
-
这个日志是本地的还是天蓝色的?
-
是本地日志
-
你需要从 azure 检查日志,因为它已经在本地工作了。
标签: c# azure botframework