- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2023 11:19 PM - edited ‎07-01-2023 04:43 PM
We are using a third party for call/chat handling so the agent status's never change in AWA and that caused me some issues attempting to transfer to a live agent. I in turn created a on update business rule on the awa_agent_presence table to keep the Virtual Agent account online. The condition is 'Current presence state' is not 'Available'. I do have scheduled jobs set to turn on and off the Virtual Agent (same code as below) at the beginning and end of the day. For the turning on of the Virtual Agent I have a conditional item set in order to adjust for our holiday schedule.
(function execute() { var VAagent = new GlideRecord('awa_agent_presence'); VAagent.addEncodedQuery('agent=ENTER SYS ID HERE OF ACCOUNT'); VAagent.query(); while (VAagent.next()) { var gdt = new GlideDateTime(); var localTime = gdt.getDisplayValue().toString().split(' ')[1]; var dayOfWeek = gdt.getDayOfWeekLocalTime(); var hour = localTime.split(':')[0]; if (hour > 19 || hour < 8 || dayOfWeek == 6 || dayOfWeek == 7) { //After Hours VAagent.current_presence_state = '9cd83267575313005baaaa65ef94f98b'; //sys_id for Offline VAagent.setWorkflow(false); //Do not run business rules VAagent.autoSysFields(false); //Do not update system fields VAagent.update(); } else { //Work Hours VAagent.current_presence_state = '0b10223c57a313005baaaa65ef94f970'; //sys_id for Available VAagent.setWorkflow(false); //Do not run business rules VAagent.autoSysFields(false); //Do not update system fields VAagent.update(); } } })()
Condition of turning on the Virtual Agent
function checkSchedule() { var schedule = new GlideSchedule("ENTER SYS ID HERE"); //THIS IS MY HOLIDAY SCHEDULE if(schedule.isInSchedule(new GlideDateTime())){ return false; } else { return true; } } checkSchedule();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2023 11:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2023 11:14 PM - edited ‎06-28-2023 11:17 PM
This was not working correctly for me once I added in the holiday schedule, so I changed it up a little. Moving the schedule into the script I no longer needed the conditional holiday schedule.
(function execute() {
var VAagent = new GlideRecord('awa_agent_presence');
VAagent.addEncodedQuery('agent=sys_id'); //sys_id for Virtual Agent
VAagent.query();
while (VAagent.next()) {
var schedule = new GlideSchedule("HELPDESK_HOURS_SYS_ID"); //Enter sys_id of cmn_schedule record
if (schedule.isInSchedule(new GlideDateTime())) {
//Work Hours
VAagent.current_presence_state = '0b10223c57a313005baaaa65ef94f970'; //sys_id for Available
VAagent.setWorkflow(false); //Do not run business rules
VAagent.autoSysFields(false); //Do not update system fields
VAagent.update();
} else {
//After Hours
VAagent.current_presence_state = '9cd83267575313005baaaa65ef94f98b'; //sys_id for Offline
VAagent.setWorkflow(false); //Do not run business rules
VAagent.autoSysFields(false); //Do not update system fields
VAagent.update();
}
}
})()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2023 11:58 PM
No solution needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2023 11:14 PM - edited ‎06-28-2023 11:17 PM
This was not working correctly for me once I added in the holiday schedule, so I changed it up a little. Moving the schedule into the script I no longer needed the conditional holiday schedule.
(function execute() {
var VAagent = new GlideRecord('awa_agent_presence');
VAagent.addEncodedQuery('agent=sys_id'); //sys_id for Virtual Agent
VAagent.query();
while (VAagent.next()) {
var schedule = new GlideSchedule("HELPDESK_HOURS_SYS_ID"); //Enter sys_id of cmn_schedule record
if (schedule.isInSchedule(new GlideDateTime())) {
//Work Hours
VAagent.current_presence_state = '0b10223c57a313005baaaa65ef94f970'; //sys_id for Available
VAagent.setWorkflow(false); //Do not run business rules
VAagent.autoSysFields(false); //Do not update system fields
VAagent.update();
} else {
//After Hours
VAagent.current_presence_state = '9cd83267575313005baaaa65ef94f98b'; //sys_id for Offline
VAagent.setWorkflow(false); //Do not run business rules
VAagent.autoSysFields(false); //Do not update system fields
VAagent.update();
}
}
})()