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

हर कॉन्फ़्रेंस समाधान आपने अपने स्क्रिप्ट प्रोजेक्ट में तय किया है मेनिफ़ेस्ट एक 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 ओपन सोर्स लाइब्रेरी शामिल हैं. आप यह भी कर सकते हैं Url मिलने की सुविधा का इस्तेमाल करके बाहरी एपीआई से कनेक्ट करना, हालांकि, इसके लिए आपको अनुमति से जुड़ी जानकारी को साफ़ तौर पर मैनेज करना होगा.

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

कॉन्फ़्रेंस सिंक करना शुरू करें

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

कैलेंडर के बदलावों को सिंक करना देखें देखें.

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

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

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

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

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

किसी गड़बड़ी की शिकायत करने के लिए, ConferenceData ऑब्जेक्ट बनाते समय, ये काम न करें इसके अलावा कोई ConferenceData कॉम्पोनेंट शामिल करना ज़रूरी है ConferenceError ऑब्जेक्ट. 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;
}