2

I am trying to develop google calendar add-on like zoom meeting.

In appsscript.json file, below code is there.

 "calendar": {
      "conferenceSolution": [{
        "onCreateFunction": "createConference",
        "id": "1",
        "name": "Meeting",
        "logoUrl": "https://companyxyz.com/images/logo192.png"
      }],
      "eventOpenTrigger": {
        "runFunction": "buildSimpleCard"
      },
      "currentEventAccess": "READ_WRITE"      
    }
  }

In Calendar.gs, below code is there.

function createConference(e) {
  Logger.log(e);
  var dataBuilder = ConferenceDataService.newConferenceDataBuilder();
  return dataBuilder.build();  
}
/**
   * Build a simple card with a button that sends a notification.
   * This function is called as part of the eventOpenTrigger that builds
   * a UI when the user opens a Calendar event.
   *
   * @param e The event object passed to eventOpenTrigger function.
   * @return {Card}
   */
  function buildSimpleCard() {
    var buttonAction = CardService.newAction()
        .setFunctionName('onSaveConferenceOptionsButtonClicked')
        .setParameters(
          {'phone': "1555123467", 'adminEmail': "joyce@example.com"});
    var button = CardService.newTextButton()
        .setText('Add new attendee')
        .setOnClickAction(buttonAction);
    var buttonSet = CardService.newButtonSet()
      .addButton(button);

    var section = CardService.newCardSection()
               .setHeader("addon")
            .addWidget(buttonSet);

   var card = CardService.newCardBuilder()
      .addSection(section)
      //.setFixedFooter(footer);

   return card.build();
    // Check the event object to determine if the user can set
    // conference data and disable the button if not.
  //  if (!e.calendar.capabilities.canSetConferenceData) {
     // button.setDisabled(true);
 //   }

    // ...continue creating card sections and widgets, then create a Card
    // object to add them to. Return the built Card object.
  }

  /**
   * Callback function for a button action. Sets conference data for the
   * Calendar event being edited.
   *
   * @param {Object} e The action event object.
   * @return {CalendarEventActionResponse}
   */
  function onSaveConferenceOptionsButtonClicked(e) {
    var parameters = e.commonEventObject.parameters;

    // Create an entry point and a conference parameter.
    var phoneEntryPoint = ConferenceDataService.newEntryPoint()
      .setEntryPointType(ConferenceDataService.EntryPointType.PHONE)
      .setUri('tel:' + parameters['phone']);

    var adminEmailParameter = ConferenceDataService.newConferenceParameter()
        .setKey('adminEmail')
        .setValue(parameters['adminEmail']);

    // Create a conference data object to set to this Calendar event.
    var conferenceData = ConferenceDataService.newConferenceDataBuilder()
        .addEntryPoint(phoneEntryPoint)
        .addConferenceParameter(adminEmailParameter)
        .setConferenceSolutionId(1)
        .build();

    return CardService.newCalendarEventActionResponseBuilder()
        .setConferenceData(conferenceData)
        .build();
  }

I have published this add-on from Publish->Deploy from menifest.

Executing this code giving me error of ReferenceError: ConferenceDataService is not defined.

I have searched all the possible references, but not able to get any solution. Please suggest me proper solution for this.

Sonal Shah
  • 41
  • 4
  • Hello @SonalShah, did you turn on the `Calendar API` from the Apps Script? You can check if you go to `Resources` -> `Advanced Google services`. Cheers! – ale13 Mar 30 '20 at 11:58
  • Yes. I have turned on Calendar API. I checked somewhere that developer needs to be whitelisted to get access of conferencedata service. but not able to find the process for the same. – Sonal Shah Mar 30 '20 at 12:37
  • Hello @SonalShah, which runtime version are you using for your project? Cheers! – ale13 Apr 01 '20 at 14:03
  • I am using DEPRECATED_ES5 runtime version – Sonal Shah Apr 02 '20 at 15:07
  • Hello @SonalShah, as explained in this documentation [here](https://developers.google.com/apps-script/reference/conference-data), "Currently you can only use this service in conjunction with Calendar conferencing add-ons or G Suite add-ons that interact with Google Calendar conferencing. Only add-ons that connect to third-party conferencing systems have need of this service". Can you confirm this is the behavior you are currently having issues with? Cheers! – ale13 Apr 06 '20 at 14:28
  • Thanks @ale13 for the prompt answers..May be because of this behaviour, I am facing issues..but I am not sure and also I am not getting what should I do to overcome this behaviour? Is there some setting available in google console for that? As per above comment, I am already building new conferencing add-on, so it should be supported. – Sonal Shah Apr 07 '20 at 03:49
  • @SonalShah, from where did you get the manifest structure for conference solution? – Sanjay Prajapati Apr 09 '20 at 07:12
  • Some where from one of the google calendar post. – Sonal Shah Apr 10 '20 at 04:05
  • Hello Sonal, just like @SanjayPrajapati has mentioned, would you mind double checking to see if the manifest structure is the accurate one, and moreover if it contains the required data? Cheers! – ale13 Apr 13 '20 at 07:37
  • Hey @ale13, Can you help me with sample structure of manifest file for third party conferencing solution and what I am missing !! I am not able to find proper documentation for cross verifying of the structure. it will be very helpful, If i can get steps to load conferencing information upon selection of third party add-on from 'add conference' dropdown, while event creation in google calendar? – Sonal Shah Apr 14 '20 at 12:31
  • Hello @SonalShah, which service are you using? Have you checked this [here](https://developers.google.com/gsuite/add-ons/concepts/gsuite-manifests#manifest_structure_for_g_suite_add-ons)? Cheers! – ale13 Apr 14 '20 at 12:35
  • @ale13, I am not getting about which service you are asking.. I am using UrlFetch for authorize third party service. – Sonal Shah Apr 14 '20 at 12:50
  • @ale13, Can you tell me what is wrong in the manifest file I have posted in the question? – Sonal Shah Apr 14 '20 at 12:51
  • @ale13, Is it something like I must have to do oauth verification, for accessing conferencedataservice? – Sonal Shah Apr 15 '20 at 02:52
  • Hello @SonalShah, thank you for the details provided, I understand at what you are referring to now. Do you have the same issue as described [here](https://issuetracker.google.com/issues/150402756)? Cheers! – ale13 Apr 17 '20 at 13:10

1 Answers1

1

According to this comment from this issue here, it looks like there has been a change regarding this.

When testing the above code, the ReferenceError: ConferenceDataService is not defined. is not displayed anymore and the code runs as expected.

For other methods specific to the ConferenceDataService you can check the documentation here.

Reference

ale13
  • 5,679
  • 3
  • 10
  • 25