Underpinnings of Bot analytics
Published Nov 12 2020 11:33 PM 1,134 Views

Hello bot developers,


In our previous blogpost, we have seen the magic of Bot Telemetry Logger middleware, like what does it offer and how does it work in harmony with the Application Insights. Today, I will be talking about the Bot Analytics blade. 


If we compare these two telemetry; "Bot Telemetry Logger" reflects how Bot Service perceives traffic coming from and being sent to the Bot and "Bot Analytics" reflects the perspective of the bot itself. While they can be used in concert, they are different sets of data. 


Bot Analytics blade can be accessed through Azure Portal, if you put "analytics" at the end of your URL like "https://ms.portal.azure.com/..../botServices/[botname]/analytics" . It is a built-in extension powered by application Insights, and provides conversation-level reporting on user, message, and channel data.


I witness some number of customer complaints that, it may not show the expected data, when our customers perform some Power BI reporting. I.e. when you use Bot Telemetry logger, the number of Users is not the same as in the "Bot Analytics" reports. Well, it may be normal because of the fact that, they are making analytics from different perspectives. Let me take you deeper cause of this:


Built-in "Bot Analytics Blade" uses a different schema when compared to other SDK based telemetry  tools like "Bot Telemetry Logger". It uses different queries, to report "User"/"Message"/"Channel Data" information. For example, it reaches out to user information from the "CustomEvents" table through  "customDimensions" field, where the custom event is named as "Activity".  it is essentially using following query, for "User" reporting:



| where name == 'Activity'

| extend from = customDimensions['from']

| extend from = tostring(iff(isnull(from), customDimensions['From ID'], from))

| extend channel = customDimensions['channel']

| extend channel = tostring(iff(isnull(channel), customDimensions['Channel ID'], channel))

| extend activityType = customDimensions['Activity type']

| where activityType != '{Microsoft.Bot.Schema.ActivityTypes.ConversationUpdate}'

| summarize event_count = dcount(from) by channel

| project customDimensions_channel = channel, event_count


If you run this query, on the "Application Insights Project" which you configured for bot analytics, you will see that the results are similar with the "Bot Analytics Blade". See it below, when we run it on Application Insights, for last 24 hours:




And here is a screenshot from "Bot analytics blade" , which show the exact same information.





On the other hand, "Bot Telemetry logger" has a different schema for user reporting. You may remember from our previous blogpost that it use the actual "user_Id" field when logging to "customEvents" table. This field is left empty for the "Bot Analytics" logger.


See below query that in the first row, we see the "user_Id"s logged by "Bot Telemetry Logger", and in the second row, we see the other "customEvents", logged by "Azure bot analytics" which has null "user_Id" field:




These logging schemas do not overlap or mix-up, because bot telemetry logger does not log any customEvent with a name "Activity":




See Bot Telemetry logger, name constants here.


There are no plans to unify the two telemetry schemas at this time. They were designed independently, so you need to know how they log, to understand what you should expect. By that way, you can generate meaningful PowerBI reports from your Application insights data.


Hope you like my blogpost,

Stay tuned for the next one,


Version history
Last update:
‎Nov 12 2020 11:33 PM
Updated by: