You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -42,151 +42,154 @@ In order to capture the LUIS information, the web app bot needs the **[Microsoft
42
42
1. Select **Browse** then search for **Microsoft.ApplicationInsights**.
43
43
1. Install the package.
44
44
45
-
## Build and resolve errors
46
-
47
-
1. Build the solution by selecting the **Build** menu, then select **Rebuild Solution**. Wait for the build to finish.
48
-
49
-
2. If the build fails with `CS0104` errors, you need to fix them. In the `Controllers` folder, in the `MessagesController.cs file`, fix the ambiguous usage of `Activity` type by prefixing the Activity type with the Connector type. To do this, change the name `Activity` on lines 22 and 36 from `Activity` to `Connector.Activity`. Build the solution again. There should be no more build errors.
The **Application Insights** package is now in the project and configured correctly for your credentials in the Azure portal. The changes for the project need to be published back to Azure.
58
-
59
-
1. In the **Solution Explorer**, right-click the project name, then select **Publish**.
60
-
61
-

62
-
63
-
2. In the **Publish** window, select **Create new profile**.
64
-
65
-

66
-
67
-
3. Select **Import profile**, and select **OK**.
68
-
69
-

70
-
71
-
4. In the **Import Publish Settings File** windows, navigate to your project folder, navigate to the `PostDeployScripts` folder, select the file that ends in `.PublishSettings`, and select `Open`. You have now configured publishing for this project.
72
-
73
-
5. Publish your local source code to Bot Service by selecting the **Publish** button. The **Output** window shows status. The rest of the tutorial is completed in the Azure portal. Close Visual Studio 2017.
74
-
75
-
## Open three browser tabs
76
-
77
-
In the Azure portal, find the web app bot and open it. The following steps use three different views of the web app bot. It may be easier to have three separate tabs open in the browser:
78
-
79
-
> * Test in Web Chat
80
-
> * Build/Open online code editor -> App Service Editor
81
-
> * App Service Editor/Open Kudu console -> Diagnostic Console
82
-
83
-
## Modify BasicLuisDialog.cs code
84
-
85
-
1. In the **App Service Editor** browser tab, open the `BasicLuisDialog.cs` file.
86
-
87
-
2. Add the following NuGet dependency under the existing `using` lines:
88
-
89
-
[!code-csharp[Add using statement](~/samples-luis/documentation-samples/tutorial-web-app-bot-application-insights/csharp/BasicLuisDialog.cs?range=11-12"Add using statement")]
90
-
91
-
3. Add the `LogToApplicationInsights` function:
92
-
93
-
[!code-csharp[Add the LogToApplicationInsights function](~/samples-luis/documentation-samples/tutorial-web-app-bot-application-insights/csharp/BasicLuisDialog.cs?range=61-92"Add the LogToApplicationInsights function")]
94
-
95
-
The Application Insights instrumentation key is already in the web app bot's application setting named `BotDevInsightsKey`.
96
-
97
-
The last line of the function adds the data to Application Insights. The trace's name is `LUIS`, a unique name apart from any other telemetry data collected by this web app bot. All the properties are also prefixed with `LUIS_` so you can see what data this tutorial adds compared to information that is given by the web app bot.
98
-
99
-
4. Call the `LogToApplicationInsights` function at the top of the `ShowLuisResult` function:
100
-
101
-
[!code-csharp[Use the LogToApplicationInsights function](~/samples-luis/documentation-samples/tutorial-web-app-bot-application-insights/csharp/BasicLuisDialog.cs?range=114-115"Use the LogToApplicationInsights function")]
102
-
103
-
## Build web app bot
104
-
105
-
1. Build the web app bot in one of two ways. The first method is to right-click on `build.cmd` in the **App Service Editor**, then select **Run from Console**. The output of the console displays and completes with `Finished successfully.`
106
-
107
-
2. If this doesn't complete successfully, you need to open the console, navigate to the script, and run it using the following steps. In the **App Service Editor**, on the top blue bar, select the name of your bot, then select **Open Kudu Console** in the drop-down list.
108
-
109
-

110
-
111
-
3. In the console window, enter the following command:
112
-
113
-
```console
114
-
cd site\wwwroot && build.cmd
45
+
## Capture and send LUIS query results to Application Insights
46
+
47
+
1. Open the `LuisHelper.cs` file and replace the contents with the following code. The **LogToApplicationInsights** method capture the bot and LUIS data and sends it to Application Insights as a Trace event named `LUIS`.
48
+
49
+
```csharp
50
+
// Copyright (c) Microsoft Corporation. All rights reserved.
3. You should see no difference in the chatbot response. The change is sending data to Application Insights, not in the bot responses. Enter a few more utterances so there is a little more data in Application Insights:
148
+
1. Inabrowser, inthe [Azureportal](https://portal.azure.com), find your bot's **Application Insights** resource. Its name will have most of the bot's name, then random characters at the end of the name, such as `luis-nodejs-bot-johnsmithxqowom`.
1. In the portal, select **All resources** then filter by the web app bot name. Click on the resource with the type **Application Insights**. The icon for Application Insights is a light bulb.
163
+
1. Inthe [Azureportal](https://portal.azure.com), open the bot's Application Insights resource.

143
-
144
-
2. When the resource opens, click on the **Search** icon of the magnifying glass in the far right panel. A new panel to the right displays. Depending on how much telemetry data is found, the panel may take a second to display. Search for `LUIS`. The list is narrowed to just LUIS query results added with this tutorial.
145
-
146
-

147
-
148
-
3. Select the top entry. A new window displays more detailed data including the custom data for the LUIS query at the far-right. The data includes the top intent, and its score.
## Query Application Insights for intent, score, and utterance
170
+
ApplicationInsightsgivesyouthepowertoquerythedatawiththe [Kusto](https://docs.microsoft.com/azure/application-insights/app-insights-analytics#query-data-in-analytics) language, as well as export it to [Power BI](https://powerbi.microsoft.com).
158
171
159
-
Application Insights gives you the power to query the data with the [Kusto](https://docs.microsoft.com/azure/application-insights/app-insights-analytics#query-data-in-analytics) language, as well as export it to [Power BI](https://powerbi.microsoft.com).
160
-
161
-
1. Click on **Analytics** at the top of the dependency listing, above the filter box.
2. A new window opens with a query window at the top and a data table window below that. If you have used databases before, this arrangement is familiar. The query includes all items from the last 24 hours beginning with the name `LUIS`. The **CustomDimensions** column has the LUIS query results as name/value pairs.
4. Run the query. Scroll to the far right in the data table. The new columns of topIntent, score, and utterance are available. Click on the topIntent column to sort.
Learnmoreaboutthe [Kustoquerylanguage](https://docs.microsoft.com/azure/log-analytics/query-language/get-started-queries) or [export the data to Power BI](https://docs.microsoft.com/azure/application-insights/app-insights-export-power-bi).
180
184
181
-
Learn more about the [Kusto query language](https://docs.microsoft.com/azure/log-analytics/query-language/get-started-queries) or [export the data to Power BI](https://docs.microsoft.com/azure/application-insights/app-insights-export-power-bi).
Other information you may want to add to the application insights data includes app ID, version ID, last model change date, last train date, last publish date. These values can either be retrieved from the endpoint URL (app ID and version ID), or from an [authoring API](https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c3d) call then set in the web app bot settings and pulled from there.
0 commit comments