【发布时间】:2017-12-09 12:18:27
【问题描述】:
我使用 IIS 在本地托管我的机器人,如下所示:https://localhost/MyBot.目前,当我尝试在机器人模拟器中连接到我的机器人时,我收到 POST 500 错误,并且无法发送消息。我是新手,大多数将机器人发布到本地服务器的文档都是有限的。但是,我可以从浏览器成功打开此链接。
我是否因为没有 https://localhost/Bridget/api/messages 目录/url 而遇到此错误?我尝试在 IIS 中创建虚拟目录,但这无助于解决我的问题。我需要隧道软件吗?是否有使用 IIS 在本地部署机器人并通过机器人模拟器连接到它的简单教程?
这是我在模拟器中看到的错误:
使用 ngrok 隧道软件,这是我看到的:
这是处理传入 POST 消息的代码:
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
// Strip any @mentions
Mention[] m = activity.GetMentions();
for (int x = 0; x < m.Length; x++)
{
if (m[x].Mentioned.Id == activity.Recipient.Id)
{
if (m[x].Text != null)
{
activity.Text = activity.Text.Replace(m[x].Text, "");
}
}
}
await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);
await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
}
else if (activity.Type == ActivityTypes.Invoke)
{
// Some Code...
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
【问题讨论】:
-
当您在模拟器中获得
conversationUpdate时,可以联系您的机器人,所以这是一件好事,现在您在处理/回复传入消息时遇到问题。也许你应该先尝试用基本的回声来回复。并且可能在文件或某处记录异常,以便能够从“服务器端”查看这些错误
标签: iis emulation botframework