Virtual Agent topic visibility using vaContext.portal persists across portals in same session

ashutoshkum
Tera Contributor

Hello Community,

I have implemented portal-based topic visibility in ServiceNow Virtual Agent using vaContext.portal, but I’m facing an issue where the portal context is not refreshing correctly between portals.

My setup:

  • I have two Service Portal portals (for example: sp and esc)

  • Same Virtual Agent widget is used on both portals

  • In Virtual Agent topic Properties → Condition, I’m using:

    (function execute() {
     
            if(vaContext.portal == 'esc'){
                    return true;
            }else{
                   return false;
            }

    })()

     

 

Expected behavior:

Topics should be visible only on their respective portals.


Actual behavior:

When I first open VA on portal sp, vaContext.portal is correctly set to sp and topics behave as expected.

But when I then open VA on portal esc (same user/session/browser):

vaContext.portal still holds value sp, and topics remain hidden on esc.

It seems the VA web client session/context is being reused and not refreshing the portal value per launch.


What I tried:

  • Verified iframe URL contains correct sysparm_portal

  • Logged vaContext using gs.info(JSON.stringify(vaContext))

  • Topic condition logic is correct

But context still persists from first portal load.


My questions:

  1. Is Virtual Agent context cached across portal launches in the same session?
  2. Is there a supported way to refresh/reset VA context per portal?
  3. Is using sysparm_reset=true or cache-buster parameters the right approach
  4. Is there a better OOTB approach for portal-specific topic visibility?

Any guidance from those who have implemented multi-portal VA setups would be appreciated.

Thank you!

0 REPLIES 0