This demo shows you how to use monitor tag and render department list directly. In this example, mylivechat ID is 68268000. You need to replace it with your own mylivechat ID.
chatapi.aspx
MyLiveChat.Departments
MyLiveChat.Departments[i].Agents[j].Online
MyLiveChat_OpenDialog()
Edit/Test this code now