Legacy - Formula override example
Summarize
Summary of Legacy - Formula override example
This example demonstrates how to create a formula override to group conversation end states in ServiceNow's Virtual Agent and Live Agent chat analytics. It is intended for customers using the legacy Conversational Analytics dashboard, which is being deprecated in favor of a new Platform Analytics experience that complies with Government Community Cloud (GCC) and FedRAMP requirements.
Show less
Key Features
- End State Grouping: The formula override script categorizes the 12 default conversation end states into three groups: System Closed VA (Virtual Agent system closures), System Closed LA (Live Agent system closures), and User Closed (user-initiated closures).
- Use of GlideRecord Queries: The script queries interaction records linked to a conversation to determine the final end state based on state, reason, and chat type (Virtual Agent or Live Agent).
- Reusable Script Structure: The example provides a function that checks if an end state belongs to one of the predefined groups and returns the grouped label accordingly.
Practical Application for ServiceNow Customers
Customers can use this formula override example to customize how conversation end states are reported in analytics, enabling clearer insights into chat session outcomes. This grouping simplifies analysis by consolidating multiple granular end states into meaningful categories, helping teams monitor chat performance and user behavior.
Since the legacy Conversational Analytics dashboard will be deprecated, customers should plan to migrate to the new Platform Analytics dashboard, which supports compliance requirements and enhanced analytics capabilities. For existing users, migration guidance is available to transfer analytics data smoothly.
Use the following formula override example to craft your own formula overrides.
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
- 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);