Either when application is deployed, or is just in development, there are multiple way to monitor it’s functionality. The easiest way in case of web application like our bot is to use log stream functionality on the Azure panel. To enable that, first you need to enable Application Logging in the „Diagnostics log“ blade on the app settings (keep in mind, that that option remains on only for 12 hours!)
Then, in case of any information and/or exceptions proper information will be displayed in Log stream:
Other option is to use Azure Application Insights functionality that offers tons of options, starting from user usage of the app, going through performance analysis and ending on exceptions. It also enables live stream, but in that case it requires additional libraries to be installed and configured (docs.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics).
There are however somethings that are not included in this text, that developer has to be aware of. Firstly – you need to handle events, that are already in calendar, and add them to the queue. Secondly – you need to handle edit/delete actions as well. There may be several approaches for that, what you choose is up to you. Other things are more as a features, like option to unsubscribe, or option to mute notifications for some time.
As usual, even the best and in theory the most straight forward solutions have owns problems, that can increase time necessary to finish the task. The same was in this case. Here are the few examples with the solutions/walkarounds:
Not working buttons
First problem that I’ve encountered was about buttons in the dialog messages. Especially – to log in to Office 365. But what is interesting – button was working in the web interface and the Bot Emulator, however – it was not working in the Teams application. Solution was easy and rather unexpected – Type of the CardAction has to be changed in order to work… That’s all. Apparently there is something wrong with that type of action.
I thought that was the end of my problems with buttons, but… No. The same problem I had with the buttons created using FormFlow, but in this case I didn’t have option to change type, and problem occurred on every channel.
Reason? Apparently bug in the 184.108.40.206 version of the Bot Framework SDK… Solution? Just take previous version… Great.
Missing refresh token
Other problem was about refresh tokens. Based on the Graph Api documentation, response of the Token endpoint should be as follows:
It seems, that it’s just missing? I don’t know the reason why, maybe I did something wrong, but to make long story short – I’ve just called endpoint manually using HttpClient, and everything worked just fine. Strange.
Autofac version problem
Other problem occurred when I tried to call some service method that supposed to restore the dialog from Azure Function. Problem seems to be self-explanatory – dll is missing, as the referenced project use one. No problem, let me install that…
Autofac version 220.127.116.11 installed…
so let’s try again:
Interesting. It seems, that we have some differences in the library, even when we have the same version installed? No way!
And what is even more strange – for test purposes I’ve copied ALL THE CODE of the method to that Azure Function and that… just worked. And what was the reason? Let me explain.
Projects like Azure Function make use of the libraries in different way than regular apps. When you install library from the NuGet that has any dependencies, that libraries are „under“ that main library. So even if I had Autofac version 4.6.2 installed, default version used in Microsoft.Bot.Builder library was different.
When Autofac from NuGet was installed, Bot.Builder in theory used the same version:
When Autofac was uninstalled, version was reverted to 3.5.2:
But in the services project, still version was 4.6.2.
So the general solution was to downgrade Autofac installed in Service project to version 3.5.2. Very, very strange that upgrade of the version broke something. But luckily after downgrade it works now 🙂
In the next part of blog series there will be description of the patterns, that will help keep code clean and handle growing project nicely. Also – unit tests of the bot will be introduced, as well as solutions to ease deployment handling.