Skip to main content

Metrics configuration

To collect detailed statistics on the bot performance, you can set up your own metrics for annotating the script in the Metrics configuration section.

You can record:

  • Topics on which users communicate with the bot.
  • Actions that take place in a dialog. For example, a user left contact details or the bot transferred the dialog to an agent.
  • Session results. For example, a user’s issue was resolved or the bot was unable to help the user. Unlike actions, there can only be one result per session.
tip
You can find statistics on topics and results in the Project overview section.

How to configure metrics

To collect data on metrics, create them in the Metrics configuration section and annotate the script using the $analytics service methods:

  1. Go to the AnalyticsMetrics configuration section.

  2. Select the Topics, Actions, or Session results tab.

  3. Fill in the Key for the script and Value fields for each metric.

    • The key is a unique identifier for the metric.

      caution
      You will not be able to change the key or delete the metric if it already has data in the analytics. When you call the setSessionTopic, setScenarioAction, or setSessionResult methods from the script, pass the key into them.
    • The value is a description or comment for the metric that appears in the Project overview section. It can be changed at any time. This will not change the existing statistics, and you will not have to edit the script code.

      tip
      The metric value can be omitted. In this case, it will be the same as the key.
  4. Go to the code editor.

  5. Select the states on which you want to record topics and actions and add the script tag to each of them, calling the necessary method:

    • setSessionTopic to set dialog topics.
    • setScenarioAction to record actions in the dialog.
    • setSessionResult to record the dialog result.

When the bot goes to the state where the method is called, the metric will be recorded in the analytics.

tip
You can add methods to the script first. When the methods are called, the metrics will be added to the Metrics configuration section and displayed in the statistics in the Project overview section. In this case, the metric key and its value will be the same.

Configuration example

You have created a chatbot for bank support. You need:

  • To collect all requests when a user applies for a loan and provides contacts.
  • To record in analytics whether the bot solved the user’s question.

To do this, you add metrics and annotate the script:

  1. In the Metrics configuration section, create new metrics:

    MetricKeyValue
    TopicLoanLoan application submitted
    ActionСontact detailsContact details recorded to CRM
    Session resultPositive feedbackThe bot helped the user
  2. Go to the bot script.

  3. Select the state where a user can apply for a loan and add a script tag to it, calling the setSessionTopic method:

    script:
    $analytics.setSessionTopic("Loan");
  4. Select the state where you send the contact data to the CRM system and add a script tag to it, calling the setScenarioAction method:

    script:
    $analytics.setScenarioAction("Сontact details");
  5. Select the state where a user leaves positive feedback about the bot’s performance and add a script tag to it, calling the setSessionResult method:

    script:
    $analytics.setSessionResult("Positive feedback");
  6. Save and publish the script.

When the user goes to these states, corresponding metrics will be recorded in the project analytics.