Insightly CRM

  • 16 October 2014
  • 42 replies
  • 207 views


Show first post
This topic has been closed for comments

42 replies

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?


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


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



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>


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


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

 



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



Not working. Spinning wheel. :(


Thanks for putting this together and it is great to link the two systems. However when I look at a ticket and retrieve a person's record I end up fetching a ton of information very little is about that contact. I am not quite sure what it is pulling. I have written integrations with Insightly before myself so will take a look at it when I have a little more time as I can see some great potential here.


David,

Thanks for the note. Will await your feedback.. Appreciate your time to take a look in to this integration.


Greetings--I'm an Insightly user and am test driving FreshDesk. As David mentioned, I get some info relevant to the user, but then I get pages and pages of tasks that are associated with *me* but have nothing to do with the particular client. Any idea why that is? Is there a fix in the works?


Thanks,

Stephen





Hello Stephen,

Thanks for writing to us. Will have my support team reach out to understand this better..


Thanks for looking into it. For the time being, I removed the part in the freshplug that referenced tasks and it works properly for just the contact info. That said, it would be very helpful to see the related task info from Insightly directly in the ticket area. 


Cheers,

Stephen



Hello Stephen,

I have made changes to the Task part of Insightly freshplug. Please find the attached zip file. Let us know if it's working fine.

Thanks,

Nithin David


Hi,


I just tested it and it does not appear to show all tasks. (I first downloaded the main one again which was broken but then saw a new download on your post above). However now I get the error message:


There was a problem retrieving the tasks. Please refresh the page.


David


Hi David,


The error was caused because of the date format in the request. I have corrected it. Please update the latest code in your set up and get back to us if there's any clarification in this regard.


Regret for the inconvenience caused


Thanks

Nithin 


That looks like it works. Can you please remove my API key from the file though!


Thanks


David