Reset Chat when Agent ends Salesforce Enhanced Chat Session
Feb 19, 2026
Show More Show Less
View Video Transcript
0:08
Hello everyone. In this video, we are
0:10
going to see how to reset the chat when
0:13
an agent ends a Salesforce enhanced chat
0:17
messaging session.
0:19
I had an use case where
0:23
the chat widget in which the end user is
0:27
chatting with an real human agent
0:32
should be closed or it should be cleared
0:36
when the agent ends the chat. Let's say
0:40
I am the human agent with uh whom you
0:44
are uh having the conversation.
0:48
As an human agent, I was able to assist
0:50
and then I'm going to end the chat. Once
0:53
I end the chat as a end visitor,
0:57
the user experience what you have you
1:00
will be facing with this video as a
1:02
references
1:04
the chat widget will be closed and then
1:07
the session will be cleared.
1:09
As an end user, if you wanted to
1:12
initiate a new chat, then you have you
1:15
can click the chat icon which appears on
1:17
the bottom right corner and then it will
1:19
start a new session.
1:22
Let's see a demo and then we will deep
1:24
dive into the technical implementation
1:27
of this particular use case.
1:31
This is the site where my uh Salesforce
1:34
enhanced chat is hosted.
1:41
As an end uh um user,
1:45
I have to initiate the chat here. As a
1:48
service agent, I have set my status to
1:51
messaging. So, I will be able to accept
1:54
the
1:55
messaging session records.
1:59
Let me
2:02
Okay, I'm going to initiate a chat.
2:10
Okay, let me go offline and online.
2:19
Let me reload it.
2:23
Okay, let me go available for messaging.
2:29
As a service agent, I'm able to initiate
2:32
the sorry, I am able to accept the
2:35
messaging session record. Let me send
2:37
some test messages.
2:41
As an end user, I can send a message.
2:45
Okay. Now,
2:49
as a service agent, I'm going to end the
2:51
chat. I was able to assist
2:55
the end user
2:58
will experience automatically closing
3:00
the chat widget and then they will be
3:02
able to see the chat icon here. So I'm
3:06
going to end the chat.
3:10
It says agent ended the chat
3:13
and then it closed the chat widget. As
3:16
an end user, you can still click this
3:18
chat icon and initiate a new chat uh
3:21
session.
3:24
So here it created a new messaging
3:27
session record and then it got routed to
3:30
an human agent.
3:33
So again if I end the chat it is saying
3:36
the agent ended the chat and then it
3:39
closed the chat widget and then the chat
3:42
icon is still available and visible so
3:44
that the end users can initiate the chat
3:50
in in order to achieve this particular
3:52
use case
3:55
I am making use of on embedded messaging
3:58
session status update event. I'm
4:01
listening to this event
4:04
and then I'm checking whether the
4:06
previous status is active, current
4:08
status is ended and whether the role of
4:12
the user who ended it is agent.
4:17
Next, with the help of embedded service
4:20
bootstrap dot user verification API.CL
4:23
clear session method I am able to clear
4:26
the messaging session so that the chat
4:28
widget will be minimized or closed and
4:32
then the end users will be able to
4:34
initiate new messaging session record
4:36
with the help of the chat icon
4:39
so this is the event uh listener
4:43
I'm listening to this on embedded
4:45
messaging session status update event
4:49
I'm checking whether the current status
4:51
is ended the previous status was active
4:55
and also I'm confirming whether the
4:57
session is ended by the agent or not.
5:00
Once it is confirmed using embedded
5:03
service bootstrap dot userverification
5:06
API.CL clear session method I am able to
5:09
clear the session.
5:13
If I go to the site and then if I click
5:15
view page source.
5:18
So this is the event listener which is
5:21
added.
5:23
to the existing code.
5:31
I have also given some best practices
5:33
and recommendations if you wanted to
5:35
make use of this sample JavaScript code
5:38
which is given for reference purpose.
5:48
Please check the video description. In
5:50
the video description, I have shared my
5:51
blog post. From the blog post, you
5:53
should be able to get this sample
5:55
JavaScript code for your reference.
6:08
I hope it was helpful.
6:20
Thank you for watching.
#Internet Software
