Example: Link to CRM¶
One of the simplest examples would be to create a widget that displays a link to an external system, such as a CRM.
Most CRMs offer a way to look-up a user based on criteria like an email address. In this example, we use an app that outputs a link with the users email address in it.
Create your widget¶
First, create your app from Admin > Apps > Create Widget like described in the previous section. Select where you want your link to appear. In this example, we’ll create a new section under the properties box:
Widget code¶
Switch to the Tickets
tab to see the two inputs for our Javascript
controller and HTML template. In this example, we’ll be using the users email
address to generate a simple HTML link. So in the first box we need to assign
the email address variable to the $scope
so it becomes available to the
HTML template:
define(function() {
return function($scope, $ticket, $person, $http, $el, $app) {
$scope.user_email = $person.primary_email.email;
};
});
Then we are free to use the new user_email
variable in our HTML template.
Here’s an example template. It has a bit of styling around the outer div to
make it a bit prettier on the view-ticket screen.
<div style="margin-top: 10px; padding: 5px; background: #fff; border: 1px solid #ccc; border-radius: 4px;">
<a href="http://example.com/crm/find-user?email={{user_email}}" target="_blank">Look up {{user_email}} in CRM</a>
</div>
This is what it looks like when we view a ticket in the Agent Interface: