Legacy - Formula override example

  • Release version: Xanadu
  • Updated August 1, 2024
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Legacy - Formula override example

    This content provides a formula override example used to group conversation end states within ServiceNow's Conversational Analytics. It helps categorize how a conversation with a virtual agent or live agent concluded, which is critical for analyzing user interactions and improving service delivery.

    Show full answer Show less

    Note that the existing Conversational Analytics dashboard is planned for deprecation. A new dashboard within the Platform Analytics experience is available and supports Government Community Cloud (GCC) compliance and FedRAMP authorization. Migration guidance is provided for existing users.

    Key Features

    • End State Groupings: Conversations can end in various ways, such as system closure, user closure, or agent closure. There are 12 default end states, which this override script groups into three categories:
      • System Closed VA: Virtual Agent sessions closed by the system (e.g., user no response, topic complete).
      • System Closed LA: Live Agent sessions closed by the system or agent (e.g., chat complete, agent clicked end).
      • User Closed: Sessions closed explicitly by the user.
    • Formula Override Script: The provided JavaScript function retrieves interaction records linked to a conversation, determines the end state by leveraging existing ServiceNow utilities, and returns the grouped end state label. This enables customized reporting and analytics based on grouped conversation outcomes.

    Practical Use for ServiceNow Customers

    • Customize how conversation end states are reported and grouped in analytics dashboards.
    • Improve insights into user engagement and chat session outcomes by consolidating granular end states into meaningful categories.
    • Prepare for migration to the new Platform Analytics conversational dashboard to maintain compliance and access enhanced analytics features.

    Use the following formula override example to craft your own formula overrides.

    Important:

    Conversational Analytics dashboard is being prepared for future deprecation. It will be supported until deprecation but will no longer be available for installation. A new Conversational Analytics dashboard in Platform Analytics experience, which meets the compliance requirements of Government Community Cloud (GCC), and thus FedRAMP authorized, is available. See Conversational Analytics dashboard in Platform Analytics experience.

    For details on the deprecation process, see the Deprecation Process [KB0867184] article in the Now Support Knowledge Base.

    If you are an existing user of this dashboard and want to migrate analytics data to the new dashboard, see Migrate data to Conversational Analytics dashboard in Platform Analytics experience [KB1651556].

    Group End State definitions

    The end state of a conversation specifies how a conversation ended. For example, it could end with the user not responding, or the user closed the chat window. There are 12 default definitions of end state. For more information on conversation end states, see Virtual Agent interaction records. The following script groups them as follows:
    • VA closed the chat session
      • System Closed VA – User No Response
      • System Closed VA – Topic Complete
      • System Closed VA – Left With AI Search
      • System closed VA – Auto Closed
      • System Closed VA – User Never Engaged
    • Live agent closed the chat session
      • System Closed LA – User No Response
      • System Closed LA – Chat Complete
      • Agent Closed LA – Clicked End/X
      • System Closed LA – Before Agent Engagement
    • User closed the chat session
      • User Closed LA – Clicked End/X
      • User Closed VA – Clicked End/X
      • User Closed LA - Before Agent Engagement

    To create these groupings of the 12 end states, follow the instructions for creating a formula override and use the following script.

    (function calc(convGr) {
        // Returns 'System Closed VA', 'System Closed LA', 'User Closed' states.
        function getFinalEndState(state) {
            var arrayUtil = new global.ArrayUtil();
            VA_END_STATE = ['System Closed VA – User No Response',
                'System Closed VA – Topic Complete',
                'System Closed VA – Left With AI Search',
                'System closed VA – Auto Closed',
                'System Closed VA – User Never Engaged'
            ];
            LA_END_STATE = ['System Closed LA – User No Response',
                'System Closed LA – Chat Complete',
                'Agent Closed LA – Clicked End/X',
                'System Closed LA – Before Agent Engagement'
            ];
            USER_CLOSED_END_STATE = ['User Closed LA – Clicked End/X',
                'User Closed VA – Clicked End/X',
                'User Closed LA - Before Agent Engagement'
            ];
            if (state) {
                if (arrayUtil.contains(VA_END_STATE, state))
                    return 'System Closed VA';
    
                if (arrayUtil.contains(LA_END_STATE, state))
                    return 'System Closed LA';
    
                if (arrayUtil.contains(USER_CLOSED_END_STATE, state))
                    return 'User Closed';
            }
            return state;
        }
    
        var conversationId = convGr.getValue('sys_id');
        var interactionGr = new GlideRecord('interaction');
        interactionGr.addQuery('channel_metadata_document', conversationId);
        interactionGr.addQuery('channel_metadata_table', 'sys_cs_conversation');
        interactionGr.query();
        if (interactionGr.next()) {
            var state = interactionGr.getValue('state');
            var reason = interactionGr.getValue('state_reason');
            var isVAChat = interactionGr.getValue('virtual_agent');
            var isLAChat = interactionGr.getValue('agent_chat');
            var endState = new CAUtil().getEndState(state, reason, isVAChat, isLAChat);
            return getFinalEndState(endState);
        }
    })(convGr);