Open a Topic Automatically onclick of a button

Sai Chetan
Tera Contributor

Hi,

We have a report an Incident button in our portal. When a user click on that button it should open the Virtual Agent with Report an Incident topic. we were able to Open VA on click of the button, but unable to start the topic automatically. Is there any way this can done

@Mark Roethof Can you please help on this?

Thanks,

Sai chetan

9 REPLIES 9

I have 1 more question

when a user opens VA it should open All topics and when user opens VA using Report an Incident button, it should open Report an Incident topic and stop existing topic if any. Can you help how can we modify the toggleWindow method to achieve this?

I have tried this and highlighted my changes in yellow, but it is not working.

 $ctrl.createIncident = false;

 $rootScope.$on('customEvent', function(event,obj) {
        $ctrl.createIncident = true;
      $ctrl.toggleWindow();
  });

$ctrl.toggleWindow = function() {
      
        if ($ctrl.isWindowVisible) {
            $ctrl.isWindowVisible = false;
            $timeout(function() {
                if (!$ctrl.isWindowVisible) {
                    $element.find('.conversation-container').css("display", "none");
                    $element.find('.sn-connect-floating').css("display", "none");
                    $element.find('.sn-connect-floating-wrapper').css("display", "none");
                    
                    // ios overlay hacky fix.
                    $document.find('.touch_scroll').css("-webkit-overflow-scrolling", "touch");
                }
            }, 300);
        } else {
            if (!$ctrl.firstPress) {
                $ctrl.firstPress = true;
                $ctrl.vaSource = '/$sn-va-web-client-app.do?sysparm_nostack=true&sysparm_stack=no';
              
                if($ctrl.createIncident)
                   {
                $ctrl.createIncident = false;
                  $ctrl.vaSource = '$sn-va-web-client-app.do?sysparm_skip_load_history=true&sysparm_topic=a91fe98b2f1710103e50a55df699b662';
                   }
                
     if ($ctrl.options.va_url_params) {
                    $ctrl.vaSource = $ctrl.vaSource  +  '&' + $ctrl.options.va_url_params;
                }
             
            }
         
            
            $ctrl.isWindowVisible = true;
            $ctrl.hasUnreadMessages = false;
            $element.find('.conversation-container').css("display", "block");
            $element.find('.sn-connect-floating').css("display", "block");
            $element.find('.sn-connect-floating-wrapper').css("display", "block");
            
            // ios overlay hacky fix.
            $document.find('.touch_scroll').css("-webkit-overflow-scrolling", "auto");
        }
    };

Have to think about this one... will get back on this.

Though my first thought would be looking at influencing the va_url_params options.

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

Hi @Sai Chetan (and @Mark Roethof ) -- I am trying to implement this same type of solution now but am running into some issues. My custom button does not open the VA pop-up like clicking the VA icon at the bottom-right does.

 

I have a widget that broadcasts (I see a console.log after my broadcast so I believe it is working); however, the data does not appear to be received from the VA widget. I have nearly mirrored the code above, and have injected $rootScope into the top line of my controller.

 

Any ideas? Have you seen the pop-up via another button anywhere else?

 

EDIT: Mark, I saw your post (https://www.servicenow.com/community/virtual-agent-nlu-articles/toggling-virtual-agent-chat-client-u... but am still trying to pass through a topic directly and am struggling

Chris D
Kilo Sage
Kilo Sage

I just want to add that you might want to be careful because it could have unintended consequences:

Use the sysparm_topic parameter only to load the given topic in the Service Portal chat client or when using the IBM Watson Assistant chat integrations (com.glide.cs.ibm.watson.assistant.topic and com.glide.cs.ibm.watson.assistant.topicV2 plugins). This parameter doesn’t allow users to start a new conversation or transfer to a live agent. It also disables the context menu and doesn't support other third-party chat clients.

This functionality changed from Madrid to New York/Orlando and I was going to do something real similar to you but it would have crippled the VA.

Your implementation was slightly different though so maybe it'll be different? I fed the topic ID to the URL and then just had the widget check to see if the URL had a topic specified and then started that topic.

Yes totally agree, be careful with this and test if your situation suits using this. Because it indeed has some consequences.

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

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

LinkedIn