我使用我开发的聊天机器人很难在本地工作但在将其部署到dev.botframework.com之后它似乎不起作用。
我的代码在下面,它在行中断... 等待Conversation.SendAsync(activity,()=> new MyBot.AppServices.ServiceLUIS());在哪里陈述 {“Microsoft App ID a8641a16-932c-49a5-af8b-a58ab2ce251f的授权失败,状态码未授权,原因短语'未授权'”}。
我已尝试Troubleshooting Bot Framework Authentication处的说明,但结果如下:
它正在破坏的地方是打电话给我的LUIS服务,所以对我而言,似乎我的Bot没有授权调用我的LUIS模型。但是我似乎无法在Azure中找到我的机器人发布的任何内容,而LUIS模型位于我允许LUIS模型授权访问我的BOT的地方。在Luis.ai或Bot Framework Portal中也看不到任何内容。
关于如何最好地解决的任何想法都会有所帮助!
namespace MyBot
{
[BotAuthentication]
public class MessagesController : ApiController
{
/// <summary>
/// POST: api/Messages
/// Receive a message from a user and reply to it
/// </summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
try
{
if (activity.Type == ActivityTypes.Message)
{
**await Conversation.SendAsync(activity, () => new MyBot.AppServices.ServiceLUIS());**
}
else
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
var reply = HandleSystemMessage(activity);
if (reply != null)
await connector.Conversations.ReplyToActivityAsync(reply);
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
catch (Exception e)
{
return null;
}
}
private Activity HandleSystemMessage(Activity message)
{
if (message.Type == ActivityTypes.DeleteUserData)
{
// Implement user deletion here
// If we handle user deletion, return a real message
}
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
}
else if (message.Type == ActivityTypes.ContactRelationUpdate)
{
// Handle add/remove from contact lists
// Activity.From + Activity.Action represent what happened
}
else if (message.Type == ActivityTypes.Typing)
{
// Handle knowing tha the user is typing
}
else if (message.Type == ActivityTypes.Ping)
{
}
return null;
}
}
}
答案 0 :(得分:0)
解决!结束为机器人和重新发布创建另一个新密钥和密码,它工作了! -