Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created February 1, 2021 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/d09566a44a9d852fa61d121f8c5d8530 to your computer and use it in GitHub Desktop.
Save iaindooley/d09566a44a9d852fa61d121f8c5d8530 to your computer and use it in GitHub Desktop.
Map Calendly bookings to Crmble cards
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