Insightly CRM

  • 16 October 2014
  • 42 replies
  • 207 views

Pull up contact information (name, mail id, organization) of your leads right inside the ticket view from Insightly CRM. Agents can not only see the contact details but track tasks associated with each leads and its status and priority.


Installation procedure:

Create an account at https://www.insightly.com

Get the API token from your insightly account

Replace the username field with the api token of your insightly account

Leave the password field as it is (blank)

Save the changes and enable the FreshPlug.



This topic has been closed for comments

42 replies


Not working. Spinning wheel. :(



Ditto with the spinnin wheel when I try to set this up. 


i would have to say they seem to have put a lot of "sales hype" changing integrations to apps but in reality little has changed
Insightly app doesnt exist its still a plug,  which is seriously hopeless
it works sort of
maybe less hype and more substance?
i will add my voice to the insightly forum,  but it shouldnt be driven by users IMHO

 


Hi all


There's a forum post at Insightly about trying to get them to build Freshdesk integration in to Insightly. Perhaps you can add your voices? :)

https://support.insight.ly/hc/en-us/community/posts/210477327-Support-for-Freshdesk?page=1#community_comment_214030297


Hi Guys,


I'm attaching a new version of the Insightly CRM plug. One would have to update the below details in the freshplug.


baseInsightly - inslightly crm url

apikey - he has to provide the api key


If you happen to face any difficulties in getting it to work, Please send us an email to support@freshdesk.com mentioning about this version of the plug, We will help you sort out the issue.


Code Below,


<div id="insightly" class="insightly">
<div class="content" id="insightly_data">
<ul class="tabs nav-tabs sleek-tab hide" id="myInsightlyTab">
<li class="active first">
<span class="ficon-arrow-left back_button hide"></span>
<a href="#insightly-contact">Contact</a>
</li>
<li>
<a href="#insightly-tasks">Tasks</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="insightly-contact">
</div>
<div class="tab-pane fade in" id="insightly-tasks">
</div>
</div>
<div id="insightly_error" class="sloading">
<p class="message"></p>
<a href="#Contact_insightly" title="Add contact to Insightly" data-template-footer="false" rel="freshdialog" data-width="600" class="btn btn-primary hide center">Create Contact</a>
</div>
</div>
<div id="Contact_insightly" class="hide row-fluid">
<hr />
<ul >
<li class="row-fluid text field">
<label class="span5" for="insightly_add_name_first">First Name</label>
<input class="span7 text" id="insightly_add_name_first" size="30" type="text" value="{{requester.first_name}}">
</li>
<li class="row-fluid text field">
<label class="span5" for="insightly_add_name_last">Last Name</label>
<input class=" span7 text" id="insightly_add_name_last" size="30" type="text" value="{{requester.last_name}}">
</li>

<li class="row-fluid text field">
<label class="span5" for="insightly_add_title">Background</label>
<input class=" span7 text" id="insightly_add_title" size="30" type="text" value="{{requester.job_title}}">
</li>

<hr />
<li class="row-fluid text field">
<label class="span5" for="insightly_add_email">Email</label>
<input class=" span7 text disabled" id="insightly_add_email" size="30" type="text" value="{{requester.email}}" disabled>
</li>
<li class="row-fluid text field">
<label class="span5" for="insightly_add_phone">Phone</label>
<input class=" span7 text" id="insightly_add_phone" size="30" type="text" value="{{requester.phone}}">
</li>

<hr />

</ul>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary insightly_new_submit" data-dismiss="modal">Create</button>
</div>
</div>

</div>
<script type="text/javascript">

if(!jQuery('body').hasClass('ticket_details')){
var InsightlyWidget = {};
jQuery('#insightly').closest('.sidepanel').addClass('widget');
}
jQuery('#insightly').parents('.widget').addClass('inactive').prepend('<h3>Insightly</h3>');

InsightlyWidget = {
TaskView: new Template(
'<div class="each_task">' +
'<div class="task_header clearfix">' +
'<span class="label label-light pull-left">#{status}</span>' +
'<div class="pull-right task_due_date">Due On : #{due_date}</div>' +
'</div>' +
'<p class="task_title clear"><span class="priority-#{priority} p-icons"></span>#{title}</p>' +
'<div class="task_content">#{content}</div>' +
'</div>'
),
ContactData: new Template(
'<ul>' +
'<li class="username"><a target="_blank" href="#{profile}">#{name}</a></li>' +
'<li><span class="head_bold">Phone:</span><span>#{phone}</span></li>' +
'<li class="ins_company"><span class="head_bold">Company:</span><span><a target="_blank" href="#{company_url}">#{company_name}</a></span></li>' +
'<li><span class="head_bold">Background:</span><span class="i_bg_info">#{background}</span></li>' +
'<li><span class="head_bold">Address:</span><span class="i_bg_info">#{address}</span></li>'
),

eachContactName: new Template('<a class="select_user_name" href="#" data-userid="#{id}" >#{name}</a>' ),


multileContactMessage: '<span class="multiCmessage">We have found multiple conatcts.</span>',


email: '{{ticket.from_email}}'.length ? '{{ticket.from_email}}' : '{{requester.email}}'.length ? '{{requester.email}}' : '',

firstname: '{{ticket.requester.firstname}}'.length ? '{{ticket.requester.firstname}}' : '{{requester.name}}'.length ? '{{requester.name}}' : '',

userHash: {},

userIdArray: [],

showTabs: function(){
jQuery('#myInsightlyTab').show();
},

hideLoading:function(show){
if (show) {
jQuery('#insightly_error').removeClass('sloading');
} else{
jQuery('#insightly_error').addClass('sloading');
};
},

initialize: function(insightlyBundle) {
InsightlyWidget = this;
InsightlyWidget.insightlyBundle = insightlyBundle;
InsightlyWidget.freshdeskWidget = new Freshdesk.Widget({
app_name: "Insightly",
domain: insightlyBundle.baseInsightly,
ssl_enabled: true,
auth_type: "Basic",
username: insightlyBundle.ApiKey,
password: ''
});
InsightlyWidget.getConatct();
},

getConatct: function(){
contactEndpoint = "contacts?email=" + InsightlyWidget.email;
this.freshdeskWidget.request({
rest_url: contactEndpoint,
on_success: function(data) {
if (data.responseJSON.length > 0) {
InsightlyWidget.parseContacts(data.responseJSON);
jQuery('#insightly_error').hide();
} else {
InsightlyWidget.hideLoading(true);
InsightlyWidget.errorMessage("Contact not found ",true);
}
},
on_failure:function(data) {
InsightlyWidget.hideLoading(true);
if (data.status === 401) {
InsightlyWidget.errorMessage("Invalid API key",false);
}else if (data.status === 500) {
InsightlyWidget.errorMessage("Some error has occured. Please refresh",false);
};
}
});
},

createContact: function(){
InsightlyWidget.hideLoading(false);
InsightlyWidget.errorMessage(' ',false);
var i_phone = jQuery('#insightly_add_phone').val(),
i_email = jQuery('#insightly_add_email').val(),
i_bg = jQuery('#insightly_add_title').val(),
i_lname = jQuery('#insightly_add_name_last').val(),
i_fname = jQuery('#insightly_add_name_first').val();

if (i_email === '' || i_fname + i_lname === '') {
InsightlyWidget.errorMessage("Email and Name cannot be empty",false);
InsightlyWidget.hideLoading(false);
InsightlyWidget.errorMessage('',true);
return false;
};

function naIfnull(val){
return val? val : 'N/A';
}
var contact_data = '{"FIRST_NAME":"'+ naIfnull(i_fname) +'","LAST_NAME":"' + naIfnull(i_lname) + '","BACKGROUND": "'+ naIfnull(i_bg) +'", "ADDRESSES": [{"ADDRESS_ID": 1, "ADDRESS_TYPE": "Work"} ], "CONTACTINFOS": [{"TYPE": "Email", "DETAIL": "' + naIfnull(i_email) + '"} ],"CONTACTINFOS": [{"TYPE": "Phone", "DETAIL": "' + naIfnull(i_phone) + '"} ] }';
contactEndpoint = "Contacts?apiContact=?";
this.freshdeskWidget.request({
rest_url: contactEndpoint,
method:"post",
body:contact_data,
on_success: function(data) {
InsightlyWidget.getConatct();
},
on_failure:function(data) {
InsightlyWidget.hideLoading(true);
if (data.status === 401) {
InsightlyWidget.errorMessage("Invalid API Key !!",false);
}else{
InsightlyWidget.errorMessage('Some error has occured. Please refresh the page',false);
}
}
});
},
parseContacts: function(contacts){
var contacts_length = contacts.length;
if(contacts_length > 1){
contacts.each(function(contact,i){
InsightlyWidget.userIdArray.push(contact.CONTACT_ID);
contact['name'] = InsightlyWidget.getContactName(contact);
contact['id'] = contact.CONTACT_ID;
InsightlyWidget.userHash[contact.CONTACT_ID] = contact;
});
jQuery('#insightly .back_button').show()
InsightlyWidget.multiContact();
}else{
InsightlyWidget.userIdArray.push(contacts[0].CONTACT_ID);
InsightlyWidget.userHash[contacts[0].CONTACT_ID] = contacts[0];
InsightlyWidget.displayData(contacts[0]);
}

},
getCompany: function(reqId,company){
companyEndpoint = "Organisations/" + company;
this.freshdeskWidget.request({
rest_url: companyEndpoint,
on_success: function(data) {
InsightlyWidget.userHash[reqId]['company_name'] = data.responseJSON.ORGANISATION_NAME ? data.responseJSON.ORGANISATION_NAME : 'N/A';
InsightlyWidget.userHash[reqId]['company_url'] = InsightlyWidget.insightlyBundle.baseInsightly + 'Organisations/Details/' + company;
InsightlyWidget.showContactData(reqId);
},
on_failure:function(data) {
this.freshdeskWidget.alert_failure("Invalid Api key");
}
});
},

addZ: function(n) {
return n < 10 ? '0' + n : n;
},

getTasks: function(req_id) {

var currentdate = new Date();
var nowDateTime = currentdate.getFullYear() + '-' + InsightlyWidget.addZ(currentdate.getMonth() + 1) + '-' + InsightlyWidget.addZ(currentdate.getDate()) + 'T' + InsightlyWidget.addZ(currentdate.getHours()) + ":"
+ InsightlyWidget.addZ(currentdate.getMinutes()) + ":" + InsightlyWidget.addZ(currentdate.getSeconds());
contactEndpoint = "Contacts/" + req_id + "/Tasks?$filter=COMPLETED ne true";
this.freshdeskWidget.request({
rest_url: contactEndpoint,
on_success: function(data) {
if (data.responseJSON.length > 0) {
InsightlyWidget.parseTasks(req_id,data.responseJSON);
} else {
var tasksDom = jQuery('#insightly-tasks');
tasksDom.html('<p class="tasks_message center" >No tasks found</p>');
}
},
on_failure:function(data) {
}
});
},
getDateOnly: function(date){
return date.split(' ')[0];
},
parseTasks: function(reqId,tasks){
var userTask = {};
if (tasks.length) {
tasks.each(function(task, i) {
userTask = {};
userTask['due_date'] = task.DUE_DATE ? InsightlyWidget.getDateOnly(task.DUE_DATE) : 'No Due Date';
userTask['content'] = task.DETAILS ? task.DETAILS : 'No data available ';
userTask['title'] = task.Title ? task.Title : 'N/A';
userTask['status'] = task.STATUS ? task.STATUS : '';
userTask['priority'] = task.PRIORITY ? task.PRIORITY : '';
InsightlyWidget.userHash[reqId]['tasks'].push(userTask);
});
InsightlyWidget.displayTasks(reqId);
}
},
displayTasks: function(reqId){
var tasksDom = jQuery('#insightly-tasks');
tasksDom.html('');
if (InsightlyWidget.userHash[reqId]['tasks'].length) {
InsightlyWidget.userHash[reqId]['tasks'].each(function(task,i){
tasksDom.append(InsightlyWidget.TaskView.evaluate(task));
});
}else{
tasksDom.html('<p class="tasks_message center" >No Tasks found</p>');
}
},
multiContact: function(){
var contactDom = jQuery('#insightly-contact');
var multi_contact_html = InsightlyWidget.multileContactMessage;
jQuery('#myInsightlyTab a:first').tab('show');
jQuery('#myInsightlyTab').hide();
InsightlyWidget.userIdArray.each(function(userId,i){
multi_contact_html += InsightlyWidget.eachContactName.evaluate(InsightlyWidget.userHash[userId]);
});
contactDom.html(multi_contact_html);
},
getContactName: function(contact_data){
if (contact_data.FIRST_NAME || contact_data.LAST_NAME ) {
if(contact_data.LAST_NAME){
return contact_data.FIRST_NAME + contact_data.LAST_NAME
}else{
return contact_data.FIRST_NAME;
}
}else{
return "Not Available";
}
},
displayData:function(contact_data){
if(contact_data['data_updated']){
insightlyUser = contact_data;
InsightlyWidget.showContactData(contact_data['id']);
InsightlyWidget.displayTasks(contact_data['id']);
}else{
var insightlyUser = {};
insightlyUser['id'] = contact_data.id ? contact_data.id : contact_data.CONTACT_ID;
insightlyUser['name'] = contact_data['name'] ? contact_data['name'] : InsightlyWidget.getContactName(contact_data);
insightlyUser['phone'] = "N/A"
contact_data.CONTACTINFOS.each(function(info,i){
if (info['TYPE'] == "PHONE") {
insightlyUser['phone'] = info['DETAIL'];
};
});
insightlyUser['profile'] = InsightlyWidget.insightlyBundle.baseInsightly + 'Contacts/Details/' + insightlyUser['id'];
insightlyUser['background'] = contact_data.BACKGROUND ? contact_data.BACKGROUND : "N/A";
insightlyUser['tasks'] = [];
insightlyUser['data_updated'] = true;
/* Code for address of user */
insightlyUser['address'] = 'N/A';
if(contact_data.ADDRESSES.length){
insightlyUser['address'] = contact_data.ADDRESSES[0].STREET ? contact_data.ADDRESSES[0].STREET : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].CITY ? ' ' + contact_data.ADDRESSES[0].CITY : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].STATE ? ' ' + contact_data.ADDRESSES[0].STATE : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].POSTCODE ? ' ' + contact_data.ADDRESSES[0].POSTCODE : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].COUNTRY ? ' ' + contact_data.ADDRESSES[0].COUNTRY : '';
insightlyUser['address'] = insightlyUser['address'].length ? insightlyUser['address'] : 'N/A';
}
/* Code for address of user */
InsightlyWidget.userHash[insightlyUser['id']] = insightlyUser;
InsightlyWidget.getTasks(insightlyUser['id']);
if (contact_data.DEFAULT_LINKED_ORGANISATION) {
InsightlyWidget.userHash[insightlyUser['id']]['company'] = contact_data.DEFAULT_LINKED_ORGANISATION;
InsightlyWidget.getCompany(insightlyUser['id'],insightlyUser['company']);
}else{
InsightlyWidget.userHash[insightlyUser['id']]['company_name'] = "N/A";
InsightlyWidget.userHash[insightlyUser['id']]['company_url'] = "#";
InsightlyWidget.showContactData(insightlyUser['id']);
}
}
},
showContactData: function(contact_id){
var contactDom = jQuery('#insightly-contact');
InsightlyWidget.hideLoading(true);
InsightlyWidget.showTabs();
contactDom.html(InsightlyWidget.ContactData.evaluate(InsightlyWidget.userHash[contact_id]));
if(InsightlyWidget.userHash[contact_id]['company_url'] == "#"){
jQuery('.ins_company span:last').html('N/A');
}
},
errorMessage:function(message,show_button){
var message_dom = jQuery('#insightly_error .message');
if (message) {
message_dom.html(message);
};
if (show_button) {
jQuery('#insightly_error .btn').show();
}else{
jQuery('#insightly_error .btn').hide();
};
},
};

var insightlydata = {
baseInsightly: 'INSIGHTLY DOMAIN', /* Example: https://test123.insight.ly/ */
ApiKey: 'API KEY',
}

jQuery('#insightly').closest('.widget').find('h3').on('click',function(){
if(!jQuery(this).hasClass('.inactive') && InsightlyWidget.userIdArray.length == 0){
InsightlyWidget.initialize(insightlydata);
}
});
jQuery('#insightly .tabs a').click(function(ev) {
ev.preventDefault();
jQuery(this).tab('show');
});
jQuery(document).on('click','#insightly .select_user_name',function(ev){
ev.preventDefault();
var _this = jQuery(this);
InsightlyWidget.displayData(InsightlyWidget.userHash[_this.data('userid')]);
})
jQuery(document).on('click','#insightly .back_button',function(ev){
ev.preventDefault();
InsightlyWidget.multiContact();
})
jQuery('.insightly_new_submit').on('click','',function(e){
jQuery('.insightly_new_submit').addClass('disabled');
InsightlyWidget.createContact();
});

</script>

<style type="text/css">
#insightly .tasks_message{
padding-top: 15px;
}
#myInsightlyTab li a{
font-size: 13px;
padding: 0 10px 10px;
}
#insightly .tabs{
margin: 0;
padding: 0;
}
#insightly .tabs a{
display: inline-block;
}
#insightly .tab-pane li{
padding: 0 0 5px 0;
}
#insightly .tab-pane li.username{
font-size: 14px;
font-weight: 300;
padding: 15px 0 8px 0;
}
#insightly .tab-pane .head_bold{
font-weight: 500;
width: 45%;
display: inline-block;
vertical-align: top;
}
#insightly .tab-pane span{
font-size: 12px;
}
#insightly .tab-pane .i_bg_info{
width: 55%;
display: inline-block;
}
#insightly #insightly-tasks .each_task{
padding: 15px 0 5px 0;
border-bottom: 1px solid #e8e8e8;
font-size: 12px;
}
#insightly #insightly-tasks .task_title{
font-size: 12px;
font-weight: 500;
padding: 5px 0;
margin-bottom: 2px;
}
#insightly #insightly-tasks .task_due_date{
color: #777;
padding-top: 2px;
}
#insightly #insightly-tasks .task_content{
color: #555;
line-height: 17px;
font-size: 12px;
}
#insightly #insightly-tasks .task_content p{
margin-bottom: 2px;
color: #555;
line-height: 17px;
font-size: 12px;
}
#insightly #insightly-tasks .p-icons{
padding-right: 7px;
letter-spacing: 1.5px;
width: 10px;
height: 16px;
}
#insightly #insightly-tasks .priority-1::before{
color: #3479E3;
content: '!';
}
#insightly #insightly-tasks .priority-2::before{
color: #D79C03;
content: '!!';
}
#insightly #insightly-tasks .priority-3::before{
color: #DB1836;
content: '!!!';
}
#insightly .select_user_name{
display: block;
font-size: 14px;
font-weight: 300;
padding: 10px 0 0;
}
#insightly .multiCmessage{
display: block;
}
#insightly .message {
color: #555;
padding-bottom: 4px;
}
#insightly .back_button{
display: inline-block;
color: rgb(71, 135, 232);
cursor: pointer;
font-size: 15px;
vertical-align: middle;
padding-right: 4px;
padding-bottom: 3px;
}
#insightly .back_button:before{
padding-right: 8px;
font-size: 20px;
vertical-align: middle;
}
#insightly .hide{
display: none;
}
#insightly #insightly_error{
text-align: center;
color: #555;
padding-bottom: 10px;
}
#insightly #insightly_error .btn{
background: #fff;
color: #3983E5;
border: 1px solid #ccc;
text-shadow: none;
font-weight: 400;
}
</style>


We use Insightly as well, can you tell me which version of the FreshPlug to use please?



I also get the same error as Jack using the latest version of the FreshPlug

can we get some clarification of which one actually works and where to actually setup the information in the freshplug as it seems different in this version to the original (which did at least do something)

I find the lack of response on this a little disappointing

To me it should have been made a proper integration and not just a FreshPlug


I have used the most up to date version of this freshplug, however it stays as a loading icon in the right sidebar. How can I fix this issue?


This is a great help to our Support Agents.  They like being able to click the link to the Customer or Company in the ticket and open Insightly right to them.  Before we implemented this FreshPlug our agents would go to Insightly and search for the Organization or Contact to see additional information.  Now they click the link and they are there, a huge tie saver for us.

I have one request.  Is there a way to list the Tasks that are associated with the Company as well as the Contact when you select tasks?  Most, if not all, of our tasks in Insightly are linked to the Company rather that the Contact.

 


Hi but does it import the organisation?

Works great, even shows the address. Great work, thank you.


I did however change:

return contact_data.FIRST_NAME + contact_data.LAST_NAME

 to

return contact_data.FIRST_NAME + ' ' + contact_data.LAST_NAME

on line #289 because the first and last name were combined on the right hand side widget. 


Hi All,


We have updated the code. Please check and see if it helps.


 

<div id="insightly" class="insightly">
<div class="content" id="insightly_data">
<ul class="tabs nav-tabs sleek-tab hide" id="myInsightlyTab">
<li class="active first">
<span class="ficon-arrow-left back_button hide"></span>
<a href="#insightly-contact">Contact</a>
</li>
<li>
<a href="#insightly-tasks">Tasks</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade in active" id="insightly-contact">
</div>
<div class="tab-pane fade in" id="insightly-tasks">
</div>
</div>
<div id="insightly_error" class="sloading">
<p class="message"></p>
<a href="#Contact_insightly" title="Add contact to Insightly" data-template-footer="false" rel="freshdialog" data-width="600" class="btn btn-primary hide center">Create Contact</a>
</div>
</div>
<div id="Contact_insightly" class="hide row-fluid">
<hr />
<ul >
<li class="row-fluid text field">
<label class="span5" for="insightly_add_name_first">First Name</label>
<input class="span7 text" id="insightly_add_name_first" size="30" type="text" value="{{requester.first_name}}">
</li>
<li class="row-fluid text field">
<label class="span5" for="insightly_add_name_last">Last Name</label>
<input class=" span7 text" id="insightly_add_name_last" size="30" type="text" value="{{requester.last_name}}">
</li>

<li class="row-fluid text field">
<label class="span5" for="insightly_add_title">Background</label>
<input class=" span7 text" id="insightly_add_title" size="30" type="text" value="{{requester.job_title}}">
</li>

<hr />
<li class="row-fluid text field">
<label class="span5" for="insightly_add_email">Email</label>
<input class=" span7 text disabled" id="insightly_add_email" size="30" type="text" value="{{requester.email}}" disabled>
</li>
<li class="row-fluid text field">
<label class="span5" for="insightly_add_phone">Phone</label>
<input class=" span7 text" id="insightly_add_phone" size="30" type="text" value="{{requester.phone}}">
</li>

<hr />

</ul>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary insightly_new_submit" data-dismiss="modal">Create</button>
</div>
</div>

</div>
<script type="text/javascript">

if(!jQuery('body').hasClass('ticket_details')){
var InsightlyWidget = {};
jQuery('#insightly').closest('.sidepanel').addClass('widget');
}
jQuery('#insightly').parents('.widget').addClass('inactive').prepend('<h3>Insightly</h3>');

InsightlyWidget = {
TaskView: new Template(
'<div class="each_task">' +
'<div class="task_header clearfix">' +
'<span class="label label-light pull-left">#{status}</span>' +
'<div class="pull-right task_due_date">Due On : #{due_date}</div>' +
'</div>' +
'<p class="task_title clear"><span class="priority-#{priority} p-icons"></span>#{title}</p>' +
'<div class="task_content">#{content}</div>' +
'</div>'
),
ContactData: new Template(
'<ul>' +
'<li class="username"><a target="_blank" href="#{profile}">#{name}</a></li>' +
'<li><span class="head_bold">Phone:</span><span>#{phone}</span></li>' +
'<li class="ins_company"><span class="head_bold">Company:</span><span><a target="_blank" href="#{company_url}">#{company_name}</a></span></li>' +
'<li><span class="head_bold">Background:</span><span class="i_bg_info">#{background}</span></li>' +
'<li><span class="head_bold">Address:</span><span class="i_bg_info">#{address}</span></li>'
),

eachContactName: new Template('<a class="select_user_name" href="#" data-userid="#{id}" >#{name}</a>' ),


multileContactMessage: '<span class="multiCmessage">We have found multiple conatcts.</span>',


email: '{{ticket.from_email}}'.length ? '{{ticket.from_email}}' : '{{requester.email}}'.length ? '{{requester.email}}' : '',

firstname: '{{ticket.requester.firstname}}'.length ? '{{ticket.requester.firstname}}' : '{{requester.name}}'.length ? '{{requester.name}}' : '',

userHash: {},

userIdArray: [],

showTabs: function(){
jQuery('#myInsightlyTab').show();
},

hideLoading:function(show){
if (show) {
jQuery('#insightly_error').removeClass('sloading');
} else{
jQuery('#insightly_error').addClass('sloading');
};
},

initialize: function(insightlyBundle) {
InsightlyWidget = this;
InsightlyWidget.insightlyBundle = insightlyBundle;
InsightlyWidget.freshdeskWidget = new Freshdesk.Widget({
app_name: "Insightly",
domain: 'https://api.insight.ly/v2.1',
ssl_enabled: true,
auth_type: "Basic",
username: insightlyBundle.ApiKey,
password: ''
});
InsightlyWidget.getConatct();
},

getConatct: function(){
contactEndpoint = "contacts?email=" + InsightlyWidget.email;
this.freshdeskWidget.request({
rest_url: contactEndpoint,
on_success: function(data) {
if (data.responseJSON.length > 0) {
InsightlyWidget.parseContacts(data.responseJSON);
jQuery('#insightly_error').hide();
} else {
InsightlyWidget.hideLoading(true);
InsightlyWidget.errorMessage("Contact not found ",true);
}
},
on_failure:function(data) {
InsightlyWidget.hideLoading(true);
if (data.status === 401) {
InsightlyWidget.errorMessage("Invalid API key",false);
}else if (data.status === 500) {
InsightlyWidget.errorMessage("Some error has occured. Please refresh",false);
};
}
});
},

createContact: function(){
InsightlyWidget.hideLoading(false);
InsightlyWidget.errorMessage(' ',false);
var i_phone = jQuery('#insightly_add_phone').val(),
i_email = jQuery('#insightly_add_email').val(),
i_bg = jQuery('#insightly_add_title').val(),
i_lname = jQuery('#insightly_add_name_last').val(),
i_fname = jQuery('#insightly_add_name_first').val();

if (i_email === '' || i_fname + i_lname === '') {
InsightlyWidget.errorMessage("Email and Name cannot be empty",false);
InsightlyWidget.hideLoading(false);
InsightlyWidget.errorMessage('',true);
return false;
};

function naIfnull(val){
return val? val : 'N/A';
}
var contact_data = '{"FIRST_NAME":"'+ naIfnull(i_fname) +'","LAST_NAME":"' + naIfnull(i_lname) + '","BACKGROUND": "'+ naIfnull(i_bg) +'", "ADDRESSES": [{"ADDRESS_ID": 1, "ADDRESS_TYPE": "Work"} ], "CONTACTINFOS": [{"TYPE": "Email", "DETAIL": "' + naIfnull(i_email) + '"} ],"CONTACTINFOS": [{"TYPE": "Phone", "DETAIL": "' + naIfnull(i_phone) + '"} ] }';
contactEndpoint = "Contacts?apiContact=?";
this.freshdeskWidget.request({
rest_url: contactEndpoint,
method:"post",
body:contact_data,
on_success: function(data) {
InsightlyWidget.getConatct();
},
on_failure:function(data) {
InsightlyWidget.hideLoading(true);
if (data.status === 401) {
InsightlyWidget.errorMessage("Invalid API Key !!",false);
}else{
InsightlyWidget.errorMessage('Some error has occured. Please refresh the page',false);
}
}
});
},
parseContacts: function(contacts){
var contacts_length = contacts.length;
if(contacts_length > 1){
contacts.each(function(contact,i){
InsightlyWidget.userIdArray.push(contact.CONTACT_ID);
contact['name'] = InsightlyWidget.getContactName(contact);
contact['id'] = contact.CONTACT_ID;
InsightlyWidget.userHash[contact.CONTACT_ID] = contact;
});
jQuery('#insightly .back_button').show()
InsightlyWidget.multiContact();
}else{
InsightlyWidget.userIdArray.push(contacts[0].CONTACT_ID);
InsightlyWidget.userHash[contacts[0].CONTACT_ID] = contacts[0];
InsightlyWidget.displayData(contacts[0]);
}

},
getCompany: function(reqId,company){
companyEndpoint = "Organisations/" + company;
this.freshdeskWidget.request({
rest_url: companyEndpoint,
on_success: function(data) {
InsightlyWidget.userHash[reqId]['company_name'] = data.responseJSON.ORGANISATION_NAME ? data.responseJSON.ORGANISATION_NAME : 'N/A';
InsightlyWidget.userHash[reqId]['company_url'] = InsightlyWidget.insightlyBundle.baseInsightly + 'Organisations/Details/' + company;
InsightlyWidget.showContactData(reqId);
},
on_failure:function(data) {
this.freshdeskWidget.alert_failure("Invalid Api key");
}
});
},

addZ: function(n) {
return n < 10 ? '0' + n : n;
},

getTasks: function(req_id) {

var currentdate = new Date();
var nowDateTime = currentdate.getFullYear() + '-' + InsightlyWidget.addZ(currentdate.getMonth() + 1) + '-' + InsightlyWidget.addZ(currentdate.getDate()) + 'T' + InsightlyWidget.addZ(currentdate.getHours()) + ":"
+ InsightlyWidget.addZ(currentdate.getMinutes()) + ":" + InsightlyWidget.addZ(currentdate.getSeconds());
contactEndpoint = "Contacts/" + req_id + "/Tasks?$filter=COMPLETED ne true";
this.freshdeskWidget.request({
rest_url: contactEndpoint,
on_success: function(data) {
if (data.responseJSON.length > 0) {
InsightlyWidget.parseTasks(req_id,data.responseJSON);
} else {
var tasksDom = jQuery('#insightly-tasks');
tasksDom.html('<p class="tasks_message center" >No tasks found</p>');
}
},
on_failure:function(data) {
}
});
},
getDateOnly: function(date){
return date.split(' ')[0];
},
parseTasks: function(reqId,tasks){
var userTask = {};
if (tasks.length) {
tasks.each(function(task, i) {
userTask = {};
userTask['due_date'] = task.DUE_DATE ? InsightlyWidget.getDateOnly(task.DUE_DATE) : 'No Due Date';
userTask['content'] = task.DETAILS ? task.DETAILS : 'No data available ';
userTask['title'] = task.Title ? task.Title : 'N/A';
userTask['status'] = task.STATUS ? task.STATUS : '';
userTask['priority'] = task.PRIORITY ? task.PRIORITY : '';
InsightlyWidget.userHash[reqId]['tasks'].push(userTask);
});
InsightlyWidget.displayTasks(reqId);
}
},
displayTasks: function(reqId){
var tasksDom = jQuery('#insightly-tasks');
tasksDom.html('');
if (InsightlyWidget.userHash[reqId]['tasks'].length) {
InsightlyWidget.userHash[reqId]['tasks'].each(function(task,i){
tasksDom.append(InsightlyWidget.TaskView.evaluate(task));
});
}else{
tasksDom.html('<p class="tasks_message center" >No Tasks found</p>');
}
},
multiContact: function(){
var contactDom = jQuery('#insightly-contact');
var multi_contact_html = InsightlyWidget.multileContactMessage;
jQuery('#myInsightlyTab a:first').tab('show');
jQuery('#myInsightlyTab').hide();
InsightlyWidget.userIdArray.each(function(userId,i){
multi_contact_html += InsightlyWidget.eachContactName.evaluate(InsightlyWidget.userHash[userId]);
});
contactDom.html(multi_contact_html);
},
getContactName: function(contact_data){
if (contact_data.FIRST_NAME || contact_data.LAST_NAME ) {
if(contact_data.LAST_NAME){
return contact_data.FIRST_NAME + contact_data.LAST_NAME
}else{
return contact_data.FIRST_NAME;
}
}else{
return "Not Available";
}
},
displayData:function(contact_data){
if(contact_data['data_updated']){
insightlyUser = contact_data;
InsightlyWidget.showContactData(contact_data['id']);
InsightlyWidget.displayTasks(contact_data['id']);
}else{
var insightlyUser = {};
insightlyUser['id'] = contact_data.id ? contact_data.id : contact_data.CONTACT_ID;
insightlyUser['name'] = contact_data['name'] ? contact_data['name'] : InsightlyWidget.getContactName(contact_data);
insightlyUser['phone'] = "N/A"
contact_data.CONTACTINFOS.each(function(info,i){
if (info['TYPE'] == "PHONE") {
insightlyUser['phone'] = info['DETAIL'];
};
});
insightlyUser['profile'] = InsightlyWidget.insightlyBundle.baseInsightly + 'Contacts/Details/' + insightlyUser['id'];
insightlyUser['background'] = contact_data.BACKGROUND ? contact_data.BACKGROUND : "N/A";
insightlyUser['tasks'] = [];
insightlyUser['data_updated'] = true;
/* Code for address of user */
insightlyUser['address'] = 'N/A';
if(contact_data.ADDRESSES.length){
insightlyUser['address'] = contact_data.ADDRESSES[0].STREET ? contact_data.ADDRESSES[0].STREET : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].CITY ? ' ' + contact_data.ADDRESSES[0].CITY : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].STATE ? ' ' + contact_data.ADDRESSES[0].STATE : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].POSTCODE ? ' ' + contact_data.ADDRESSES[0].POSTCODE : '';
insightlyUser['address'] += contact_data.ADDRESSES[0].COUNTRY ? ' ' + contact_data.ADDRESSES[0].COUNTRY : '';
insightlyUser['address'] = insightlyUser['address'].length ? insightlyUser['address'] : 'N/A';
}
/* Code for address of user */
InsightlyWidget.userHash[insightlyUser['id']] = insightlyUser;
InsightlyWidget.getTasks(insightlyUser['id']);
if (contact_data.DEFAULT_LINKED_ORGANISATION) {
InsightlyWidget.userHash[insightlyUser['id']]['company'] = contact_data.DEFAULT_LINKED_ORGANISATION;
InsightlyWidget.getCompany(insightlyUser['id'],insightlyUser['company']);
}else{
InsightlyWidget.userHash[insightlyUser['id']]['company_name'] = "N/A";
InsightlyWidget.userHash[insightlyUser['id']]['company_url'] = "#";
InsightlyWidget.showContactData(insightlyUser['id']);
}
}
},
showContactData: function(contact_id){
var contactDom = jQuery('#insightly-contact');
InsightlyWidget.hideLoading(true);
InsightlyWidget.showTabs();
contactDom.html(InsightlyWidget.ContactData.evaluate(InsightlyWidget.userHash[contact_id]));
if(InsightlyWidget.userHash[contact_id]['company_url'] == "#"){
jQuery('.ins_company span:last').html('N/A');
}
},
errorMessage:function(message,show_button){
var message_dom = jQuery('#insightly_error .message');
if (message) {
message_dom.html(message);
};
if (show_button) {
jQuery('#insightly_error .btn').show();
}else{
jQuery('#insightly_error .btn').hide();
};
},
};

var insightlydata = {
baseInsightly: 'INSIGHTLY DOMAIN', /* Example: https://test123.insight.ly/ */
ApiKey: 'API KEY',
}

jQuery('#insightly').closest('.widget').find('h3').on('click',function(){
if(!jQuery(this).hasClass('.inactive') && InsightlyWidget.userIdArray.length == 0){
InsightlyWidget.initialize(insightlydata);
}
});
jQuery('#insightly .tabs a').click(function(ev) {
ev.preventDefault();
jQuery(this).tab('show');
});
jQuery(document).on('click','#insightly .select_user_name',function(ev){
ev.preventDefault();
var _this = jQuery(this);
InsightlyWidget.displayData(InsightlyWidget.userHash[_this.data('userid')]);
})
jQuery(document).on('click','#insightly .back_button',function(ev){
ev.preventDefault();
InsightlyWidget.multiContact();
})
jQuery('.insightly_new_submit').on('click','',function(e){
jQuery('.insightly_new_submit').addClass('disabled');
InsightlyWidget.createContact();
});

</script>

<style type="text/css">
#insightly .tasks_message{
padding-top: 15px;
}
#myInsightlyTab li a{
font-size: 13px;
padding: 0 10px 10px;
}
#insightly .tabs{
margin: 0;
padding: 0;
}
#insightly .tabs a{
display: inline-block;
}
#insightly .tab-pane li{
padding: 0 0 5px 0;
}
#insightly .tab-pane li.username{
font-size: 14px;
font-weight: 300;
padding: 15px 0 8px 0;
}
#insightly .tab-pane .head_bold{
font-weight: 500;
width: 45%;
display: inline-block;
vertical-align: top;
}
#insightly .tab-pane span{
font-size: 12px;
}
#insightly .tab-pane .i_bg_info{
width: 55%;
display: inline-block;
}
#insightly #insightly-tasks .each_task{
padding: 15px 0 5px 0;
border-bottom: 1px solid #e8e8e8;
font-size: 12px;
}
#insightly #insightly-tasks .task_title{
font-size: 12px;
font-weight: 500;
padding: 5px 0;
margin-bottom: 2px;
}
#insightly #insightly-tasks .task_due_date{
color: #777;
padding-top: 2px;
}
#insightly #insightly-tasks .task_content{
color: #555;
line-height: 17px;
font-size: 12px;
}
#insightly #insightly-tasks .task_content p{
margin-bottom: 2px;
color: #555;
line-height: 17px;
font-size: 12px;
}
#insightly #insightly-tasks .p-icons{
padding-right: 7px;
letter-spacing: 1.5px;
width: 10px;
height: 16px;
}
#insightly #insightly-tasks .priority-1::before{
color: #3479E3;
content: '!';
}
#insightly #insightly-tasks .priority-2::before{
color: #D79C03;
content: '!!';
}
#insightly #insightly-tasks .priority-3::before{
color: #DB1836;
content: '!!!';
}
#insightly .select_user_name{
display: block;
font-size: 14px;
font-weight: 300;
padding: 10px 0 0;
}
#insightly .multiCmessage{
display: block;
}
#insightly .message {
color: #555;
padding-bottom: 4px;
}
#insightly .back_button{
display: inline-block;
color: rgb(71, 135, 232);
cursor: pointer;
font-size: 15px;
vertical-align: middle;
padding-right: 4px;
padding-bottom: 3px;
}
#insightly .back_button:before{
padding-right: 8px;
font-size: 20px;
vertical-align: middle;
}
#insightly .hide{
display: none;
}
#insightly #insightly_error{
text-align: center;
color: #555;
padding-bottom: 10px;
}
#insightly #insightly_error .btn{
background: #fff;
color: #3983E5;
border: 1px solid #ccc;
text-shadow: none;
font-weight: 400;
}
</style>

 


Hi Manoj

That seems to have broken it alltogether!



Great plugin, one question thought. How can I make it to also pull address etc info from Insightly? As it stands now it is, at least for me, not pulling address etc info from Insightly.


Thank you for the great plugin.


Hi Kevin,


Please find the updated freshplug for Insightly CRM. 


Hope this helps. 


i seem to be able to import contacts ok but there doesnt appear to be import of organisations?



Is there a way to create a link in the freshplug so you can click it and open the contact and/or the organization in insightly in a new window? 


Also, can we make the email link a mailto: so you can click to send them an email?


Thanks!

Shawn


Hi Patrick,

Yes , It is upto date.


Thanks 

Nithin David


HI Just wondering if the download button at the top of this page contains the latest code for the Freshplug for insightly ? I see a number of additions at a later date .. Are these corrections integrated ?
thanks for letting me know
regards
Patrick

 


Hi Colin,

Can you please send a mail to support@freshdesk.com regarding this issue? Our support team will look into it.

Thanks

Nithin David


Thanks for getting back to me.  I hadn't checked that box but I'm not sure it's picking up the info I need.


I have tested it with a client (making sure I have some background and a task loaded in via Insightly) but it isn't picking up this information when I view the ticket in Freshdesk.



Hi Colin,

Did you check "Show the widget in ticket view page." option just below the freshplug code editor? . The freshplug will work in tickets page only if you select that option. Please see the screenshot below. If you have already done this, please get back to us.




Thanks


Nithin David




I am new to Freshdesk and love the fact I can integrate my Insightly contacts into this system.


I've downloaded, installed and added my Insightly API key to the code as per the last comment above.


When I go to add a ticket and search for a user that I know is in Insightly it isn't finding them though.


Am I missing something fundamental?


The example is setup for 2 custom fields. You might need to adjust the number of fields:

 - add some more or delete 1


Or to adjust the names of fields (e.g.):

replace the naming to your liking at  '.organization-status:last' and <span>Org. Status: </span><label class="organization-status"> n/a </label>


Overall there are only two places in code where the adjustments need to be done.


Hi, I am not too sure what is to be "adjusted" in STEP 1? Can you please clarify what needs to be done to aply this update.


Thanks