Recent searches
No recent searches
Show web widget/answer bot only to signed-in users?
Answered
Posted Feb 23, 2022
What would need to be done to only show the web widget/answer bot to only signed in users on the ZenDesk help center?
I believe the following should work, but it doesn't appear to be:
{{#if signed_in}}
<script type="text/javascript">
zE('webWidget', 'show');
</script>
{{else}}
<script type="text/javascript">
zE('webWidget', 'hide');
</script>
{{/if}}
0
7
7 comments
Christopher Kennedy
That snippet can work to accomplish the goal. Are you seeing an error? Is the widget displaying in cases where you expect it to be hidden? Or vice versa?
Best,
0
David Nguyen
Hi Christopher,
It seems that the widget is not hiding as expected if the user is not logged in.
Looking at the console, I believe that the culprit is that we are now using the Web SDK and not the Web Widget (Classic)
"
Method webWidget.hide does not exist.
A note from Zendesk: API methods associated with the Web Widget (Classic) are still being executed on this page. This website is now using the new Web SDK (messaging experience) which no longer supports these APIs. If you don't intend to use the Web Widget (Classic), we recommend that you remove this code from your website. Whilst not recommended, leaving them won't cause any issues. "
Is it possible to hide the web SDK through similar code on the theme or elsewhere?
0
Christopher Kennedy
That note about the Web SDK for Messaging is correct. There is no Hide API available at this time. However you can work around that fact in your theme using the same
signed_in
helper from your post. Instead of using it to determine when to call a show or hide API method, place the widget launch snippet inside thesigned_in
block:By doing this, the widget will only load on the page at all if the user is signed in.
Best,
0
William Sedgwick
Christopher Kennedy
Where abouts is the signed in block in the themes?
thank you for helping
0
Guido
You can add this piece of code to either the footer or the header of your help centre by going to Guide admin > Themes > Customize > Edit code > Header:
I recommend adding it to the footer or header because they are present in every page of your help centre, allowing the widget code logic that we have added to work in all of it.
Thank you!
0
Stephen Marron
Hi everyone,
I also use the Web Widget (Classic) chat and would like it only to display for logged in Zendesk Help centre users.
In admin > channels > chat settings, the 'Add to Help Centre' option is checked and I am using a customised copy of the 'Copenhagen' theme.
Is there an option in admin to enable chat for logged in users only or do I need to disable the 'Add to Help Centre' option and manually add the chat embed snippet to my custom there footer.hbs using the {{#if signed_in}} tag as outlined above?
What is the best method to achieve the desired outcome?
Thank you,
0
Stephen Marron
UPDATE:
I opted for the below working solution:
0