Microsoft聊天机器人显示403配额超出错误

时间:2018-10-31 14:16:16

标签: botframework luis

在运行应用程序时,我会收到正确的欢迎消息,我已经调用了luis类来获取匹配的意图。 在直接问题列表中,获得此消息- 向您的机器人发送此消息时出错:HTTP状态代码InternalServerError

在检查浏览器时,我收到此消息- 加载资源失败:服务器响应状态为502(错误的网关)

尽管我已经检查了所有键,但bot之前工作正常,但突然遇到了这些问题。

同样,当经过很多次重试后,在模拟器中进行测试时,又再次停止了bot的答复-对不起,我的bot代码有问题。

这是我的消息控制器代码-    公共类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)
    {
        if (activity.GetActivityType() == ActivityTypes.Message)
        {
            await Conversation.SendAsync(activity, () => new LuisClass());
        }
        else
        {
            await HandleSystemMessageAsync(activity);
        }
        var response = Request.CreateResponse(HttpStatusCode.OK);
        return response;
    }

    private async Task<Activity> HandleSystemMessageAsync( Activity message)
    {
        string messageType = message.GetActivityType();
        if (messageType == ActivityTypes.DeleteUserData)
        {
            // Implement user deletion here
            // If we handle user deletion, return a real message
        }



        else if (message.Type == ActivityTypes.ConversationUpdate)
        {
            if (message.MembersAdded.Any(o => o.Id == message.Recipient.Id))
            {
                ConnectorClient client = new ConnectorClient(new Uri(message.ServiceUrl));

                var reply = message.CreateReply();

                //reply.Text = "Welcome to Microsoft QaMaker Bot.How can i help you....?";
                reply.Text = "Hey there! I provide information on weather, stock and tableau. Ask me anything and I will try to answer";
                reply.Speak = "Hey there! I provide information on weather, stock and tableau. Ask me anything and I will try to answer";
                reply.InputHint = InputHints.AcceptingInput;
                await client.Conversations.ReplyToActivityAsync(reply);
            }
        }

        else if (messageType == ActivityTypes.ContactRelationUpdate)
        {
            // Handle add/remove from contact lists
            // Activity.From + Activity.Action represent what happened
        }
        else if (messageType == ActivityTypes.Typing)
        {
            // Handle knowing that the user is typing
        }
        else if (messageType == ActivityTypes.Ping)
        {
        }

        return null;
    }
}

LuisClass代码- 在这里,我正在使用luis模型并尝试获取特定的匹配意图-

public class LuisClass : LuisDialog<object>
{
    //public List<CompanyStockPrice> DataResult { get; private set; }

    [LuisIntent("None")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("Sorry, I didn't quite get that. Please try again");
        context.Wait(MessageReceived);
    }

    [LuisIntent("General")]
    public async Task General(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("Ask me anything and i will try to answer!");
        context.Wait(MessageReceived);
    }

}

堆栈跟踪:

"{\r\n  \"message\": \"An error has occurred.\",\r\n  \"exceptionMessage\": 
"Response status code does not indicate success: 403 (Quota Exceeded).\",\r\n  \"exceptionType\":  
"System.Net.Http.HttpRequestException\",\r\n  \"stackTrace\": \"   
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\\r\\n   
at Microsoft.Bot.Builder.Luis.LuisService.<Microsoft-Bot-Builder-Luis-ILuisService-QueryAsync>d__8.MoveNext() in D:\\\\a\\\\1\\\\s\\\\CSharp\\\\Library\\\\Microsoft.Bot.Builder\\\\Luis\\\\LuisService.cs:line 284\\r\\n--- 
End of stack trace from previous location where exception was thrown 

0 个答案:

没有答案