This article discusses how you can capture telemetry data from your Copilot Studio agent for use in Azure Application Insights.
In addition to the native analytics features within Copilot Studio, you can send telemetry data to Application Insights. Telemetry offers insights into your agent by tracking:
Logged messages and events sent to and from your agent
Topics to be triggered during user conversations
Custom telemetry events that can be sent from your topics
Important
Application Insights is a feature of Azure Monitor, an extensible Application Performance Management (APM) tool that allows you to monitor your live applications. It requires a subscription to Microsoft Azure.
Connect your Copilot Studio agent to Application Insights
To connect your agent to Application Insights, you first need to add your instrumentation key to your agent's configuration.
Go to the Settings page for your agent, and select Advanced.
Within the Application Insights section, populate the Connection string setting. See the Azure Monitor documentation to find out how to locate your connection string.
Optionally, you can choose to enable one of the following settings.
Log activities: If enabled, details of incoming/outgoing messages and events are logged.
Log sensitive Activity properties: If enabled, the values of certain properties that could be considered sensitive on incoming/outgoing messages and events are included in logs. The properties that are considered potentially sensitive are userid, name, text and speak (text and speak properties only apply to messages).
Analyze bot telemetry with Application Insights
After you've connected your bot to Application Insights, telemetry data is logged when users interact with the bot, including testing within Copilot Studio. To see the logged telemetry data, navigate to the Logs section of your Application Insights resource in Azure.
A query can be as simple as specifying a single table, such as customEvents, which shows all custom telemetry events logged from Copilot Studio. But you can also use Kusto queries to narrow down your results further, including;
Adding a time interval
Extending your results using custom dimensions. Custom dimensions are custom properties that are logged, along with the prebuilt fields, such as timestamp or the event name
A where clause to limit the data returned based on a condition
Using more built-in Kusto functions to determine what and how information is shown
The example query below results in a line chart that shows how many distinct users communicated with your bot per day for the past 14 days.
Kusto
let queryStartDate = ago(14d);
let queryEndDate = now();
let groupByInterval = 1d;
customEvents
| where timestamp > queryStartDate
| where timestamp < queryEndDate
| summarize uc=dcount(user_Id) by bin(timestamp, groupByInterval)
| rendertimechart
Important
The data within some fields varies and is more or less applicable, depending on the channel that is being used. For example, you'll only get a correct count of unique users in the query if they're authenticated users and their user ids are consistent across conversations. In anonymous scenarios where a random user id is generated per conversation, the user id field is less useful.
Excluding telemetry from test conversations from your queries
Your bot logs telemetry for all conversations, including those that happen within Copilot Studio during testing. If you want to exclude telemetry gathered during testing, you can extend your query with the designMode custom dimension that is captured on all events, and use a where clause in your query.
The following example shows all custom events, excluding those captured through the test canvas.
Much of the specific activity data received from Copilot Studio is stored in the customDimensions field. You can see a custom dimension field being used in a query to exclude telemetry from test conversations.
Field
Description
Sample Values
type
Type of activity
message, conversationUpdate, event, invoke
channelId
Channel identifier
emulator, directline, msteams, webchat
fromId
From Identifier
<id>
fromName
Username from client
John Bonham, Keith Moon, Steve Smith, Steve Gadd
locale
Client origin locale
en-us, zh-cn, en-GB, de-de, zh-CN
recipientId
Recipient identifier
<id>
recipientName
Recipient name
John Bonham, Keith Moon, Steve Smith, Steve Gadd
text
Text in message
find a coffee shop
designMode
Conversation happened within the test canvas
True / False
Note
This article applies to classic chatbots only. To extend agents created in Copilot Studio, you don't need to use Bot Framework Composer. All features described in this article are available for agents, directly in Copilot Studio.
You can use Bot Framework Composer with Copilot Studio to send event data to a telemetry service in Application Insights. Telemetry offers insights into your bot by showing which features are used the most, detects unwanted behavior, and provides data on availability, performance, and usage.
Important
Application Insights is a feature of Azure Monitor, an extensible Application Performance Management (APM) tool that allows you to monitor your live applications. It requires a subscription to Microsoft Azure.
Connect Application Insights
To connect to your Application Insights service in Composer, you need to add your instrumentation key to the project.
In Composer, go to the Configure page.
Enable Advanced Settings View (json).
Find the applicationInsights section, then add your Application Insights instrumentation key to the instrumentationKey setting.
To learn more on how to set up and use Application Insights and create queries for Composer's Adaptive dialogs, see these resources:
Use the upgraded analytics page in Copilot Studio to improve how well your agent responds to user questions. Review user feedback, knowledge source use, and the outcomes of conversations between your agent and your users.
The Summary analytics page shows you the scope of analytics, clustered with AI technology, so you can instantly see what topics and agents you should consider improving.
Use AI-driven analytics in Microsoft Copilot Studio to understand how well customers are interacting with your agent and identify areas for improvement.
Guidance for extending the use and scope of analytics data in Microsoft Copilot Studio by using a custom report template. Use your data with Dataverse, Azure data lake storage, and Power BI.