Connecting Azure Bots with Application Insights is very important to get your Bot telemetry data, as well as Bot analytics information. When we create a bot using Azure Bot Services, it creates the Application Insights resources and linked with Azure Bot. So, as soon as you run your chatbot, it starts capturing telemetry data. So far everything is fine. Now, let’s consider you have an existing Application Insight resource. Rather create a new Application Insight, you want to link with your existing one. Well, you can achieve that by following few steps.
Connecting Azure Bots with Application Insights
When we talk about connecting Azure Bot Services with Application Insights, we need to consider it for two purposes.
- Application Insights capture the telemetry data of our Bot, which we will be used for instrumentation and troubleshooting purpose.
- Azure Bot Analytics reads instrumented data from Application Insights and displays in the Analytics blade.
To start capturing the telemetry data, you only need the instrumentation key of the Application Insight.
First, from Application Insights – Get the Application Insights Instrumentation Key
Related Post :
- Getting an Application Insights Instrumentation Key inside Visual Studio itself
- Real-Time Telemetry for your BoT using Application Insights
Once you have the Instrumentation Key, Open the Azure Bot Services > Navigate to Bot Management > Settings and under the Analytics section update the Application insights Instrumentation Keys.
With that, your bot telemetry would be captured and collected by Application Insights. You can leverage the Application Insight dashboard for analysis of the telemetry data.
Connecting Azure Bots with Application Insights – API Keys
To address the second purpose, We need to get hold of API Keys and the Application Insights Application ID
You can query Application Insights telemetry data using Rest API and Azure Bot Analytics similar access your Application Insight information for providing the Bot Analytics. To get access to Application Insight data, you need Application ID and API Key. To get those details, Open the respective Application Insights dashboard from the Azure Portal. Select the API Access available under Configure option.
get the Application ID from the API Access window. Get the Application ID from here and click in “Create API Key” Option.
In the Create API Key window, provide a description of your API Keys, and choose the purpose of the API Access-like Read, Write etc.
Once done, select the “Generate Key”.
Once the key is generated. Keep the API key for further reference.
That’s it from here. Now you have the reference of Application ID and API Key, which will allow you to connect with your Application Insight Telemetry records.
Now go back to Azure Bot Service once again, BOT Management > Settings and update the Application Insight API Key and Application ID.
With these two values updates, the Bot Analytics would be able to populate the analytics in the dashboard. You can see the Bot Analytics from Bot Management > Analytics page.