Google Chat থেকে মিটিং শিডিউল করুন

কোডিং স্তর : মধ্যবর্তী
সময়কাল : ২৫ মিনিট
প্রকল্পের ধরণ : গুগল চ্যাট অ্যাপ

উদ্দেশ্য

  • সমাধানটি কী কাজ করে তা বুঝুন।
  • সলিউশনের মধ্যে অ্যাপস স্ক্রিপ্ট সার্ভিসগুলো কী কাজ করে তা বুঝুন।
  • আপনার পরিবেশ প্রস্তুত করুন।
  • স্ক্রিপ্টটি সেট আপ করুন।
  • স্ক্রিপ্টটি চালান।

এই সমাধান সম্পর্কে

ডাইরেক্ট মেসেজ (DM) বা গুগল চ্যাটের কোনো স্পেস থেকে গুগল ক্যালেন্ডারে একটি মিটিং শিডিউল করুন। আপনি মিটিংয়ের জন্য বিষয়, শুরুর সময় বা সময়কালের মতো নির্দিষ্ট বিবরণ সেট করতে পারেন, অথবা তাৎক্ষণিক মিটিং শিডিউল করার জন্য ডিফল্ট সেটিংস ব্যবহার করতে পারেন।

মিটিং শিডিউলার চ্যাট অ্যাপের ডায়ালগ ইন্টারফেস

এটি কীভাবে কাজ করে

চ্যাট অ্যাপ স্ক্রিপ্টটি ব্যবহারকারীদের কাছ থেকে মিটিংয়ের বিবরণ নিতে এবং ক্যালেন্ডার ইভেন্ট নির্ধারণ করতে স্ল্যাশ কমান্ডডায়ালগ ব্যবহার করে। স্ক্রিপ্টটিতে ডিফল্ট মিটিং সেটিংস অন্তর্ভুক্ত রয়েছে, যা আপনার প্রয়োজন অনুযায়ী কাস্টমাইজ করা যেতে পারে।

অ্যাপস স্ক্রিপ্ট পরিষেবা

এই সমাধানটি নিম্নলিখিত পরিষেবাগুলি ব্যবহার করে:

  • ক্যালেন্ডার পরিষেবা – প্রদত্ত মিটিং তথ্য থেকে ক্যালেন্ডার ইভেন্ট তৈরি করে।
  • বেস সার্ভিস – স্ক্রিপ্টের টাইম জোন পাওয়ার জন্য Session ক্লাস ব্যবহার করে। ক্যালেন্ডার ইভেন্টটি শিডিউল করার সময় এই টাইম জোনটি ব্যবহার করে।
  • ইউটিলিটি সার্ভিস – ক্যালেন্ডার ইভেন্টের জন্য তারিখ ফরম্যাট করে এবং ইভেন্ট ইউআরএল পেতে সাহায্য করার জন্য ইভেন্ট আইডি এনকোড করে।

পূর্বশর্ত

আপনার পরিবেশ তৈরি করুন

গুগল ক্লাউড কনসোলে আপনার ক্লাউড প্রজেক্টটি খুলুন।

যদি আগে থেকে খোলা না থাকে, তাহলে এই স্যাম্পলটির জন্য আপনি যে ক্লাউড প্রজেক্টটি ব্যবহার করতে চান সেটি খুলুন:

  1. গুগল ক্লাউড কনসোলে, 'Select a project' পেজে যান।

    একটি ক্লাউড প্রকল্প নির্বাচন করুন

  2. আপনি যে গুগল ক্লাউড প্রজেক্টটি ব্যবহার করতে চান, সেটি নির্বাচন করুন। অথবা, 'Create project'-এ ক্লিক করুন এবং স্ক্রিনে দেওয়া নির্দেশাবলী অনুসরণ করুন। আপনি যদি একটি গুগল ক্লাউড প্রজেক্ট তৈরি করেন, তাহলে প্রজেক্টটির জন্য বিলিং চালু করার প্রয়োজন হতে পারে।

এপিআই চালু করুন

গুগল এপিআই ব্যবহার করার আগে, আপনাকে একটি গুগল ক্লাউড প্রজেক্টে সেগুলি চালু করতে হবে। আপনি একটি একক গুগল ক্লাউড প্রজেক্টে এক বা একাধিক এপিআই চালু করতে পারেন।

সমস্ত চ্যাট অ্যাপের জন্য একটি সম্মতি স্ক্রিন কনফিগারেশন প্রয়োজন। আপনার অ্যাপের OAuth সম্মতি স্ক্রিন কনফিগার করার মাধ্যমে নির্ধারিত হয় যে Google ব্যবহারকারীদের কী দেখাবে এবং আপনার অ্যাপটি নিবন্ধিত হয়, যাতে আপনি পরবর্তীতে এটি প্রকাশ করতে পারেন।

  1. Google API কনসোলে, > Google Auth প্ল্যাটফর্ম > ব্র্যান্ডিং- এ যান।

    ব্র্যান্ডিং-এ যান

  2. আপনি যদি ইতিমধ্যেই Google Auth প্ল্যাটফর্মটি কনফিগার করে থাকেন, তাহলে আপনি Branding , Audience , এবং Data Access- এ নিম্নলিখিত OAuth Consent Screen সেটিংস কনফিগার করতে পারেন। যদি আপনি এমন কোনো বার্তা দেখতে পান যেখানে লেখা আছে ‘Google Auth প্ল্যাটফর্ম এখনও কনফিগার করা হয়নি’ , তাহলে Get Started-এ ক্লিক করুন:
    1. 'অ্যাপ ইনফরমেশন'- এর অধীনে 'অ্যাপ নেম' -এ অ্যাপটির জন্য একটি নাম লিখুন।
    2. ব্যবহারকারী সহায়তা ইমেল- এ, এমন একটি সহায়তা ইমেল ঠিকানা বেছে নিন যেখানে ব্যবহারকারীরা তাদের সম্মতি সম্পর্কে কোনো প্রশ্ন থাকলে আপনার সাথে যোগাযোগ করতে পারে।
    3. পরবর্তী ধাপে যান।
    4. Audience-এর অধীনে Internal নির্বাচন করুন।
    5. পরবর্তী ধাপে যান।
    6. যোগাযোগের তথ্যের অধীনে, একটি ইমেল ঠিকানা লিখুন যেখানে আপনার প্রকল্পের যেকোনো পরিবর্তন সম্পর্কে আপনাকে জানানো যাবে।
    7. পরবর্তী ধাপে যান।
    8. Finish-এর অধীনে, Google API Services ব্যবহারকারীর ডেটা নীতি পর্যালোচনা করুন এবং যদি আপনি সম্মত হন, তাহলে I agree to the Google API Services: User Data Policy নির্বাচন করুন।
    9. চালিয়ে যান-এ ক্লিক করুন।
    10. তৈরি করুন- এ ক্লিক করুন।
  3. আপাতত, আপনি স্কোপ যোগ করা এড়িয়ে যেতে পারেন। ভবিষ্যতে, যখন আপনি আপনার Google Workspace অর্গানাইজেশনের বাইরে ব্যবহারের জন্য কোনো অ্যাপ তৈরি করবেন, তখন আপনাকে অবশ্যই ইউজার টাইপ (User type) পরিবর্তন করে ‘এক্সটার্নাল’ ( External ) করতে হবে। এরপর আপনার অ্যাপের জন্য প্রয়োজনীয় অথরাইজেশন স্কোপগুলো যোগ করুন। আরও জানতে, সম্পূর্ণ ‘কনফিগার OAuth কনসেন্ট’ (Configure OAuth consent) গাইডটি দেখুন।

স্ক্রিপ্টটি সেট আপ করুন

অ্যাপস স্ক্রিপ্ট প্রজেক্টটি তৈরি করুন

  1. Google Chat Apps থেকে মিটিং শিডিউল করার স্ক্রিপ্ট প্রজেক্টটি খুলতে নিচের বাটনটিতে ক্লিক করুন।
    প্রকল্পটি খুলুন
  2. ওভারভিউ ক্লিক করুন।
  3. ওভারভিউ পৃষ্ঠায়, 'একটি অনুলিপি তৈরি করুন'-এ ক্লিক করুন। অনুলিপি তৈরির আইকন .

ভবিষ্যতে, আপনি যদি নির্দিষ্ট Google API ব্যবহার করতে বা আপনার অ্যাপ প্রকাশ করতে চান, তাহলে আপনাকে অবশ্যই আপনার ক্লাউড প্রজেক্টকে আপনার অ্যাপস স্ক্রিপ্ট প্রজেক্টের সাথে যুক্ত করতে হবে। এই নির্দেশিকার জন্য, আপনাকে তা করতে হবে না। আরও জানতে, Google ক্লাউড প্রজেক্ট নির্দেশিকা দেখুন।

একটি টেস্ট ডেপ্লয়মেন্ট তৈরি করুন

  1. আপনার কপি করা অ্যাপস স্ক্রিপ্ট প্রজেক্টে, Deploy > Test deployments-এ ক্লিক করুন।
  2. পরবর্তী ধাপে ব্যবহারের জন্য হেড ডিপ্লয়মেন্ট আইডিটি কপি করুন এবং 'সম্পন্ন' বোতামে ক্লিক করুন।

চ্যাট এপিআই কনফিগার করুন

  1. In the Google API Console, go to the Chat API page.
    চ্যাট এপিআই-তে যান
  2. কনফিগারেশন- এ ক্লিক করুন।
  3. 'এই চ্যাট অ্যাপটিকে একটি গুগল ওয়ার্কস্পেস অ্যাড-অন হিসাবে তৈরি করুন ' বিকল্পটি থেকে টিক চিহ্ন তুলে দিন। নিশ্চিত করার জন্য একটি ডায়ালগ বক্স খুলবে। ডায়ালগ বক্সে, 'অক্ষম করুন' (Disable) বোতামে ক্লিক করুন।
  4. নিম্নলিখিত তথ্য দিয়ে চ্যাট এপিআই কনফিগার করুন:
    • নাম : Meeting Scheduler
    • অ্যাভাটার ইউআরএল : এমন একটি ইউআরএল যোগ করুন যা ন্যূনতম ২৫৬x২৫৬ পিক্সেল আকারের একটি ছবির দিকে নির্দেশ করে।
    • বিবরণ : Quickly create meetings.
    • কার্যকারিতা : ব্যবহারকারীদের সরাসরি অ্যাপে মেসেজ পাঠানোর এবং তা স্পেসে যোগ করার সুযোগ দিতে উভয় বক্সে টিক দিন।
    • সংযোগ সেটিংস : অ্যাপস স্ক্রিপ্ট-এ ক্লিক করুন এবং হেড ডিপ্লয়মেন্ট আইডি প্রবেশ করান।
    • স্ল্যাশ কমান্ড : /help এবং /schedule_Meeting জন্য স্ল্যাশ কমান্ড যোগ করতে নিচের ধাপগুলো অনুসরণ করুন:
      1. ‘Add slash command’-এ ক্লিক করুন এবং নিম্নলিখিত তথ্য দিয়ে এটি কনফিগার করুন:
        • নাম : /help
        • কমান্ড আইডি : 1
        • বিবরণ : Learn what this app does.
      2. আবার 'Add slash command'-এ ক্লিক করুন এবং নিম্নলিখিত তথ্য দিয়ে এটি কনফিগার করুন:
        • নাম : /schedule_Meeting
        • কমান্ড আইডি : 2
        • বিবরণ : Schedule a meeting.
        • 'একটি ডায়ালগ বক্স খোলে ' বিকল্পটি চেক করুন।
    • অনুমতি : আপনার ডোমেইনের নির্দিষ্ট ব্যক্তি ও গোষ্ঠী নির্বাচন করুন এবং আপনার ইমেল ঠিকানা লিখুন।
  5. সেভ-এ ক্লিক করুন এবং পেজটি রিফ্রেশ করুন।
  6. কনফিগারেশন পেজে, ‘অ্যাপ স্ট্যাটাস’- এর অধীনে, স্ট্যাটাসটি ‘লাইভ – ব্যবহারকারীদের জন্য উপলব্ধ’ হিসেবে সেট করুন।
  7. সংরক্ষণ করুন- এ ক্লিক করুন।

স্ক্রিপ্টটি চালান

  1. গুগল চ্যাট খুলুন।
  2. চ্যাট যোগ করতে 'স্টার্ট এ চ্যাট এ ক্লিক করুন।
  3. অ্যাপটির নাম, Meeting Scheduler , দিয়ে অনুসন্ধান করুন।
  4. অনুমোদনের জন্য অনুরোধ জানাতে hello এর মতো একটি প্রাথমিক বার্তা পাঠান।
  5. অ্যাপটি উত্তর দিলে, কনফিগার-এ ক্লিক করুন এবং অ্যাপটিকে অনুমোদন দিন। যদি OAuth সম্মতি স্ক্রিনে ‘ এই অ্যাপটি যাচাই করা হয়নি ’ সতর্কবার্তাটি প্রদর্শিত হয়, তাহলে অ্যাডভান্সড > {প্রজেক্টের নাম}-এ যান (অনিরাপদ) নির্বাচন করে এগিয়ে যান।

  6. অ্যাপে /schedule_Meeting পাঠান।

  7. ডায়ালগ বক্সে, আমন্ত্রিতদের মধ্যে অন্তত একজনের ইমেল ঠিকানা যোগ করুন। আপনি অন্যান্য ফিল্ডগুলো আপডেট করতে পারেন অথবা ডিফল্ট এন্ট্রিগুলো ব্যবহার করতে পারেন।

  8. সাবমিট-এ ক্লিক করুন।

  9. মিটিংটি দেখতে, ‘ওপেন ক্যালেন্ডার ইভেন্ট’-এ ক্লিক করুন।

কোডটি পর্যালোচনা করুন

এই সলিউশনের অ্যাপস স্ক্রিপ্ট কোড পর্যালোচনা করতে, নিচে দেওয়া 'ভিউ সোর্স কোড'-এ ক্লিক করুন:

উৎস কোড দেখুন

কোড.জিএস

apps-script/schedule-meetings/Code.js
// To learn how to use this script, refer to the documentation:
// https://developers.google.com/workspace/chat/tutorial-schedule-meetings

/*
Copyright 2022 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Application constants
const APPNAME = "Chat Meeting Scheduler";
const SLASHCOMMAND = {
  HELP: 1, // /help
  DIALOG: 2, // /schedule_Meeting
};

/**
 * Responds to an ADDED_TO_SPACE event in Google Chat.
 * Called when the Chat app is added to a space. The Chat app can either be directly added to the space
 * or added by a @mention. If the Chat app is added by a @mention, the event object includes a message property.
 * Returns a Message object, which is usually a welcome message informing users about the Chat app.
 *
 * @param {Object} event The event object from Google Chat
 */
function onAddToSpace(event) {
  let message = "";

  // Personalizes the message depending on how the Chat app is called.
  if (event.space.singleUserBotDm) {
    message = `Hi ${event.user.displayName}!`;
  } else {
    const spaceName = event.space.displayName
      ? event.space.displayName
      : "this chat";
    message = `Hi! Thank you for adding me to ${spaceName}`;
  }

  // Lets users know what they can do and how they can get help.
  message = `${message}/nI can quickly schedule a meeting for you with just a few clicks.Try me out by typing */schedule_Meeting*. /nTo learn what else I can do, type */help*.`;

  return { text: message };
}

/**
 * Responds to a MESSAGE event triggered in Chat.
 * Called when the Chat app is already in the space and the user invokes it via @mention or / command.
 * Returns a message object containing the Chat app's response. For this Chat app, the response is either the
 * help text or the dialog to schedule a meeting.
 *
 * @param {object} event The event object from Google Chat
 * @return {object} JSON-formatted response as text or Card message
 */
function onMessage(event) {
  // Handles regular onMessage logic.
  // Evaluates if and handles for all slash commands.
  if (event.message.slashCommand) {
    switch (event.message.slashCommand.commandId) {
      case SLASHCOMMAND.DIALOG: // Displays meeting dialog for /schedule_Meeting.
        // TODO update this with your own logic to set meeting recipients, subjects, etc (e.g. a group email).
        return getInputFormAsDialog_({
          invitee: "",
          startTime: getTopOfHourDateString_(),
          duration: 30,
          subject: "Status Stand-up",
          body: "Scheduling a quick status stand-up meeting.",
        });

      case SLASHCOMMAND.HELP: // Responds with help text for /help.
        return getHelpTextResponse_();

      /* TODO Add other use cases here. E.g:
      case SLASHCOMMAND.NEW_FEATURE:  // Your Feature Here
        getDialogForAddContact(message);
      */
    }
  }
  // Returns text if users didn't invoke a slash command.
  return { text: "No action taken - use Slash Commands." };
}

/**
 * Responds to a CARD_CLICKED event triggered in Chat.
 * @param {object} event the event object from Chat
 * @return {object} JSON-formatted response
 * @see https://developers.google.com/workspace/chat/receive-respond-interactions
 */
function onCardClick(event) {
  if (event.action.actionMethodName === "handleFormSubmit") {
    const recipients = getFieldValue_(event.common.formInputs, "email");
    const subject = getFieldValue_(event.common.formInputs, "subject");
    const body = getFieldValue_(event.common.formInputs, "body");

    // Assumes dialog card inputs for date and times are in the correct format. mm/dd/yyy HH:MM
    const dateTimeInput = getFieldValue_(event.common.formInputs, "date");
    const startTime = getStartTimeAsDateObject_(dateTimeInput);
    const duration = Number(
      getFieldValue_(event.common.formInputs, "duration"),
    );

    // Handles instances of missing or invalid input parameters.
    const errors = [];

    if (!recipients) {
      errors.push("Missing or invalid recipient email address.");
    }
    if (!subject) {
      errors.push("Missing subject line.");
    }
    if (!body) {
      errors.push("Missing event description.");
    }
    if (!startTime) {
      errors.push("Missing or invalid start time.");
    }
    if (!duration || Number.isNaN(duration)) {
      errors.push("Missing or invalid duration");
    }
    if (errors.length) {
      // Redisplays the form if missing or invalid inputs exist.
      return getInputFormAsDialog_({
        errors,
        invitee: recipients,
        startTime: dateTimeInput,
        duration,
        subject,
        body,
      });
    }

    //  Calculates the end time via duration.
    const endTime = new Date(startTime.valueOf());
    endTime.setMinutes(endTime.getMinutes() + duration);

    // Creates calendar event with notification.
    const calendar = CalendarApp.getDefaultCalendar();
    const scheduledEvent = calendar.createEvent(subject, startTime, endTime, {
      guests: recipients,
      sendInvites: true,
      description: `${body}\nThis meeting scheduled by a Google Chat App!`,
    });

    // Gets a link to the Calendar event.
    const url = getCalendarEventURL_(scheduledEvent, calendar);

    return getConfirmationDialog_(url);
  }
  if (event.action.actionMethodName === "closeDialog") {
    // Returns this dialog as success.
    return {
      actionResponse: {
        type: "DIALOG",
        dialog_action: {
          actionStatus: "OK",
        },
      },
    };
  }
}

/**
 * Responds with help text about this Chat app.
 * @return {string} The help text as seen below
 */
function getHelpTextResponse_() {
  const help = `*${APPNAME}* lets you quickly create meetings from Google Chat. Here\'s a list of all its commands:
  \`/schedule_Meeting\`  Opens a dialog with editable, preset parameters to create a meeting event
  \`/help\`  Displays this help message

  Learn more about creating Google Chat apps at https://developers.google.com/chat.`;

  return { text: help };
}

Dialog.gs

apps-script/schedule-meetings/Dialog.js
/**
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Form input dialog as JSON.
 * @return {object} JSON-formatted cards for the dialog.
 */
function getInputFormAsDialog_(options) {
  const form = getForm_(options);
  return {
    actionResponse: {
      type: "DIALOG",
      dialogAction: {
        dialog: {
          body: form,
        },
      },
    },
  };
}

/**
 * Form JSON to collect inputs regarding the meeting.
 * @return {object} JSON-formatted cards.
 */
function getForm_(options) {
  const sections = [];

  // If errors present, display additional section with validation messages.
  if (options.errors?.length) {
    let errors = options.errors.reduce((str, err) => `${str}${err}<br>`, "");
    errors = `<b>Errors:</b><br><font color="#ba0000">${errors}</font>`;
    const errorSection = {
      widgets: [
        {
          textParagraph: {
            text: errors,
          },
        },
      ],
    };
    sections.push(errorSection);
  }
  const formSection = {
    header: "Schedule meeting and send email to invited participants",
    widgets: [
      {
        textInput: {
          label: "Event Title",
          type: "SINGLE_LINE",
          name: "subject",
          value: options.subject,
        },
      },
      {
        textInput: {
          label: "Invitee Email Address",
          type: "SINGLE_LINE",
          name: "email",
          value: options.invitee,
          hintText: "Add team group email",
        },
      },
      {
        textInput: {
          label: "Description",
          type: "MULTIPLE_LINE",
          name: "body",
          value: options.body,
        },
      },
      {
        textInput: {
          label: "Meeting start date & time",
          type: "SINGLE_LINE",
          name: "date",
          value: options.startTime,
          hintText: "mm/dd/yyyy H:MM",
        },
      },
      {
        selectionInput: {
          type: "DROPDOWN",
          label: "Meeting Duration",
          name: "duration",
          items: [
            {
              text: "15 minutes",
              value: "15",
              selected: options.duration === 15,
            },
            {
              text: "30 minutes",
              value: "30",
              selected: options.duration === 30,
            },
            {
              text: "45 minutes",
              value: "45",
              selected: options.duration === 45,
            },
            {
              text: "1 Hour",
              value: "60",
              selected: options.duration === 60,
            },
            {
              text: "1.5 Hours",
              value: "90",
              selected: options.duration === 90,
            },
            {
              text: "2 Hours",
              value: "120",
              selected: options.duration === 120,
            },
          ],
        },
      },
    ],
    collapsible: false,
  };
  sections.push(formSection);
  const card = {
    sections: sections,
    name: "Google Chat Scheduled Meeting",
    fixedFooter: {
      primaryButton: {
        text: "Submit",
        onClick: {
          action: {
            function: "handleFormSubmit",
          },
        },
        altText: "Submit",
      },
    },
  };
  return card;
}

/**
 * Confirmation dialog after a calendar event is created successfully.
 * @param {string} url The Google Calendar Event url for link button
 * @return {object} JSON-formatted cards for the dialog
 */
function getConfirmationDialog_(url) {
  return {
    actionResponse: {
      type: "DIALOG",
      dialogAction: {
        dialog: {
          body: {
            sections: [
              {
                widgets: [
                  {
                    textParagraph: {
                      text: "Meeting created successfully!",
                    },
                    horizontalAlignment: "CENTER",
                  },
                  {
                    buttonList: {
                      buttons: [
                        {
                          text: "Open Calendar Event",
                          onClick: {
                            openLink: {
                              url: url,
                            },
                          },
                        },
                      ],
                    },
                    horizontalAlignment: "CENTER",
                  },
                ],
              },
            ],
            fixedFooter: {
              primaryButton: {
                text: "OK",
                onClick: {
                  action: {
                    function: "closeDialog",
                  },
                },
              },
            },
          },
        },
      },
    },
  };
}

ইউটিলিটিস.জিএস

apps-script/schedule-meetings/Utilities.js
/**
 * Copyright 2022 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Helper function that gets the field value from the given form input.
 * @return {string}
 */
function getFieldValue_(formInputs, fieldName) {
  return formInputs[fieldName][""].stringInputs.value[0];
}

// Regular expression to validate the date/time input.
const DATE_TIME_PATTERN = /\d{1,2}\/\d{1,2}\/\d{4}\s+\d{1,2}:\d\d/;

/**
 * Casts date and time from string to Date object.
 * @return {date}
 */
function getStartTimeAsDateObject_(dateTimeStr) {
  if (!dateTimeStr || !dateTimeStr.match(DATE_TIME_PATTERN)) {
    return null;
  }

  const parts = dateTimeStr.split(" ");
  const [month, day, year] = parts[0].split("/").map(Number);
  const [hour, minute] = parts[1].split(":").map(Number);

  Session.getScriptTimeZone();

  return new Date(year, month - 1, day, hour, minute);
}

/**
 * Gets the current date and time for the upcoming top of the hour (e.g. 01/25/2022 18:00).
 * @return {string} date/time in mm/dd/yyy HH:MM format needed for use by Calendar
 */
function getTopOfHourDateString_() {
  const date = new Date();
  date.setHours(date.getHours() + 1);
  date.setMinutes(0, 0, 0);
  // Adding the date as string might lead to an incorrect response due to time zone adjustments.
  return Utilities.formatDate(
    date,
    Session.getScriptTimeZone(),
    "MM/dd/yyyy H:mm",
  );
}

/**
 * Creates the URL for the Google Calendar event.
 *
 * @param {object} event The Google Calendar Event instance
 * @param {object} cal The associated Google Calendar
 * @return {string} URL in the form of 'https://www.google.com/calendar/event?eid={event-id}'
 */
function getCalendarEventURL_(event, cal) {
  const baseCalUrl = "https://www.google.com/calendar";
  // Joins Calendar Event Id with Calendar Id, then base64 encode to derive the event URL.
  let encodedId = Utilities.base64Encode(
    `${event.getId().split("@")[0]} ${cal.getId()}`,
  ).replace(/\=/g, "");
  encodedId = `/event?eid=${encodedId}`;
  return baseCalUrl + encodedId;
}

পরবর্তী পদক্ষেপ