तीसरे पक्ष के कॉन्फ़्रेंस बनाना

आपके स्क्रिप्ट प्रोजेक्ट में तय किए गए हर कॉन्फ़्रेंस सलूशन के मेनिफ़ेस्ट में एक onCreateFunction शामिल होता है. जब भी कोई उपयोगकर्ता उस कॉन्फ़्रेंस समाधान को कोई इवेंट चुनने की कोशिश करता है, तब ऐड-ऑन इस फ़ंक्शन को कॉन्फ़्रेंस बनाने के लिए कॉल करता है.

आपको अपने ऐड-ऑन मेनिफ़ेस्ट में बताए गए हर onCreateFunction को लागू करना होगा. आम तौर पर, इन फ़ंक्शन को नीचे दिया गया तरीका अपनाना चाहिए:

  1. Google Calendar इवेंट की जानकारी, जैसे कि इवेंट आईडी या मेहमानों की सूची वापस पाएं. कॉन्फ़्रेंस बनाने के लिए, तीसरे पक्ष के कॉन्फ़्रेंसिंग सिस्टम को इसकी ज़रूरत पड़ सकती है.
  2. Google Calendar इवेंट की जानकारी का इस्तेमाल करके, तीसरे पक्ष की कॉन्फ़्रेंसिंग सेवा से कनेक्ट करें और नई कॉन्फ़्रेंस बनाएं.
  3. अगर किसी वजह से कॉन्फ़्रेंस बनाने का अनुरोध पूरा नहीं हो पाता है, तो गड़बड़ी की जानकारी का इस्तेमाल करके, ConferenceData ऐसा ऑब्जेक्ट बनाएं और दिखाएं जिसमें ConferenceError हो. या फिर, अगले चरण पूरे करें.
    1. कॉन्फ़्रेंस सिंक करना शुरू करें.
    2. नया ConferenceData ऑब्जेक्ट बनाने और उसे वापस करने के लिए, तीसरे पक्ष की कॉन्फ़्रेंसिंग सेवा से मिली जानकारी का इस्तेमाल करें.

इवेंट की जानकारी फ़ेच की जा रही है

तीसरे पक्ष का कॉन्फ़्रेंस बनाने के लिए, उससे जुड़े Google Calendar इवेंट की कुछ जानकारी की ज़रूरत होती है. तीसरे पक्ष के अलग-अलग कॉन्फ़्रेंस सिस्टम पर, इवेंट की सटीक जानकारी अलग-अलग होती है. हालांकि, अक्सर इसमें इवेंट के शुरू होने का समय, उसके खत्म होने का समय, खास जानकारी, मेहमानों की सूची, और आईडी शामिल होता है.

कॉल किए जाने पर, आपके तय किए गए हर onCreateFunction के लिए एक आर्ग्युमेंट पास किया जाता है. इसमें कैलेंडर और इवेंट आईडी शामिल होते हैं. आप इन आईडी का इस्तेमाल करके Google Calendar की बेहतर सेवा का इस्तेमाल करके इवेंट की पूरी जानकारी पा सकते हैं.

Google Calendar में, इवेंट के होने से पहले ही उसमें कॉन्फ़्रेंस की जानकारी जोड़ दी जाती है. ऐसे मामलों में, Google Calendar, onCreateFunction को एक मान्य eventId पास करता है, लेकिन Calendar.Events.get() को बाद में किए जाने वाले कॉल की वजह से, गड़बड़ी का जवाब मिल सकता है कि इवेंट मौजूद नहीं है. ऐसे मामलों में, प्लेसहोल्डर डेटा का इस्तेमाल करके तीसरे पक्ष का कॉन्फ़्रेंस बनाना सबसे अच्छा होता है; अगली बार इवेंट सिंक होने पर इस डेटा को बदल दिया जाता है.

तीसरे पक्ष का कॉन्फ़्रेंस बनाया जा रहा है

onCreateFunction से ज़रूरी इवेंट डेटा मिलने के बाद, कॉन्फ़्रेंस बनाने के लिए इसे तीसरे पक्ष के कॉन्फ़्रेंसिंग सिस्टम से कनेक्ट करना होगा. आम तौर पर, इसके लिए तीसरे पक्ष के कॉन्फ़्रेंसिंग सिस्टम के साथ काम करने वाले एपीआई अनुरोधों को स्वीकार किया जाता है. कॉन्फ़्रेंस बनाने के लिए, एपीआई के कौनसे अनुरोधों का इस्तेमाल किया जा सकता है, यह तय करने के लिए तीसरे पक्ष के कॉन्फ़्रेंसिंग समाधान से जुड़े दस्तावेज़ देखें.

Apps Script में, बाहरी एपीआई अनुरोधों को मैनेज करने का सबसे आसान तरीका Apps Script के लिए OAuth2 या Apps Script के लिए OAuth1 ओपन-सोर्स लाइब्रेरी का इस्तेमाल करना है. UrlFetch सेवा का इस्तेमाल करके, बाहरी एपीआई से कनेक्ट भी किया जा सकता है. हालांकि, इसके लिए आपको अनुमति की जानकारी को साफ़ तौर पर मैनेज करना होगा.

कॉन्फ़्रेंस बनाने का अनुरोध करने के बाद, नई कॉन्फ़्रेंस की जानकारी वापस पाने के लिए, आपको और अनुरोध करने पड़ सकते हैं.

कॉन्फ़्रेंस सिंक करने की प्रोसेस शुरू करें

ऐड-ऑन से तीसरे पक्ष के सिस्टम पर कॉन्फ़्रेंस बनाने के बाद, सिंक करने की सुविधा को चालू करने के लिए कुछ ज़रूरी कदम उठाने चाहिए, ताकि Google Calendar इवेंट में किए गए बदलाव कॉन्फ़्रेंस में दिखें.

कॉन्फ़्रेंस बनाने के बाद, सिंक करने की सुविधा सेट अप करने के बारे में जानने के लिए, Calendar में किए गए बदलावों को सिंक करना देखें.

कॉन्फ़्रेंस डेटा का जवाब देना

तीसरे पक्ष की सेवा से मिलने वाली कॉन्फ़्रेंस की जानकारी का इस्तेमाल करके, onCreateFunction को कोई ConferenceData ऑब्जेक्ट बनाना और दिखाना चाहिए. कॉन्फ़्रेंस डेटा सेक्शन में, इस ऑब्जेक्ट के कॉन्टेंट के बारे में बताया जाता है. Google Calendar इसका इस्तेमाल कॉन्फ़्रेंस शुरू होने के बाद, लोगों को कॉन्फ़्रेंस में भेजने के लिए करता है.

ConferenceData ऑब्जेक्ट बनाते समय, यह ध्यान रखें कि फ़ील्ड की लंबाई, एंट्री पॉइंट यूआरआई के फ़ॉर्मैट, और एंट्री पॉइंट के मान्य कॉम्बिनेशन की कुछ सीमाएं हैं. उदाहरण के लिए, एक ConferenceData में ज़्यादा से ज़्यादा एक VIDEO एंट्री पॉइंट हो सकता है. ये सीमाएं, उनसे जुड़े conferenceData फ़ील्ड के लिए कैलेंडर एपीआई इवेंट में बताई गई सीमाओं के जैसी हैं. हालांकि, वहां बताए गए सभी एपीआई इवेंट फ़ील्ड, Apps Script में उपलब्ध नहीं हैं.

गड़बड़ियों को ठीक करना

कुछ मामलों में कॉन्फ़्रेंस बनाने की प्रोसेस पूरी नहीं हो पाती, क्योंकि तीसरे पक्ष की कॉन्फ़्रेंसिंग सिस्टम से मिली गड़बड़ी दिखती है. इन मामलों में आपके ऐड-ऑन को ConferenceData जानकारी वाला ConferenceError ऑब्जेक्ट बनाकर और दिखाकर गड़बड़ी की स्थिति को बेहतर तरीके से ठीक करना चाहिए, ताकि Google Calendar उसके हिसाब से काम कर सके.

किसी गड़बड़ी की शिकायत करने के लिए ConferenceData ऑब्जेक्ट बनाते समय, आपको ConferenceError ऑब्जेक्ट के अलावा, कोई भी ConferenceData कॉम्पोनेंट शामिल करने की ज़रूरत नहीं होती. ConferenceErrors में ConferenceErrorType, गड़बड़ी का मैसेज दिख सकता है. पुष्टि करने से जुड़ी समस्याएं होने पर, एक ऐसा यूआरएल हो सकता है जो उपयोगकर्ताओं को तीसरे पक्ष के कॉन्फ़्रेंसिंग सिस्टम में लॉग इन करने की सुविधा देता है.

उदाहरण

नीचे एक onCreateFunction का उदाहरण दिया गया है (ध्यान दें कि फ़ंक्शन का नाम कुछ भी हो सकता है; आपको इसे सिर्फ़ अपने ऐड-ऑन प्रोजेक्ट मेनिफ़ेस्ट में तय करना होता है).

create3rdPartyConference() फ़ंक्शन कॉन्फ़्रेंस बनाने के लिए तीसरे पक्ष के सिस्टम से संपर्क करता है और getAuthenticationUrl() फ़ंक्शन तीसरे पक्ष के सिस्टम की पुष्टि करने वाला यूआरएल बनाता है. इन्हें यहां पूरी तरह से लागू नहीं किया गया है, क्योंकि ये तीसरे पक्ष के सिस्टम से जुड़ी जानकारी पर निर्भर करते हैं.

initializeSyncing() फ़ंक्शन यहां नहीं दिखाया गया है. यह सिंक करने के लिए ज़रूरी सभी शुरुआती काम करता है. जानकारी के लिए कैलेंडर बदलाव सिंक करना देखें.

/**
 *  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;
}