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.
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:
Go to the Analytics → Metrics configuration section.
Select the Topics, Actions, or Session results tab.
Fill in the Key for the script and Value fields for each metric.
The key is a unique identifier for the metric.
cautionYou will not be able to change the key or delete the metric if it already has data in the analytics. When you call thesetSessionTopic
,setScenarioAction
, orsetSessionResult
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.
tipThe metric value can be omitted. In this case, it will be the same as the key.
Go to the code editor.
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.
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:
In the Metrics configuration section, create new metrics:
Metric Key Value Topic Loan Loan application submitted Action Сontact details Contact details recorded to CRM Session result Positive feedback The bot helped the user Go to the bot script.
Select the state where a user can apply for a loan and add a
script
tag to it, calling thesetSessionTopic
method:script:
$analytics.setSessionTopic("Loan");Select the state where you send the contact data to the CRM system and add a
script
tag to it, calling thesetScenarioAction
method:script:
$analytics.setScenarioAction("Сontact details");Select the state where a user leaves positive feedback about the bot’s performance and add a
script
tag to it, calling thesetSessionResult
method:script:
$analytics.setSessionResult("Positive feedback");Save and publish the script.
When the user goes to these states, corresponding metrics will be recorded in the project analytics.