Created
February 1, 2021 00:56
-
-
Save iaindooley/d09566a44a9d852fa61d121f8c5d8530 to your computer and use it in GitHub Desktop.
Map Calendly bookings to Crmble cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mapCalendlyBookingsToCrmbleCards(notification) | |
{ | |
var added = new Notification(notification).addedCard("Calendly Bookings"); | |
var booked_email = extractEmailFromCalendlyBooking(added); | |
var target_plugin = null; | |
new IterableCollection(TrelloApi.get("boards/"+this.notif.board().id()+"/plugins?filter=enabled")).each(function(loop) | |
{ | |
if(loop.name == "Crmble") | |
{ | |
target_plugin = loop.id; | |
} | |
}.bind(this)); | |
if(target_plugin) | |
{ | |
added.board().cards().each(function(card) | |
{ | |
if(fetchContactEmailFromCrmbleCard(target_plugin,card) == booked_email) | |
{ | |
card | |
//Set the contact card due to the booking time | |
.setDue(extractDateAndTimeFromCalendlyBooking(added)) | |
//and move to the top of the Meeting Booked list | |
.moveTo("Meeting Booked","top").archive(); | |
} | |
}); | |
} | |
} | |
function fetchContactEmailFromCrmbleCard(target_plugin,card) | |
{ | |
var email = null; | |
new IterableCollection(TrelloApi.get("cards/"+card.id()+"/pluginData")).each(function(plugin) | |
{ | |
if(plugin.idPlugin == target_plugin) | |
{ | |
try | |
{ | |
var contact = JSON.parse(plugin.value).contact; | |
var first = contact.firstName; | |
var last = contact.lastName; | |
var email = contact.email; | |
var phone = contact.phone; | |
} | |
catch(e) | |
{ | |
} | |
} | |
}); | |
return email; | |
} | |
function extractEmailFromCalendlyBooking(card) | |
{ | |
//IMPLEMENT ME! | |
//Need to look at specific format of emails | |
//as they arrive in Trello via BenkoBoard | |
} | |
function extractDateAndTimeFromCalendlyBooking(card) | |
{ | |
//IMPLEMENT ME! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment