The right way to Create Zoom Conferences with Google Script

Shubham
4 Min Read

This information describes how one can programmatically create person conferences in your Zoom account with the assistance of Google Apps Script and the official Zoom API.

As a primary step, go to the Zoom Developer Dashboard and create a new app. Select JWT because the app sort and make a remark of the Zoom API key and secret. We will construct Zoom apps with the OAuth2 library as properly however since this app is just for inside use and won’t be publish to the Zoom market, the JWT strategy is simpler.

The app would contain two step. We’ll hook up with the /api.zoom.us/v2/customers/ API to get the Zoom ID of present authenticated person. Subsequent, we make a POST request to the /v2/customers/<>/conferences endpoint to create the precise Zoom assembly.

Generate the Zoom Entry Token

const ZOOM_API_KEY = '>';
const ZOOM_API_SECRET = '';
const ZOOM_EMAIL = '';

const getZoomAccessToken = () => {
  const encode = (textual content) => Utilities.base64Encode(textual content).exchange(/=+$/, '');
  const header = { alg: 'HS256', typ: 'JWT' };
  const encodedHeader = encode(JSON.stringify(header));
  const payload = {
    iss: ZOOM_API_KEY,
    exp: Date.now() + 3600
  };
  const encodedPayload = encode(JSON.stringify(payload));
  const toSign = `${encodedHeader}.${encodedPayload}`;
  const signature = encode(Utilities.computeHmacSha256Signature(toSign, ZOOM_API_SECRET));
  return `${toSign}.${signature}`;
};

Get the Inside Consumer Id of the present person

const getZoomUserId = () => {
  const request = UrlFetchApp.fetch('https://api.zoom.us/v2/customers/', {
    technique: 'GET',
    contentType: 'utility/json',
    headers: { Authorization: `Bearer ${getZoomAccessToken()}` }
  });
  const { customers } = JSON.parse(request.getContentText());
  const [{ id } = {}] = customers.filter(({ e mail }) => e mail === ZOOM_EMAIL);
  return id;
};

Schedule a Zoom Assembly

You possibly can create an Prompt assembly or schedule a gathering with a set period. The assembly begin time is laid out in yyyy-MM-ddThh:mm:ss format with the desired timezone.

The whole record of assembly choices is out there here whereas the timezones can be found here.

const createZoomMeeting = () => {
  const meetingOptions = {
    subject: 'Zoom Assembly created with Google Script',
    sort: 1,
    start_time: '2020-07-30T10:45:00',
    period: 30,
    timezone: 'America/New_York',
    password: 'labnol',
    agenda: 'Focus on the product launch',
    settings: {
      auto_recording: 'none',
      mute_upon_entry: true
    }
  };

  const request = UrlFetchApp.fetch(`https://api.zoom.us/v2/customers/${getZoomUserId()}/conferences`, {
    technique: 'POST',
    contentType: 'utility/json',
    headers: { Authorization: `Bearer ${getZoomAccessToken()}` },
    payload: JSON.stringify(meetingOptions)
  });
  const { join_url, id } = JSON.parse(request.getContentText());
  Logger.log(`Zoom assembly ${id} created`, join_url);
};

The app might be enhanced to routinely add new contributors to a gathering after they register their e mail handle on, say, Google Kinds. In that case, a POST request is made to /conferences/{meetingId}/registrants with the e-mail handle and first title of the participant within the request physique.

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *