When running application i get welcome message properly, i have called my luis class to get the matching intent. In directline issues list getting this message- There was an error sending this message to your bot: HTTP status code InternalServerError
While inspecting browser i am getting this message- Failed to load resource: the server responded with a status of 502 (Bad Gateway)
Though i have checked all keys, and bot was working fine before but suddenly getting these issue.
Also when testing in emulator after so many retry its working but again get stop with bot reply as- Sorry, my bot code is having an issue.
This is my Message controller code- public class MessagesController : ApiController { public object activity { get; private set; }
/// <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 code- Here i am using luis model and trying to get the specific matching intent-
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);
}
}
Stack Trace:
"{\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