Skip to main content

$analytics.setScenarioAction

This method records that a specific action took place in the script. For example, a user placed an order or the bot transferred the dialog to an agent.

tip
You can create and edit actions in the Metrics configuration section.

Syntax

The method accepts a string as an argument.

$analytics.setScenarioAction("Action")

Usage details

  1. If you want to record an action 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. Unlike the setSessionResult method, which allows you to record only one result in a session, the setScenarioAction method can be called multiple times. All values will be recorded.

How to use

In the example script below, the bot records a transfer to an agent in a text channel:

state: TransferToAgent
intent!: /TransferToAgent
a: I’m connecting you with an agent.
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "switch",
"firstMessage": $jsapi.chatHistory(),
"closeChatPhrases": ["/closeChat", "Close dialog"]
});
$analytics.setScenarioAction("Transfer to agent");