📅

Calendar

Tags
Description
Features
Type
var now = new Date().getTime();
var tomorrow = now + (24 * 60 * 60 * 1000);

// get all the events from now for the next 24 hours
chatbox.integrations.googleCalendar.getEvents("phil_calendar", "phil@chatbox.com", now, tomorrow, "calEventCallback");

// calEventCallback
// useful for taking the return data from a Google Calendar getEvents call and
// using that data to populate a buttonList or pickList

if (statusCode != 200) {
 // do some error handling
 return;
}

// save the calendar data for later use perhaps by the buttonList
store.save("app", "calendarData", returnData);

var rd = JSON.parse(returnData);
var options = [];
for(var i = 0; i < rd.length; i++) {
   var e = rd[i];
   var title = e.title;
   var startTime = new Date(e.startTime).toLocaleTimeString();
   var endTime = new Date(e.endTime).toLocaleTimeString();
   var description = e.description;
   var attendees = e.attendees;
   var html = "<div class='eventTitle'>" + title + "</div>";
       html +="<div class='eventTime'>" + startTime + " to " + endTime + "</div>";
       html +="<div class='eventAttendees'>" + e.attendees.length + " Attendees </div>";
   options.push({"label": html, "value": String(i)});
}

console.log(options);

app.setElementOptions("bl", options);