Adding Application Insights on CardAction of button

132 Views Asked by At

I am new to Microsoft Bot Framework. I am logging custom events on Application Insights. I am unable to figure out how can i log custom events on button clicks. Is there a way I could call my TrackCustomEvent function in CardAction of button?

1

There are 1 best solutions below

0
On

You can add telemetry inside your code (in C#) like the following. Notice that I supposed you are created telemetry service in azure, and get you InstrumentationKey.

var ai = new TelemetryClient();
ai.InstrumentationKey = "<your instrumentation key from azure>";
ai.TrackTrace("Hello! " + DateTime.Now.ToString());
ai.TrackTrace("Info " + DateTime.Now.ToString(), SeverityLevel.Information, 
     // Here you can add a structure into the log
     new Dictionary<string, object>() { { "UserId", activity.GetChannelData<object>()}}
);
ai.Flush(); // it sends the logs into the telemetry service

Also, you should set some configs and add some references. it can be followed in this post.