Mind Your Metrics: How to use Telemetry to Make Your Chatbot More Effective in Azure HealthBot
Tags: javascript, ai, healthbot, analytics
Published: 2023-04-11 16:29:48

Chatbots have become an essential tool for providing quick and efficient support to users and patients. As chatbot developers, it is crucial to continuously monitor and improve the performance and effectiveness of these virtual assistants. One way to achieve this is by incorporating telemetry into your chatbot. Telemetry allows you to collect and analyze data, providing valuable insights that can help you optimize your chatbot's functionality and user experience.

In this blog post, we will discuss the importance of telemetry in chatbots, particularly in Azure's HealthBot service, and guide you through the process of integrating it into your chatbot. We will also demonstrate how to ping a custom Application Insights layer using a Telemetry Scenario that we will create, making it quick and easy to edit or add events as needed.

## The Impact of Telemetry on Chatbot Effectiveness

### * User Experience:
Telemetry is essential for understanding the user experience, as it provides valuable insights into how users interact with your chatbot and allows you to measure its performance. By analyzing these insights, you can identify necessary adjustments to improve the user experience.

### * Identifying Bottlenecks:
Telemetry can help detect potential bottlenecks in your chatbot's conversation flow, where users may be getting stuck or disengaging. By monitoring these issues, you can determine the root cause and address them effectively.

### * Evaluating Usage:
A chatbot's value is determined by its usage; even the most well-designed scenario is irrelevant if no one uses it. Usage telemetry helps you identify the features and skills that users desire, allowing you to optimize your chatbot based on the needs and preferences of your audience. In the following section, we will explore an example of how smart telemetry can be used to understand user preferences and guide chatbot development.

## Using Application Insights
Application Insights is Microsoft's Application Performance Dashboard, designed to collect and analyze various metrics and logs, all in a single location. To get started, make sure Application Insights is enabled for your HealthBot. Then, we can create a new scenario to encapsulate our logging function, which will have only two blocks in it.

#### Action Block
The Action Block should contain code similar to the following:
```js
const { 
    event = "", 
    value = ""
} = scenario.scenarioArgs;.

if (event) {
    session.logCustomEvent(event, value);
}
```

#### End Scenario Block
The End Scenario Block should return an empty object ({}). Returning an empty object avoids breaking the conversation if someone specifies a return value.

After setting up these blocks, you can easily use this scenario by calling the conversation and passing the values you need. This will trigger the scenario, log the values provided, and then continue with your scenario as expected.

![A Begin Scenario block Invoking the Telemetry scenario from inside another scenario](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9yusaxwo1zdgujc7x0zn.png)

### Identifying In-Demand Scenarios By Working Backwards from Telemetry

Now that we have a method for logging events, we can easily identify scenarios that would be most useful to our users. To do this, create the desired scenario, log the user's input that led to it, and then pass the data to another implemented scenario. This approach not only ensures a smooth user experience but also allows for the creation of a Power BI report. This valuable information can then be used by product owners to make informed decisions about the chatbot's development roadmap.

Leveraging telemetry and Application Insights in Azure HealthBot can significantly improve the overall effectiveness of your chatbot, resulting in a better user experience and more informed development decisions. I hope this post has provided valuable insights into ways you can take advantage of custom telemetry to identify improvements to your chatbots.

I'm eager to learn about your experiences and the unique ways you're using telemetry to enhance your Azure HealthBot. Please share your insights and ideas in the comments below, so we can grow and learn together! 😊