Question
The routing workflow using triggers described in the article Automatically route chats to departments does not take into account a specific department’s online status. Is it possible to show the Web Widget as online for Chat on my webpage only if a certain department is online?
Answer
It is not natively possible to display the widget when specific departments are online, but you can create a custom script with the use of Zendesk API. With a custom script, you can configure the Web Widget (Classic) to present Chat only when a specific department is online. The script will identify a change in the account’s department status and the API will update the settings for the Web Widget (Classic) as desired based on the current department status.
Below is an example API script that uses this method. This example shows the Web Widget as online for Chat only when the CRM department is online. If the department's CRM status is not online, Chat is suppressed. When Chat has been suppressed only other enabled features of the Web Widget (Classic) are shown to the visitor. For example, the contact form or help center search.
<script id="ze-snippet"
src="https://static.zdassets.com/ekr/snippet.js?key=ACCOUNT_KEY"> </script>
<script>
zE('webWidget:on', 'chat:departmentStatus', function(dept) {
if (dept.name === 'CRM' && dept.status === 'online') {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
departments: {
enabled: [''],
select: 'CRM'
},
suppress: false
}
}
});
} else if (dept.name === 'CRM' && dept.status !== 'online') {
zE('webWidget', 'updateSettings', {
webWidget: {
chat: {
suppress: true
}
}
});
}
});
</script>
24 comments
Fred Thomas
This is a great resource @...! Given the example of the singular dept. "CRM", what would the code look like for multiple dept, say "CRM", "HR, and "Sales" for instance?
0
Eric Ypsilantis
I'm glad to hear you find the article helpful, @...! You know, I had been asked this before back when I was less dangerous with JavaScript, and didn't think it would be possible given how I'm using the API - but let me ponder this and I'll get back to you here. Is the idea to only show the widget as online if a subset of the departments is online, but then not set the department to use in the widget automatically (let the user choose)?
0
Maky
Hi Eric.
Great article for me!
However in this link said that has to word automatically this doesn't happen.
Thanks!
Maria
0
DJ Buenavista Jr.
Hi Maria,
Thank you for reaching out to Zendesk Support.
In regards to your concern, the following article mentioned how to present chat if a specific department is online. This means that the end-users can only access chat once a specific or the set department agents are online.
The following instructions in this link are custom and it's not a native feature in Zendesk. As the disclaimer in this article mentioned, "This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online."
Thank you!
Kind regards,
DJ Buenavista Jr. |
Customer Advocacy Specialist |
0
Abdo
thank you all 😊
0
Maky
Hi @...
When I said "However in this link said that has to work automatically this doesn't happen." I'm talking about this link:
https://support.zendesk.com/hc/en-us/articles/4408836216218-Using-Web-Widget-Classic-to-embed-customer-service-in-your-website
" If Chat is the only contact option enabled and no agents are online, the launcher does not display."
I'm not taking about the current link.
Is that what you said?
Maria
0
Paolo
Good day! I would be taking your question on behalf of DJ. For this to work, you have to make sure that Chat is the only contact option enabled in the web widget settings(see screenshot below). Sometimes, the changes don't reflect right away after you save it due to caching issues. So if in case you already enabled the option to Chat only and you still can see the widget appearing even if all agents are offline, you may try clearing cache and cookies or open your Help Center on another browser.
Since Zendesk does not guarantee the codes above, and if in case you have added them in your widget, that could affect its native function and possibly compromise some of its expected behavior.
I hope this helps!
0
Chris Smith
I'm not seeing a definitive answer to the first question posed on this thread. If there are multiple departments, each with varying hours of ops, then what is the most efficient means of preventing the chat widget for a closed Department A while Department B & C are open? I have to believe this is not a rare scenario for other organizations.
1
Walter
Hi Chris,
Perhaps modifying the javascript like this would help. However, the available departments would become visible in a dropdown list.
0
Luca Baldini
Before it was enough to insert this API and everything worked correctly:
chat: {
departments: {
enabled: ['GROUP1'],
select: 'GROUP1'
}
}
The chat button would only appear if the department was online, even if there were other departments active.
Why doesn't it work now?
Is this a bug that will be fixed?
Thank you very much
0
Dane
The script you have provided is still working. However, it is only applicable directly for Chat. If you have Ticket Submission enabled on your widget, it will still show even your departments are offline.
0
Luca Baldini
Hi Dane,
I have disabled the contact form, I have disabled the offline chat form, but in the widget the offline form is shown (the specific department of the widget indicated by the API is offline).
The widget doesn't care about the department indicated in the API.
It only works if all departments are Offline.
Since March 1 the problem started.
0
Dane
I have tried it on my end and it worked by disabling the offline form. If you have also performed it and the same behavior persisted, contact support directly and we'll investigate further.
0
Chris Smith
Luca,
Just curious if you've made progress on this. Our account has multiple departments with varying hours of ops. Chat suppression code in place and contact form has been disabled. Nonetheless, we see "missed conversations" daily as Zendesk attempts to route chats from a closed department to an agent in an open department. Hard to believe there isn't an efficient way to solve this.
0
Luca Baldini
Hi e.campus,
my technicians have built a custom code to solve the problem. We used the code written by Eric. Zendesk does not have settings to manage open and closed departments or direct chats to certain departments.
0
Chris Smith
Luca,
Thanks Luca! With Zendesk being less than helpful, any way you can share with me the custom code structure your technicians developed?
0
Jacob the Moderator
Eric Ypsilantis
This is awesome! It was the missing step for me
0
Leo Medalla
Is it possible to also modify this script to auto-respond when a department is offline? We don't have the pre-chat form enabled since we don't want our customers to select it for themselves but instead, be directed to the department assigned to a specific webpage.
0
Julio H
I am not sure if this is possible via Script. You might need to post this query as feedback here: Feedback - Chat and Messaging (Chat).
However, you can enable the offline form https://developer.zendesk.com/api-reference/widget/settings/#offlineform:~:text=title-,offlineForm,-Set%20the%20offline for offline messages.
I hope it helps!
0
Testing
Hi, there is a way to do the same ussing messaging ?
0
Ivan Miquiabas
Thanks for reaching out!
This workflow only works when you are using the web widget classic unfortunately. I would suggest to write a Product feedback about this, so that our Messaging team can take a closer look and possible be added as a feature on the next udpdate.
Cheers!
0
Alexey Krasnichenko
Why your API reference does not contain updateSettings option?
0
Tony
Maybe this is the page you were looking for!
Best,
0
Alexey Krasnichenko
Well, this is totally different, window.zESettings and
0