Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Virtual Chat Agent

Akhil32
Tera Contributor

Hi Team,

When a user ends a live chat with an agent, the bot displays a message: “Thank you for contacting us. The chat has ended.” After this, if the user clicks the text area that says, “Click here to start a new conversation,” the chat reopens in the same bot window and automatically assigns another agent. We want to restrict this behavior. If the user clicks on that text, instead of reopening the chat. We can make it read-only not to click the that. if they close the chat window and open the new chat it should editable. See the attached image

how can we achieve this

Akhil32_0-1762356129949.png

 



 

 

2 REPLIES 2

Anupam1
Kilo Guru

Hi @Akhil32 ,

 

To prevent users from reopening a live agent chat by clicking “Click here to start a new conversation” in the same window, you’ll need to customize the Virtual Agent widget behavior using client-side scripting and session state logic. You can make the input field read-only after chat ends and re-enable it only when the chat window is reopened.

 

 

How to Restrict Reopening Chat in Same Window

  1. Customize the Virtual Agent Web Client Widget

If you're using Service Portal or Next Experience, locate the widget responsible for rendering the Virtual Agent chat interface. This is typically:

  • Widget Name: Virtual Agent Web Client
  • Found under: Service Portal > Widgets

You’ll need to modify the widget’s client controller and HTML template.

 

2.  Detect End of Conversation

Use the conversationState or sessionState object to detect when the chat has ended. For example:

if (conversationState === 'ended') {

    $scope.chatInputDisabled = true;

}

In the HTML:

<input type="text" ng-model="userInput" ng-disabled="chatInputDisabled" />

This disables the input field once the conversation ends.

 

3. Prevent Reopening Until Window Is Reset

To allow chat only after the window is closed and reopened:

  • Store a flag in sessionStorage or localStorage when the chat ends.
  • On widget load, check if the flag exists:
  • if (sessionStorage.getItem('chatEnded')) {
  •     $scope.chatInputDisabled = true;
  • }
  • When the user closes and reopens the chat window, clear the flag:
  • sessionStorage.removeItem('chatEnded');

This ensures the input field is only re-enabled on a fresh session.

 

Optional Enhancements

  • Display a message like “Please close and reopen the chat to start a new conversation.”
  • Hide the input field entirely instead of disabling it.
  • Use a custom end-of-chat action to trigger the disable logic.

 

Why This Works

  • Prevents accidental re-engagement with live agents.
  • Ensures session integrity and avoids duplicate assignments.
  • Improves user experience by guiding them to restart properly.

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Thanks,

Anupam.

 

 

Akhil32
Tera Contributor

I don't see such widget, but we have  Virtual Agent Service Portal Widgets