Skip to main content

$analytics.setSessionTopic

The method records the topic on which the user communicates with the bot. For example, you can call it on the initial state of a new branch of the script.

This method is useful for analyzing popular user requests. To record actions in a script, use the setScenarioAction method instead.

tip
You can find statistics on topics in the Project overview section. You can create and edit request topics in the Metrics configuration section.

Syntax

The method accepts a string as an argument.

$analytics.setSessionTopic("Topic")

Usage details

  1. If you want to record a topic that you previously created in the Metrics configuration section, you need to specify the Key of this metric as an argument. If the argument is different, a new metric will be created.
  2. The method can be called multiple times during one session.
  3. If the user navigates between topics, all values will be recorded. If within the same session the method is called with several times with the same argument, then the value is not recorded again.

How to use

state: MobileApp
intentGroup!: /KnowledgeBase/FAQ.Mobile App
a: It looks like you have requested information about our mobile app. Here is the answer to your question:
script:
$faq.pushReplies();
$analytics.setSessionTopic("Mobile app");

state: Mortgage
intentGroup!: /KnowledgeBase/FAQ.Mortgage
a: You seem to be interested in our mortgage programs. Here is the answer to your question:
script:
$faq.pushReplies();
$analytics.setSessionTopic("Mortgage");