How to show virtual agent chat history only for 24 hours of chat to users?

shaikha
Tera Guru

Hi,

Could you please help me i am strggling to disable history and show only 24 hours of history to users on the virtual agent chat.

If i use skip_load_history: true in server script of agent chat record. it is disabling all history also when user is in middle of the session the and goes to some knowledge article page then the bot is restarting from the scratch.

 @Nabil Asbi Could you please help me how to tackle this situation it would be greatly help me.

Any response from anyone would reduce my struggle.

Thanks,

Shaikha

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Curious if it would work, I tried something...
A before query Business Rule on sys_cs_message. Only for messages of today, for example:

(function executeRule(current, previous /*null when async*/) {

	var qc = current.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');

})(current, previous);

Query for last 24 hours could be something like:

sys_created_onRELATIVEGT@hour@ago@24

This would only show you the history of today.

You might want to add a condition to the Business Rule. Like not running for admin, virtual_agent_admin. For example:

!gs.hasRole('virtual_agent_admin')

Also test! I haven't looked if this gives other issues.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

2 REPLIES 2

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Curious if it would work, I tried something...
A before query Business Rule on sys_cs_message. Only for messages of today, for example:

(function executeRule(current, previous /*null when async*/) {

	var qc = current.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');

})(current, previous);

Query for last 24 hours could be something like:

sys_created_onRELATIVEGT@hour@ago@24

This would only show you the history of today.

You might want to add a condition to the Business Rule. Like not running for admin, virtual_agent_admin. For example:

!gs.hasRole('virtual_agent_admin')

Also test! I haven't looked if this gives other issues.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you so much @Mark Roethof 

I appreciate your quick response and efforts.