Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to open virtual agent chat bot automatically when after page loading?

Community Alums
Not applicable

We have virtual agent chat in out home page of portal and we want it open/pop up automatically when page loading finishes. It there any way through programming or configuration setting to make it happen?

 What exactly should be the code changes? I f somebody has done it earlier please paste it over here too.

1 ACCEPTED SOLUTION

- Clone the out-of-the-box widget
- Apply the cloned widget to your Service Portal page or header/footer
- Update the Client controller and CSS script like below

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

33 REPLIES 33

Hi Mark Could you share the script again I cant see it attachment is not there

@Mark Roethof  thank you for detail explanation.

 

I have cloned virtual agent widget and kept it in footer.

In above it is opening on initial home page load as well so How to restrict to open virtual agent window to first click that means if user logged in i don't want virtual agent window to open.

only when user click on it should open but when user has opened virtual agent it should be opened in next page of the portal how to achieve this ?

find_real_file.png

 

find_real_file.pngfind_real_file.png

once i click on the incident link it is opening other page on the other page virtual agent window is not active if i have to open again i have to click. i saw client script and CSS but it didn't helped.

 

I have cloned it and configured it in footer if i use agent chat configuration it is behaving as i have explained (when VA is open it is still open in next page of portal)

please help if i am going wrong somewhere.

 

 

find_real_file.png

 

 

please help @Mark Roethof 

dants
Kilo Contributor

Nice solution from Mark, as ever.

If you're cloning the widget, there is another way, which is to trigger the toggleWindow() function in the widget Client controller.  You could do this every time the widget loads, or introduce some controls over it by using a $scope.on listener in the VA widget, and then doing a broadcast/emit from any other widgets on your page.

As an example of the latter, we show calculate and show counts of open requests and approvals in the our SC portal header.  When the header loads, we check for the page id (only on the home page) and whether there are open requests or approvals.  If these conditions are met,we make that broadcast, which is picked up by the VA widget listener and calls the toggleWindow() function.

Amarendra3
Kilo Contributor

Hi dants,

I tried to call the toggleWindow() function inside div tag, but was not able to open the chat bot on load.

-------------------------------------------------------------------------------------

<div class="conversation-button-container" onLoad="$ctrl.toggleWindow()" >
<div class="conversation-region fade"
ng-class="{'open': $ctrl.isWindowVisible}">
<div class="sn-connect sn-connect-floating">
<div class="sn-connect-floating-wrapper loaded">
<div class="conversation-container">
<iframe title="${Chat Support}" class = "chat-frame" scrolling="no" horizontalscrolling="no" verticalscrolling="no" frameborder="none" ng-src="{{$ctrl.vaSource}}">
</iframe>
</div>
</div>
</div>
</div>


<button
aria-label="${Start Support Conversation}"
class="help-button"
ng-attr-tabindex="0"
ng-class="{'state-open': $ctrl.isWindowVisible, 'state-unread': $ctrl.hasUnreadMessages}"
ng-click="$ctrl.toggleWindow()"
ng-style="{'background-color': $ctrl.options.button_color}"
ng-attr-tabindex="0"
>
<div class="hover-overlay"></div>
<span aria-hidden="true" ng-class="$ctrl.isWindowVisible ? 'help-icon icon-close icon-cross' : 'help-icon icon-open sn-va-widget-icon'"></span>
</button>


</div>

--------------------------------------------------------------------------------------------

Can you help to identify the issue or appropriate way of calling function.

 

Thanks you in advance.

Lener Pacania1
ServiceNow Employee
ServiceNow Employee

Hi Mark,

Will your solution only work for the legacy Virtual Agent widget?  Will this also work for the new Virtual Agent chat widget that we access via Service Portal > Agent Chat?

Best Regards, Lener