3

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 
Mark B
  • 581
  • 2
  • 14
  • 1
    Sorry but your description seems far too general - could you add any more details about how your bot works? Could you add code sample? Are you using C#? Any dialogs? – Ferdinand Fejskid Oct 31 '18 at 17:47
  • It would be good if you could get a copy of the stack trace for this question. If you are testing on azure, consider using [ngrok](https://blog.botframework.com/2017/10/19/debug-channel-locally-using-ngrok/) to test as if the bot were local. – Mark B Oct 31 '18 at 18:05
  • @FerdinandFejskid I have added my code, pls let me know whats wrong? – Neha Shaikh Nov 01 '18 at 07:44
  • @MarkB i have added stack trace – Neha Shaikh Nov 01 '18 at 10:08
  • What about https://stackoverflow.com/questions/48095767/is-luis-limited-for-use/48096165 – Ferdinand Fejskid Nov 01 '18 at 11:03
  • @FerdinandFejskid i referred that link, Got to know "Out of call volume quota" for the key i was using. Now i am using the new key got from azure portal. i have assign new resource in luis portal. But now getting **Response status code does not indicate success 401 Access Denied** in my stack trace. – Neha Shaikh Nov 01 '18 at 12:22
  • 1
    The endpoint earlier while using Starter_key of luis was - https://westus.api.cognitive.microsoft.com/luis/v2.0/ and now new endpoint is- https://southcentralus.api.cognitive.microsoft.com/luis/v2.0 – Neha Shaikh Nov 01 '18 at 12:27
  • Well thats important - are you positive you assigned the new key to the region "southcentralus" ? Could you eventually check it? The usage of the key is bound to the region. – Ferdinand Fejskid Nov 01 '18 at 12:36
  • 1
    @FerdinandFejskid Well got your point, I created a new key of westus, and now its working fine. Thank you so much! – Neha Shaikh Nov 02 '18 at 06:16
  • 1
    Great! I guess you may now write down your "story" as an answer and accept it:-) And perhaps also please try to shorten the stacktrace. – Ferdinand Fejskid Nov 02 '18 at 08:20

0 Answers0