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

zica
Giga Guru

Hello Everyone,



I came accross to this forum and I really want further information.


Basically, I am setting up a chat service on SNOW Portal for end users, who are based in 6 countries (UK, FR, DE, CH, USA...).


I have been tasked to redirect users to a custom chat depending on their location.



I have seen the code above, and it is working fine for some people. My problem is I don't know where to copy and paste the code from Abhinav Khanna & Trevor Kuebler & others.



I am new on servicenow, Could you please give me more details where have you pasted this code in order to allow users a custom chat depending on their location ? A screenshot ?



Many thanks



Kind Regards.


ZA


We are using a dynamic content block to hold the code (that I provided above). We then have that dynamic content block on a content page. Below are the screenshots you asked for.



If you need any further help please let me know!





Dynamic content block:


dynamiccontentblock.PNG


dynamicblock.PNG


Content Page:


pages.PNG


(hard to add a screenshot of this, there is no code. You click EDIT PAGE then add the dynamic block. I can walk you through that if you need)


zica
Giga Guru

Thank you very much for your reply.


If I understand correctly, the code above will redirect end users to the custom chat depending on their location ? (example : if the user is from Paris and click the chat button, il will root his message to paris support team, and then if he is fron UK, it will root to the UK support ?)


Please see below my screenshots :


I have created two separate dynamic content for two countries (should I add the event all the customEvent.fire in only one dynamic content ?)


Last request : How this code above will know the location of the users ?


DynamicContent.png



What I have is below on the Portal :


Portal.PNG




Kind regards


The code from Abhinav (above) will allow multiple queues based on language. Reading through his code, it looks like there is a "preferred_language" field on the user table. Based on the preferred language of the user, Abhinav's code will direct them to the appropriate chat queue. My code directs users to a single chat queue (we only use one).



If you are wanting to use a field on the user record, such as Abhinav did, then you would use one dynamic content block. Within it you would query for the desired field to do the filtering (in his case, "preferred_language"). You would then have your logic in there to determine what preferred_language directs to what queue (based on what is stored in sys_user). You would not need multiple dynamic blocks (as developed above in your example).




Your question: How this code above will know the location of the users?


Abhinav's example shows you how to perform a query within the dynamic content block for a value on the user table. You use this value to determine which queue to use.



At the end of the day, you need to decide what you want to use to redirect them. Do you want to use a pre-defined value on their user record? Do you plan to look at their IP and base it on that? Do you want them to select from a drop down which region they prefer? There are many different ways to redirect them to the appropriate chat queue - I would start with what you ideal/preferred way is and then work towards it. For something as simple as this, you should be able to get whatever you want working.




How I would proceed:


1) Get it working for a single queue (every user goes to one queue)


2) Get it working for multiple queues, but have the user select the queue through a simple hard coded drop down


3) Get it working with your desired automated way (lookup value on sys_user, etc.)


This should get you familiar with the use of dynamic content blocks, and allows for a logical progression through the code that should be easy to follow and help you understand what each piece is doing. I assume #1 is done already, so #2 should be your next step.




Hope that helps - any questions let me know!


zica
Giga Guru

Good morming,



Million Thanks to you Trevor Kuebler for helping me. You are really an angel


In answer to your question, I am using the 'location.country', which is the sys_user table's field, to redirect user for the appropriate chat.



You are absolutly right for the point below :


- The #1 is already done. In the first instance, I have started with that and it is working fine.


- Today, I have also implemented the #2 (by following your valuable advice, thanks to you again). It is working when I click in '360 London' and '360 Paris' links (see pictures below).


- With reference to The #3, I believe that will work if I could find this specific issue below :


        Like Abhinav Khanna's script, I am trying to collect the country of the user by querying the sys_user table. But in the script, it seems, the code is not taken in account. Please find the screenshot.


#3.PNG


This is the script which I have copied and pasted. It is the same script, I only changed the condition : instead of prefered_language, I have the location.country :



based on location.PNG



If this issue is fixed, I am certain weather it will collect the country of the current user and will redirect him to the appropriate chat.


Any kind of suggestion or proposal is welcome.



Kind regards,


ZA