Microsoft bot works locally but not when published - botframework

So I created a chatbot which works perfectly fine on the Microsoft Bot Framework Channel Emulator when run locally.
However, after I publish it, when I test it on Telegram, I get Error 500: "POST to pbot2 failed: POST to the bot's endpoint failed with HTTP status 500".
I have absolutely no clue as to where I might have gone wrong. Usually its a credentials issue if it works locally but not when published, but I tried testing connection to my bot on the Microsoft Bot website and it gives me: Endpoint authorization succeeded. So credentials is definitely not an issue.
Googling gives me results where the problem is with the backward compatibility of the System.IdentityModel.Tokens.jwt, but I did not update that package so that should not be an issue.
At this point I've ran out of ideas, will appreciate any help! Thanks in advance.

Without a little more context I might not be of much help; however there are a number of tools you can use:
1) If you hook up app insights in the bot framework portal, we'll log exceptions we see from your bot into app insights. The first couple million transactions a month are free for dev time debugging it's a must have.
2) 500 is internal server error. I assume your bot is set to take the other activity types beyond just "Message"? You'll get conversationUpdate Activity messages from the channel that you won't see automatically in the emulator.
3) You can point the emulator at your cloud endpoint and verify there as well and often get more detail for exceptions than you will in your chat channel.
Let us know what you find.

You're getting an uncaught exception; what I do is wrap everything in in the Post method in MessageController.cs in try...catch, and when the exception is caught, send the exception's Message and StackTrace into the chat. Usually the first few lines will contain the general error description and most of the times the line number.
catch (Exception ex)
{
string error = Emoji.Blush;
//for debugging in bot emulator, also output stack trace
if (activity.ChannelId == "emulator"
|| activity.ChannelId == "facebook" //uncomment this line to get stack traces on facebook too
)
{
error += ex.Message + ex.StackTrace;
}
//create response activity
Activity response = activity.CreateReply(error);
//post back to user
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await connector.Conversations.ReplyToActivityAsync(response);
}

Related

Teams Webhook gives ReflectionTypeLoadException

Is the webhook connections broken in Microsoft Teams or how do we solve the following issue?
When applying the Microsoft Teams Get Started documentation we get the following response in Postman.
"System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information."
We have set up a webhook in Teams and use it to post Application Insights messages to a Logic App where one of the actions is the webhook to Teams. Everything went fine until now (7/21 and 7/22, 2019) when we saw in Azure the same exception as a response on status 200. To figure this all out we went back to basic and tried to execute the Get Started documentation. The same exception was thrown.
Code that we used was all from the documentation.
After a day or two the exception wasn't returned anymore after NO modifications to the logic app or payload to the Teams webhook. Everything works fine now.
For future use we added an action to the Logic App to read out the webhook's response to determine futher actions, like sending an e-mail if webhook failed.

Ms Bot V4(LUIS) Internal server error when I try to enable the channel Cortana

When I try to enable Cortana in my Nodejs Bot, I get the message error internal server error, probably there something wrong in my code despite it works fine locally and in Ms Teams.
Is there a way to obtain a more specific error?
Analyzing the browser dev toolbar I get a 400 for the following http POST:
https://dev.botframework.com/api/bots//channels/cortana/deployment/ring
Did you check:
https://learn.microsoft.com/en-us/cortana/skills/known-issues#luisdialog-fails-on-skill-launch
https://github.com/Microsoft/cortana-skills-samples/blob/master/Consumer/Node/V4Patches/12.nlp-with-luis.diff
I would venture a guess that you do not handle the empty message / welcome intent on first turn.
Finally I activated Cortana Channel by uploading again the skill icon

Bot Framework Exception Handling in Channels?

I wanted to know if anyone knows what happens when a public bot on azure crashes for one user (i.e. when an Exception is thrown while a user is communicating with a bot via a channel)? Does this affect other users using the bot or the channel? Also, what happens to the conversation between the user and the bot when this crash happens, or when an exception is thrown?
By crashes, do you mean when Errors and/or Exceptions are thrown will a user is communicating with a bot via a channel like skype, FB Messenger, etc...)? If so, the default response for an Exception/Error is "Sorry, my bot code is having an issue" -- (I see this in MS Teams when I encounter an error in my code) As shown here:
While this is vague you can always go to the Bot Framework Portal to see more detailed error reporting. As shown here:
More than likely the users' experience will vary based on what caused the crash/error/exception.
When testing in the Emulator you may get a more detailed response, stating that an Exception occurred. You can also view the stack trace in the Emulator as well. For this reason you may want to thoroughly test your bot code there before deploying it to Azure.

Bot Service Basic Bot not responding to prompts

I've a Basic Bot Template based Bot set up using Bot Service. I've built a use case with few question prompts and capturing answers. I see the timestamp below my prompt in the chat box indicating that my prompt is delivered. But don't get a response back from the service. The application is still in develop and still haven't published it.
On Channels -> Web Chat -> I see few errors being logged.
Error: "There was an error sending this message to your bot: HTTP status code NotFound".
Could anybody help resolving this error?
A 404 (Not Found) would imply there's something wrong with your bot's registration in the bot framework portal. Can you log into dev.botframework.com, open your bot, hit edit, and see what the endpoint URL looks like?

Bot framework: “Sorry, my bot code is having an issue”. Fixed bug but how to restart conversation?

I have a simple Bot created using Microsoft Bot Framework running on Azure and it was working fine on all channels. Until yesterday when it stopped working on Facebook messenger when a user chose a particular untested option.
These are the lines that get executed when the rogue option is selected:
string replyText = "I am not yet ready to answer this question. Please choose another option.";
switch (appointmentBookType){
case Option1:
//Call Option1 Dialog.
break;
case Option2:
//Call Option2 Dialog.
break;
I keep getting "Sorry, my bot code is having an issue" as a response to anything I type.
This is the error I see in the Bot Framework developer portal for facebook messenger:
"There was an error sending this message to your bot: HTTP status code InternalServerError"
I am only using dialogs with some HeroCards.
I do not use LUIS.
I have fixed the bug by handling this previously unhandled conditions.
Is there a way to restart the conversation after fixing the bug?
After some scouring, this finally worked: https://docs.botframework.com/en-us/technical-faq/#my-bot-is-stuck--how-can-i-reset-the-conversation

Resources