Auto-close Virtual Agent chat if user is inactive for 2 minutes

nagaklv
Tera Contributor

Hi Experts,

 

In Virtual Agent, how can we automatically close a chat session if the user does not respond for more than 2 minutes during an active conversation with an agent?

Is there any out-of-the-box option available to handle inactivity timeout?
If not, what would be the recommended approach to achieve this?

Appreciate any suggestions or examples.

 

Thanks!

Nagesh

3 REPLIES 3

Dr Atul G- LNG
Tera Patron

Hi @nagaklv 

 

https://www.servicenow.com/community/virtual-agent-nlu-forum/how-to-automatically-close-the-virtual-...

 

To auto-close a Virtual Agent (VA) chat after 2 minutes of inactivity, update the ServiceNow system properties com.glide.cs.conversation_idle_timeout and com.glide.cs.idle_chat_cancel_timeout to 120 seconds. Additionally, configure the Time Out Abandoned VA Conversations scheduled job to run frequently to ensure idle chats are closed promptly. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Tanushree Maiti
Kilo Patron

Hi @nagaklv ,

Refer this servicenow Documentation &  helpful article: 

Controlling idle live chat sessions 

Understanding Virtual Assistant Timeout Settings

 

How to Change the Timeout:

To make this change, there are two things involved:

System Property: There's a setting called "com.glide.cs.conversation_idle_timeout" that controls the timeout duration.

Scheduled Job: A background process named "Time Out Abandoned VA Conversations" needs to be updated to run regularly and clear out inactive chats according to the new timeout.

 

If the property does not exist you can create one. The OOB setting of the property is 24 hours in seconds [Integer - 86400]. Similarly, the job has to be configured periodically. 

 

Change the idle chat timeout values

Add the com.glide.cs.idle_chat_reminder_timeout and the com.glide.cs.idle_chat_cancel_timeout properties to the System Property [sys_properties] table to set the chat reminder message timeout and the idle chat cancel timeout values. Create both properties at the same time.

  1. As admin, navigate to All, and then enter sys_properties.list in the filter.
  2. Select New to add the com.glide.cs.idle_chat_reminder_timeout property.
    1. On the form, fill in the fields.
       Field Value
      NameSystem property name. Enter: com.glide.cs.idle_chat_reminder_timeout
      DescriptionExplanation for this property. For example: Idle chat reminder timeout (in seconds)
      TypeData type. Select integer.
      ValueEnter the number of seconds before the idle chat reminder message is displayed, after the requester's last response. This value must be equal to or greater than 120 seconds, since the Idle Chat Timer Task job runs every 120 seconds to check active chat sessions.

      For example, if the idle chat reminder message is to be displayed 5 minutes after the requester's last response, enter 300 seconds.

      Note:
      If you want to set an idle chat message reminder timeout that is under 120 seconds, you must also change the time at which the Idle Chat Timer Task job runs. The job must check for idle chats within a shorter time frame. For example, if the reminder message timeout is 60 seconds after the requester's last response, set the Idle Chat Timer Task job to run every 60 seconds. For more information on base system scheduled jobs, see System scheduler.
    2. Select Submit.
  3. In the System Properties table, select New to add the com.glide.cs.idle_chat_cancel_timeout property.
    1. On the form, fill in the fields.
       Field Value
      NameSystem property name. Enter: com.glide.cs.idle_chat_cancel_timeout
      DescriptionExplanation for this property. For example: Idle chat cancel timeout (in seconds)
      TypeData type. Select integer.
      ValueNumber of seconds before an idle chat is canceled (times out). This value must be larger than com.glide.cs.idle_chat_reminder_timeout, where the difference between this value and com.glide.cs.idle_chat_reminder_timeout is larger than or equal to 120 seconds (2 minutes, which is when the Idle Chat Timer Task job runs).

      For example, if the reminder message timeout value is 300 seconds (5 minutes), the idle chat cancel timeout value must be 420 seconds or greater.

      Note:
      If you changed the Idle Chat Timer Task job, the difference between the chat cancel timeout value and the idle chat reminder timeout must be larger or equal to the Idle Chat Timer Task job time. For example, if the reminder timeout is 60 seconds and the Idle Chat Timer Task job is also 60 seconds, the idle chat cancel timeout value must be 120 seconds or greater.
    2. Select Submit.

Set the inactivity timeout behavior

The com.glide.cs.start_idle_timeout_after_agent_response property determines the timeout behavior when inactivity is triggered. When this property is true, the inactivity timer does not start until the agent sends a non-automated response to the requester.

  1. As admin, navigate to All, and then enter sys_properties.list in the filter.
  2. Select New to add the com.glide.cs.start_idle_timeout_after_agent_response property.
    1. On the form, fill in the fields.
       Field Value
      NameSystem property name. Enter: com.glide.cs.start_idle_timeout_after_agent_response
      DescriptionExplanation for this property. For example: Timeout behavior when inactivity should be triggered.
      TypeData type. Select true/false.
      ValueEither true or false.
    2. Select Submit.

Set the server disconnect timeout for guest conversations

The com.glide.cs.chat_disconnect_timeout property determines how long the system will wait to reconnect a disconnected conversation before it ends the chat. If communication is reestablished during that timeframe, the conversation resumes.

  1. As admin, navigate to All, and then enter sys_properties.list in the filter.
  2. Select New to add the com.glide.cs.chat_disconnect_timeout property.
    1. On the form, fill in the fields.
       Field Value
      NameSystem property name. Enter: com.glide.cs.chat_disconnect_timeout
      DescriptionExplanation for this property. For example: Timeout behavior for disconnected guest conversations.
      TypeData type. Select integer.
      ValueNumber of seconds before a disconnected guest chat is canceled (times out). The client will try to reconnect during that time.
    2. Select Submit.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

ChallaR
Giga Guru

Hi @nagaklv ,

Hi  ,

 

There is an out-of-the-box (OOB) way, but it may not exactly match your “2 minutes” requirement unless you configure it.

OOB Capability (What ServiceNow Already Provides)

ServiceNow already handles idle chat sessions using system properties + a scheduled job.

🔹 Key OOB properties:

  • com.glide.cs.idle_chat_reminder_timeout
    → Time before sending a warning message (default: 180 sec / 3 min)
  • com.glide.cs.idle_chat_cancel_timeout
    → Time before auto-closing the chat (default: 360 sec / 6 min)
  • Scheduled Job: Idle Chat Timer Task
    → Runs every ~2 minutes to evaluate inactivity

NOTE -

  • The system doesn’t close the chat exactly at your timeout.
  • It depends on the scheduled job (runs every 2 minutes), so delays can occur.

 

Option 1: Configure OOB Properties (Recommended)

You can achieve this without scripting:

Set:

 

 

com.glide.cs.idle_chat_reminder_timeout = 60   (optional warning at 1 min)
com.glide.cs.idle_chat_cancel_timeout   = 120  (close at 2 min)

 

 

This will:

  • Warn user at 1 min (optional)
  • Close chat at 2 min inactivity

Also check:

  • Ensure Idle Chat Timer Task is active
  • (Optional) Reduce its run interval to 1 min for more accuracy

 

 

2: Custom Approach

Approach:

  • Use Scheduled Script / Business Rule on:
    • sys_cs_conversation
  • Check:
    • Last activity time
    • Conversation state
  • Close conversation programmatically

Sample Logic:

var gr = new GlideRecord('sys_cs_conversation');
gr.addQuery('state', 'active');
gr.query();

while (gr.next()) {
    var lastActivity = gr.sys_updated_on;
    var now = new GlideDateTime();

    var diff = gs.dateDiff(lastActivity, now, true); // seconds

    if (diff > 120) { // 2 minutes
        gr.state = 'closed';
        gr.update();
    }
}
I highly recommend to  Use OOB properties first → simplest and supported 
 
Thanks,
Rithika.ch