dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
597 stars 282 forks source link

Get Event ID #319

Open ambrix opened 3 years ago

ambrix commented 3 years ago

I would like to display the ID of an event (event.id) in google calendar (using dialogflow fulfillment). So I inserted a showEvent () function but this doesn't work. Could someone tell me where is the mistake? I need the ID because I would like to be able to delete an event later.

/* ***** */ `function showEvents(agent) { return new Promise ((resolve, reject) => {calendar.events.list({ 'auth': serviceAccountAuth, 'calendarId': calendarId, 'timeMin': (new Date()).toISOString(), 'showDeleted': false, 'singleEvents': true, 'maxResults': 10, 'orderBy': 'startTime' }).then(function(response) { var events = response.result.items; console.log('events:', events); agent.add('Appointment List:');

if (events.length > 0) {
  for (let i = 0; i < events.length; i++) {
    var event = events[i];
    var when = event.start.dateTime;
    if (!when) {
      when = event.start.date;
    }
    agent.add(event.summary + ' (' + when + ')' + ' eventId:' + ' ' + event.id);
  }
} else {
  agent.add('No Events);
}

}); }); }`