I am currently writing some unit tests for my slack bot that I am creating, and I would love to be able to throw slack API errors such as channel_not_found exceptions or not_in_channel exceptions to test if I handle them well. I have been able to find documentation of what each response looks like, but I don't know how to throw the exception itself. Is there a good way I can do this?
Related
Just curious to know how others handle this from a security perspective. In a workaround related to Microsoft Power Automate, I'm using events and bolt-python to listen for a key word that will trigger an action to my bot endpoint. The issue is, as I'm building and testing this, every message posted is triggering an unhandled request and invoking my bot.of course the logic I want will execute fine when the key word is triggered but the amount of unnecessary triggers with the messages is concerning.
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.
I have a bot deployed to our Azure subscription. Using the webchat channel, I can interact with the bot using the url:
http://mybotname.azurewebsites.net/
We have added the bot to Slack as an app. We followed all the instructions given by the documentation on how to add a bot into Slack - https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-slack?view=azure-bot-service-3.0
When I send a message to the bot in the Slack channel we have created, I get no response. There is not error message, or in fact anything, returned.
Whereabouts can I start looking to see what the problem could be? Suggestions for error logs, traces, etc would be appreciated. I enabled App insights for the Azure Web App which the bot runs under, but nothing comes up as an error, or warning, or anything. I'm a bit lost here, any suggestions would be appreciated.
Note that I was made aware that, for Slack, I may need to tailor the responses in order for Slack to render them e.g. FormFlow define options for string field
I'm not sure how to do that, or even if this is a case that my bot simply isn't working in Slack regardless of how I'd format the responses.
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.
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);
}