Help with vaSystem.isLiveAgentAvailable() - it is not returning the correct result

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 11:55 AM
Hello! I am hoping someone can help me out with this issue. My current version is Utah and I am trying to figure out why the vaSystem.isLiveAgentAvailable() method is returning 'true' when there are no live agents connected. I have tested this in the designer and it gives me the correct result of 'false' but when I test it in a published topic, it tells me that there are agents I can chat with and when i click to be transferred, then it says there are no live agents available. I am confused and not sure what to do to fix it.
(function execute() {
//get live agent result
if (vaSystem.isLiveAgentAvailable()) {
vaVars.agentAvailable = 'true';
//get avg wait time for queue
var avgWait = new GlideRecord('awa_queue');
if(avgWait.get('609ff3561b49e050306b55392a4bcbba')){
vaVars.waitingTime = avgWait.average_wait_time.getDisplayValue();
}
}
else {
vaVars.agentAvailable = 'false';
}
})();
Is anyone experiencing the same thing? Any suggestions of what i can do?
Thank you,
Yen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 09:00 PM
Hi, I suspect the issue is that in your code 'if (vaSystem.isLiveAgentAvailable())' doesn't test the result of vaSystem.isLiveAgentAvailable(), but tests the existence of vaSystem.isLiveAgentAvailable()
Hopefully running this in a background script will help clarify.
//var test = true;
var test = false;
if(test){
gs.info('test = true | ' + typeof test)
} else {
gs.info('test != true | ' + typeof test);
}
function test2() {
return false;
// return 'I am a string';
}
if(test2){
gs.info('test2 = true | ' + typeof test2)
} else {
gs.info('test2 != true | ' + typeof test2);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2023 01:48 PM
I tried this approach but i keep getting the same results unfortunately. I can see the correct value when i test it in the designer but when i test it in the topic, it tells me that there are agents available when no agents are signed in. I am trying to figure out why it's giving me the incorrect value but getting no where.
Test from designer:
Test from topic:
and when i click on the option to talk to an agent, then it says there are no agents available.
It is so confusing and i don't know what I am missing lol
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2023 04:40 PM
Hi, when you state 'I tried this approach' does this mean that you updated and tested your 'if' statement so that it tests the result that is returned by the call? IE
if (vaSystem.isLiveAgentAvailable() == true) {
for debugging you could also log the result of the call and use typeof to confirm that the result is a boolean value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 08:31 AM
Hi Tony,
Yes, this is what i did and i got the same results
bot response script 1:
(function execute() {
var test = vaSystem.isLiveAgentAvailable();
if(test){
return ('test = true | ' + typeof test);
} else {
return ('test != true | ' + typeof test);
}
function test2() {
return false;
}
if(test2){
return 'test2 = true | ' + typeof test2;
} else {
return 'test2 != true | ' + typeof test2;
}
})()
bot response script 2:
(function execute() {
if (vaSystem.isLiveAgentAvailable() == true) {
return "vaSystem.isLiveAgentAvailable returned true";
}
if (vaSystem.isLiveAgentAvailable() == false) {
return "vaSystem.isLiveAgentAvailable returned false";
}
})()
Output in designer:
Output in the published topic in the portal:
So still confused on what the reason is for this behavior. Please let me know if I did something wrong when testing this. I really appreciate it!