How to Manage Frontend Chat Retention in ServiceNow Virtual Agent for 30 Days?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2025 08:45 AM
Hello Community,
I’m working on implementing frontend chat retention for ServiceNow Virtual Agent (VA) in our instance. My goal is to retain Virtual Agent conversations on the frontend for exactly 30 days, so that users can see past interactions for up to a month — but without deleting them from the backend.
Here’s what I’ve tried so far:
1. Scheduled Script Execution:
I created a scheduled job (Chat Retention Policy for VA) using the following script to manage frontend chat visibility:
var daysOld = 1;
var retentionDate = new GlideDateTime();
retentionDate.addDaysUTC(-daysOld);
var gr = new GlideRecord('sys_cs_conversation');
gr.addQuery('sys_created_on', '<', retentionDate);
gr.query();
while (gr.next()) {
var archive = new GlideRecord('x_myapp_cs_conversation_archive'); // Custom archive table
archive.initialize();
archive.setValue('original_sys_id', gr.sys_id);
archive.setValue('conversation_data', gr.getValue('conversation_data'));
archive.insert();
gr.deleteRecord(); // Remove from active table after archiving
}
But this code is not working.
2. System Properties & Widget Cache:
I checked system properties starting with va. like:
va.adapter.max_processing.time
va.bot.to.bot.logging.enabled
va.messenger.account.auth
None of these appear to control frontend chat retention.
3. Clearing cache and reloading the browser did not help. Even older conversations (more than 7 days old) are still showing up in the chat widget on the Service Portal, despite running the cleanup script.
Questions:
How is frontend chat retention actually managed in ServiceNow Virtual Agent?
Is there a specific system property or config to limit frontend chat history visibility to 30 days (e.g., va.chat_retention_days)?
Can the VA chat widget be customized to filter sys_cs_conversation records based on age (e.g., show only conversations newer than 30 days)?
Is there an officially recommended approach to achieve frontend-only chat cleanup without removing the records from the backend?
Any insights, documentation links, or examples would be greatly appreciated.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2025 11:33 PM
Hello @guptasurbhi
I don't think you can retain it like that, you only have this property "load_active_only" : true and "skip_load_history" - true - which will help you load and control the chat retention in frontend (basically it hides from frontend - but they are still available in conversations table)
This property is given in "Service Portal" or "Employee center portal" under "Agent Chat" in left navigation wherever you have configured VA.
Apart from this there is no way to control chat retention in frontend. You can obviously manage the tables, but that's that. If you want some custom retention apart from this, maybe you can also ask Servicenow directly for advice by opening a case. But i doubt that's feasible.
Reference links - https://www.servicenow.com/community/virtual-agent-nlu-articles/using-skip-load-history-and-load-act...
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY