chat queue routing

abhinav_khanna
Kilo Expert

Hi all,

 

On the ess portal I want to give a custom link on the page which when clicked opens up the "chat" dialog box and the chat is routed to the correct assignment group based on the users country.
Any idea how to achieve that. I can not hard code the sys_id in the chatqueue function. I want something dynamic which pops up the end user chat on Click.

 

 

Regards
Abhinav Khanna

1 ACCEPTED SOLUTION

TrevorK
Kilo Sage

My initial thought would be that you want to create an "inbetween" piece that either accepts their country as input or takes one from their profile. This piece then redirects to the appropriate Chat Queue based on the result.



While I am not a CMS expert, my thoughts are that a simple way to do this would be through a dynamic content block. The user would enter their country (defaults to their profile country maybe?) and click Chat. The code in the background would then determine the appropriate Chat Queue to send it to and then just redirect to the chat queue link.



We only have one Chat Queue, and we fire it through our dynamic content block in this fashion:


      CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, 'CHAT_QUEUE_SYS_ID','CHAT_QUEUE_NAME');


I see no reason why there could not just be a little logic before to determine which Chat Queue to fire into.



On the surface, this does not seem too challenging to develop from a technical point of view, however what will be challenging is the UI/UX around this feature.



I am sorry I do not have the code developed for this, as we only use the one Chat Queue but I hope this helps. If you need anything else please post back.


View solution in original post

56 REPLIES 56

I will start by saying I am not a jelly expert, but I took a class at Knowledge15 on it and it really opened my eyes to all the things I did but didn't know why. If you attend Knowledge, or if SN is putting on a Jelly class, I would highly recommend it if you are maintaining a lot of jelly code.



Here is a blog that is a good read:


Jelly: A Tale of Two Phases...



Without going into too much detail (it might not make sense), two potential fixes are to change your two "g2" tags to "g" to evaluate it in the first phase OR switch your JEXL statements to be square brackets (so it would be $[VARIABLE] - square instead of curly).




I couldn't copy/paste your code, but I believe the condition in your j2:if is wrong as well because you are not wrapping the variable inside brackets (square or curly), but instead are wrapping your whole condition.





My thought is that you set your location to a fixed variable in your "g" or "g2" statement. Something like:


if (location.country == "") {var user_location = "United Kingdom"}


else {var user_location = user.location.country;}



Then reference the variable user_location in your "j2" statement.




I can help write it out if need be, it's just a lot of typing I am hoping to save. But if you need me to let me know! Here is a quick sample using the square brackets:


square.PNG


And here is a quick example using "g" instead of "g2":


g.PNG



Both of those work. Just to give you a visual idea of what I am talking about.




Any questions let me know!


zica
Giga Guru

Hello Trevor,


I would like to thank you for the time you spent on me and also for all you did.


Thanks a million.


My chat is working fine now. Currently, I have implemented either chat option depending on the location of users and also Chat with a drop down list (in which users can choose which country they want to chat with).



For those who may have to implement the same feature, please find the script below :



<?xml version="1.0" encoding="utf-8" ?>


  <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <div style="padding-top:100px">


  <div style="margin:0;padding:1px 4px;" class="live_workqueue_button cms_menu_vertical_blocks_container">


       


  <g:evaluate>


  var user = new GlideRecord('sys_user');


  user.addQuery('sys_id',gs.getUserID())


  user.query();


  user.next();


  var language = user.location.country;        


  </g:evaluate>


     


  <j:if test="${user.location.country== 'Your country'}">


  <a href="#" onclick="CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, CHAT_QUEUE_SYS_ID, CHAT_QUEUE_SYS_NAME); return false;"> </a>


  </j:if>



  <j:if test="${user.location.country== 'France'}">                


  <a href="#" onclick="CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, CHAT_QUEUE_SYS_ID, CHAT_QUEUE_SYS_NAME); return false;"> </a>


  </j:if>



  <j:if test="${user.location.country== 'Switzerland' || user.location.country== 'Germany'}">                


  <a href="#" onclick="CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, CHAT_QUEUE_SYS_ID, CHAT_QUEUE_SYS_NAME); return false;"> </a>


  </j:if>




  </div>


  </div>


  </j:jelly



>



<?xml version="1.0" encoding="utf-8" ?>


  <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <div style="padding-top:100px">


  <div style="margin:0;padding:1px 4px;" class="live_workqueue_button cms_menu_vertical_blocks_container">


           


  <g:evaluate>


  var user = new GlideRecord('sys_user');


  user.addQuery('sys_id',gs.getUserID())


  user.query();


  user.next();


  var language = user.location.country;            


  </g:evaluate>


         


  <j:if test="${user.location.country== 'Country of choice 1'}">


  <a   href="#"onclick="CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, CHAT_QUEUE_SYS_ID, CHAT_QUEUE_SYS_NAME); return false;"> </a>


  </j:if>



  <j:if test="${user.location.country== 'Country of choice 2'}">                    


  <a href="#" onclick="CustomEvent.fire(.............); return false;"> </a>


  </j:if>



  <j:if test="${user.location.country== 'Country of choice 3'}">                    


  <a href="#" onclick="CustomEvent.fire(..................); return false;"> </a>


  </j:if>



  <j:if test="${user.location.country== 'Country of choice 4'}">                    


  <a href="#" onclick="CustomEvent.fire(........................'); return false;"> </a>


  </j:if>



  </div>


  </div>


  </j:jelly>


Thank you to you again Trevor for all you did for me;




Kind Regards,


ZA


Thank you for sharing the script.


I am glad you got it working!



I would love to hear of any improvements you are able to make to the chat functionality in the future. We use it quite heavily ourselves and SN does not seem to give much ability to customize without heavy scripting so I always like to see what others are doing. Our last big one was integrating quick messaging into the chat sessions, and the next customization we have on our plate is allowing attachments to be sent to the chat user.



So definitely let me know if you come up with anything new!


hi AKb Zic,


As from the conversation, I can see that you have implemented, chat with a drop down for the users to select from different countries. I have same requirement, do u have the sample script for the same?


Thanks in advance