Widgets
Widgets are html fragments that can be embedded directly on selected pages of your help desk. Use widgets to integrate external data in your help desk interface. If the REST API is enabled for your help desk, you can furthermore access all of the data in your help desk via JSON, mash-up with external data and even replace existing elements in the help desk layout.
Presently, you can place widgets on the help desk home page and on the ticket create/update form.
For advanced usage, see the Javascript Resource API
Home widget
For the help desk home widget, you have {{user.name}}, {{user.email}} and {{user.external_id}} available as placeholders. These placeholders refer to attributes for the user currently logged in. If you have pre-populated or updated the user database via REST, you can utilize the attribute {{user.external_id}} for the user internal ID for your enterprise, thus using javascript or iframing in the widget to fetch and present additional data from your repositories - e.g. license or asset data.
The home widget appears in the sidebar on the right hand side of the home page of your zendesk.
Examples
Hello user
hello {{user.name}}
Widget access to all data in your helpdesk via JSON
<script>
new Ajax.Request('/users.js', {
method:'get',
asynchronous: true,
onSuccess: function(transport){
var obj = transport.responseText.evalJSON();
$('active-views').innerHTML = '<p>' + obj.length + ' users in your help desk.'
+ ' First user is '
+ obj[0].name + '</p>'
}
});
</script>
You can access all data in your help desk directly from the widget via JSON. This example lists the number of users in your help desk, and displays the name of the first user. The data is shown on the page in the inner HTML of the div with ID "active-views". You can place the content of your widget in any div with an ID!
Ticket widget
For the ticket widget, you have the following placeholders available: {{requester.name}}, {{requester.email}} and {{requester.external_id}}. These placeholders refer to attributes for the ticket requester. In addition you have access to all of the ticket properties through the following placeholders:
- {{ticket.id}}
- {{ticket.title}}
- {{ticket.description}}
- {{ticket.url}}
- {{ticket.status}}
- {{ticket.priority}}
- {{ticket.ticket_type}}
- {{ticket.index}}
- {{ticket.group}}
- {{ticket.organization}}
- {{ticket.latest_comment}}
- {{ticket.latest_public_comment}}
- {{ticket.all_comments}}
- {{ticket.all_public_comments}}
- {{ticket.account}}
- {{ticket.assignee}}
- {{ticket.requester}}
- {{ticket.current_collaborators}}
- {{ticket.ticket_field_ID}}
- {{updater.name}}
- {{updater.email}}
- {{updater.organization}}
The ticket widget appears in the sidebar to the right of the ticket form. Notice that the widget only gets invoked for existing tickets, as the requester is "unknown" to the system when creating a new ticket.
Integrating data from and to your enterprise
If you have pre-populated or updated the user database via REST, you can utilize the attribute {{user.external_id}} for the internal user ID for your enterprise, thus using javascript calls in the widget to fetch and present additional data from your repositories - e.g. license or asset data for the current user.
Integrating user data from and to your enterprise
<script type="text/javascript"
src="https://database.your_enterprise.com/get_user_assets.php?id={{user.external_id}}">
</script>
This example calls an internal method at your enterprise. The method returns javascript listing users assets. This could also be done with an iframe returning plain HTML from your enterprise.
