- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 11:03 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2014 11:48 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2015 10:05 AM
One way to do this is to setup a Content Page with a Dynamic Content Block. This is the code we use (as this is how we do ours - we only have one queue). When you go to this URL it automatically connects you to the Chat Queue:
<script>
function startChat()
{
if(document.getElementsByClassName('gb_mw').length == 0)
{
CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, 'SYS_ID_OF_QUEUE','TITLE OF QUEUE');
}
}
setTimeout(startChat,200);
</script>
<a href="#" onclick="startChat();"></a>
Navigating to this link (your Content Page that contains the above Dynamic Block) automatically triggers the Chat Desktop for the client.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2015 07:49 PM
Hi Trevor Kuebler,
Here what we want to achieve is, we will send a URL to user in email to chat with service desk. Whenever they clicks this URL it should open chat window to chat directly. It is possible through above code but when user login to system manually without hitting the URL in email it should not open chat window directly...
Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2015 09:07 PM
I think we have to sort of look at the limitations of what you want to do - the URL in the email is opened up in your internet browser. Your browser does not know where the link came from (manually typed in, opened from email, etc.). If you are expecting the exact same URL to behave differently based on how the internet browser got it, I think you may be in for a challenge. This eliminates the obvious solutions of just passing a parameter in because they could pass that same parameter in by typing it in manually.
I would think that a typical workaround would be to generate a "session id" within the link. The "session id" will be a one-time use code, and once it is used, cannot be used again. You will maintain these "session id" values and you would use scripting to generate it and the dynamic page (above) to check if it's valid, so if someone tried to use a "session id" twice they would be given an error message.
Someone with more web development experience might have a different solution, but I just cannot see how you could treat the exact same URL differently based on whether it was opened from an email or manually typed in. I assume there would have to be something in the link to differentiate it. Unless I am missing something with your requirements that is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2015 08:10 AM
Hi Trevor Kubler,
I have created new dynamic content block like this asper our requirement
<script>
var user = new GlideRecord('sys_user');
user.addQuery('sys_id',gs.getUserID())
user.query();
user.next();
var language = user.preferred_language;
function startChat()
{
if(document.getElementsByClassName('gb_mw').length == 0)
{
if(language == 'en')
{
CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, 'c54f0abf0a0a0b452db84664f409c79c', 'Service Desk Chat');
}
if(language != 'en')
{
CustomEvent.fire(LiveEvents.LIVE_EVENT, LiveEvents.LIVE_WINDOW_JOIN_QUEUE_QUERY, 'cf939eb30fc85200c33445ace1050ea7', 'Service Desk Chat1');
}
}
}
setTimeout(startChat,200);
</script>
<button type="button" onclick="startChat();">Click Me!</button>
But what happening here is chat window is not opening directly it is opening when I am clicking the button only.
Something I am missing here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2015 08:38 AM
Just to provide some background, this is the part of your code that creates the button and runs the function when the button is clicked:
<button type="button" onclick="startChat();">Click Me!</button>
So, what we need to do is run your function when the page loads, rather than when someone clicks a button. Below is one way to do it - there are many, many different ways to do it. I kept the sample completely generic so that you can run the code by itself and understand what it is doing. What should happen when you navigate to a page with this Dynamic Content block is that an alert window pops up and when you click OK it redirects you to google.com.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<script>
window.onload = function() { startChat();};
function startChat() {
alert("Test onLoad");
window.location.assign("http://www.google.com");
}
</scri
So how can we apply this to your scenario? Well, you can use the window.onload to call your custom function and logic. Again, there are many ways to execute commands when a page loads and this is just one example. Other ways would be with event listeners, the HTML body onload ability to call the function, etc.
Hope this makes sense - it's fairly straight forward but I wanted to give you an example you can cut and paste into your system that will let you see what each piece of the code is doing before you start putting in your own code.