서드 파티 회의 만들기

회의 솔루션 포드 내에서 매니페스트 에는 연결된 onCreateFunction가 있습니다. 부가기능은 이 함수를 호출하여 사용자가 회의 솔루션을 선택하려고 할 때마다 이벤트를 처리합니다.

부가기능 매니페스트에 설명된 각 onCreateFunction를 구현해야 합니다. 일반적으로 이러한 함수는 다음을 실행해야 합니다.

  1. Google Calendar 일정 정보(예: 일정 ID 또는 타사 회의 시스템에서 필요할 수 있는 참석자 목록을 회의를 생성할 수 있습니다.
  2. 서드 파티 회의 서비스에 연결하고 새 회의를 만듭니다. Google Calendar 일정 정보를 사용하여 일정을 예약할 수 있습니다.
  3. 어떤 이유로든 회의 생성 요청이 실패한 경우 다음 오류를 사용하세요. 빌드하고 반환하기 위한 정보를 ConferenceData 객체에 대한 ConferenceError 그 외의 경우에는 다음 단계를 완료합니다.
    1. 회의 동기화를 초기화합니다.
    2. 서드 파티 회의 서비스에서 반환한 정보를 사용하여 다음을 수행합니다. 새로운 포드를 빌드하고 ConferenceData 객체를 지정합니다.

이벤트 정보 가져오기

제3자 회의를 생성하려면 해당 회의에 대한 특정 정보를 Google Calendar 일정이 필요합니다. 필요한 정확한 일정 정보는 서로 다른 서드 파티 회의 시스템 간에 액세스할 수 있지만 여기에는 이벤트 시작 시간, 종료 시간, 요약, 참석자 목록 및 ID입니다.

호출되면 정의한 각 onCreateFunction에 에는 캘린더 및 일정 ID가 포함됩니다. 이 ID를 사용하여 전체 이벤트 정보를 Google Calendar 고급 서비스.

Google Calendar가 다음 날짜 이전에 일정에 회의 세부정보를 추가할 수 있습니다. 존재한다는 것입니다. 이 경우 Google Calendar는 onCreateFunction에 유효한 eventId를 지원하지만 이후 Calendar.Events.get()를 호출하면 이벤트가 존재하지 않는다는 오류 응답이 표시됩니다. 이러한 경우에는 자리표시자 데이터를 사용하여 서드 파티 회의를 만듭니다. 이 데이터는 다음에 이벤트가 발생하면 syncs.

서드 파티 회의 생성

onCreateFunction는 필요한 이벤트 데이터를 가져온 후에는 다음을 실행해야 합니다. 타사 회의 시스템에 연결하여 회의를 생성합니다. 일반적으로 이 작업은 회의 시스템에 연결할 수 있습니다. 서드 파티의 설명서를 확인하세요. 회의를 생성하는 데 사용할 수 있는 API 요청을 결정합니다. 있습니다.

Apps Script에서 외부 API 요청을 처리하는 가장 쉬운 방법은 Apps Script용 OAuth2 사용 또는 Apps Script용 OAuth1 오픈소스 라이브러리를 제공합니다. 그 외에 UrlFetch 서비스를 사용하여 외부 API에 연결 승인 세부정보를 명시적으로 처리해야 합니다.

회의 생성을 요청한 후 요청을 보낼 수 있습니다

회의 동기화 초기화

부가기능이 서드 파티 시스템에서 회의를 성공적으로 생성하면, 몇 가지 단계를 거쳐 syncing으로 변경하여 Google Calendar 일정이 회의에 반영됩니다.

캘린더 변경사항 동기화를 참조하세요. 회의 생성 후 동기화 설정에 대한 자세한 내용을 참조하세요.

회의 데이터 응답 작성

타사 서비스에서 반환한 회의 정보를 사용하여, 그러면 onCreateFunctionConferenceData 객체; 회의 데이터 섹션은 이 객체의 콘텐츠를 설명합니다. Google Calendar에서는 이 회의가 시작되면 이 정보를 사용하여 사용자를 회의로 안내합니다.

ConferenceData를 빌드할 때 사용할 경우 필드 길이, 진입점 URI, 허용되는 진입점 조합입니다. 예를 들어 단일 객체에 최대 1개의 VIDEO 진입점이 있을 수 있습니다. ConferenceData입니다. 다음 제한사항은 앞서 설명한 제한사항과 동일합니다. Calendar API 이벤트에서 해당 이벤트를 conferenceData 필드(여기에 설명된 일부 API 이벤트 필드) Apps Script에서 사용할 수 있습니다.

오류 처리

다음과 같은 이유로 회의 생성을 완료할 수 없는 경우가 있습니다. 발생하는 오류의 총량을 나타냅니다. 이러한 경우 부가기능은 애플리케이션을 빌드하고 배포하는 것 외에 오류 상태를 강력하게 처리해야 합니다 결과를 반환하는 ConferenceData 다음 객체를 포함하는 ConferenceError Google Calendar가 그에 따라 작업을 수행할 수 있습니다.

오류를 보고하기 위해 ConferenceData 객체를 구성할 때는 ConferenceData 구성요소를 포함해야 합니다. ConferenceError 객체. ConferenceErrors에는 ConferenceErrorType, 오류 메시지가 표시되고, 인증이 필요한 경우 타사 회의 시스템에 로그인해야 합니다.

다음은 onCreateFunction의 예를 보여줍니다( 함수는 무엇이든 될 수 있습니다. 부가기능 프로젝트에서만 정의하면 됩니다. 합니다.

create3rdPartyConference() 함수가 서드 파티 시스템에 연결 거기에서 회의를 생성하고 getAuthenticationUrl() 함수를 는 서드 파티 시스템 인증 URL을 만듭니다. 구현되지 않음 제3자 시스템의 세부 사항에 크게 의존하기 때문에 여기에 완전히 나와 있습니다.

initializeSyncing() 함수는 여기에 표시되지 않습니다. 사전 학습된 API에 대해 작업을 수행해야 합니다. 캘린더 변경사항 동기화를 참조하세요. 참조하세요.

/**
 *  Creates a conference, then builds and returns a ConferenceData object
 *  with the corresponding conference information. This method is called
 *  when a user selects a conference solution defined by the add-on that
 *  uses this function as its 'onCreateFunction' in the add-on manifest.
 *
 *  @param {Object} arg The default argument passed to a 'onCreateFunction';
 *      it carries information about the Google Calendar event.
 *  @return {ConferenceData}
 */
function createConference(arg) {
  const eventData = arg.eventData;
  const calendarId = eventData.calendarId;
  const eventId = eventData.eventId;

  // Retrieve the Calendar event information using the Calendar
  // Advanced service.
  var calendarEvent;
  try {
    calendarEvent = Calendar.Events.get(calendarId, eventId);
  } catch (err) {
    // The calendar event does not exist just yet; just proceed with the
    // given event ID and allow the event details to sync later.
    console.log(err);
    calendarEvent = {
      id: eventId,
    };
  }

  // Create a conference on the third-party service and return the
  // conference data or errors in a custom JSON object.
  var conferenceInfo = create3rdPartyConference(calendarEvent);

  // Build and return a ConferenceData object, either with conference or
  // error information.
  var dataBuilder = ConferenceDataService.newConferenceDataBuilder();

  if (!conferenceInfo.error) {
    // No error, so build the ConferenceData object from the
    // returned conference info.

    var phoneEntryPoint = ConferenceDataService.newEntryPoint()
        .setEntryPointType(ConferenceDataService.EntryPointType.PHONE)
        .setUri('tel:+' + conferenceInfo.phoneNumber)
        .setPin(conferenceInfo.phonePin);

    var adminEmailParameter = ConferenceDataService.newConferenceParameter()
        .setKey('adminEmail')
        .setValue(conferenceInfo.adminEmail);

    dataBuilder.setConferenceId(conferenceInfo.id)
        .addEntryPoint(phoneEntryPoint)
        .addConferenceParameter(adminEmailParameter)
        .setNotes(conferenceInfo.conferenceLegalNotice);

    if (conferenceInfo.videoUri) {
      var videoEntryPoint = ConferenceDataService.newEntryPoint()
          .setEntryPointType(ConferenceDataService.EntryPointType.VIDEO)
          .setUri(conferenceInfo.videoUri)
          .setPasscode(conferenceInfo.videoPasscode);
      dataBuilder.addEntryPoint(videoEntryPoint);
    }

    // Since the conference creation request succeeded, make sure that
    // syncing has been enabled.
    initializeSyncing(calendarId, eventId, conferenceInfo.id);

  } else if (conferenceInfo.error === 'AUTH') {
    // Authenentication error. Implement a function to build the correct
    // authenication URL for the third-party conferencing system.
    var authenticationUrl = getAuthenticationUrl();
    var error = ConferenceDataService.newConferenceError()
        .setConferenceErrorType(
            ConferenceDataService.ConferenceErrorType.AUTHENTICATION)
        .setAuthenticationUrl(authenticationUrl);
    dataBuilder.setError(error);

  } else {
    // Other error type;
    var error = ConferenceDataService.newConferenceError()
        .setConferenceErrorType(
            ConferenceDataService.ConferenceErrorType.TEMPORARY);
    dataBuilder.setError(error);
  }

  // Don't forget to build the ConferenceData object.
  return dataBuilder.build();
}


/**
 *  Contact the third-party conferencing system to create a conference there,
 *  using the provided calendar event information. Collects and retuns the
 *  conference data returned by the third-party system in a custom JSON object
 *  with the following fields:
 *
 *    data.adminEmail - the conference administrator's email
 *    data.conferenceLegalNotice - the conference legal notice text
 *    data.error - Only present if there was an error during
 *         conference creation. Equal to 'AUTH' if the add-on user needs to
 *         authorize on the third-party system.
 *    data.id - the conference ID
 *    data.phoneNumber - the conference phone entry point phone number
 *    data.phonePin - the conference phone entry point PIN
 *    data.videoPasscode - the conference video entry point passcode
 *    data.videoUri - the conference video entry point URI
 *
 *  The above fields are specific to this example; which conference information
 *  your add-on needs is dependent on the third-party conferencing system
 *  requirements.
 *
 * @param {Object} calendarEvent A Calendar Event resource object returned by
 *     the Google Calendar API.
 * @return {Object}
 */
function create3rdPartyConference(calendarEvent) {
  var data = {};

  // Implementation details dependent on the third-party system API.
  // Typically one or more API calls are made to create the conference and
  // acquire its relevant data, which is then put in to the returned JSON
  // object.

  return data;
}

/**
 *  Return the URL used to authenticate the user with the third-party
 *  conferencing system.
 *
 *  @return {String}
 */
function getAuthenticationUrl() {
  var url;
  // Implementation details dependent on the third-party system.

  return url;
}