Sample Scripts for Creating New Event with Google Meet Link to Google Calendar using Various Languages

Gists

This is the sample scripts for creating new event with Google Meet link to Google Calendar using various languages. When I saw the official document of “Add video and phone conferences to events”, in the current stage, I can see only the sample script for Javascript. But I saw the several questions related to this for various languages. So I published the sample scripts for creating new event with Google Meet link to Google Calendar using various languages.

In order to create new event with Google Meet link to Google Calendar, it is required to set the request body and query parameter as follows.

Please add the following object to the request body.

conferenceData: {
  createRequest: {
    requestId: "sample123",
    conferenceSolutionKey: { type: "hangoutsMeet" },
  },
}

And also, please add conferenceDataVersion=1 to the query parameter.

The following scripts creates the same event including Google Meet link.

  1. Javascript
  2. Go
  3. Google Apps Script
  4. Node.js
  5. PHP
  6. Python
  7. Ruby
  8. Curl

Javascript

About auth, please check the Quickstart for Javascript. Ref In this case, Please be careful the scope.

const calendarId = "###";
const event = {
  start: { dateTime: "2021-01-01T00:00:00.000+09:00" },
  end: { dateTime: "2021-01-01T00:30:00.000+09:00" },
  attendees: [{ email: "###" }],
  conferenceData: {
    createRequest: {
      requestId: "sample123",
      conferenceSolutionKey: { type: "hangoutsMeet" },
    },
  },
  summary: "sample event with Meet link",
  description: "sample description",
};
gapi.client.calendar.events
  .insert({
    calendarId: calendarId,
    conferenceDataVersion: 1,
    resource: event,
  })
  .then((res) => console.log(res.result));

Go

About auth, please check the Quickstart for Go. Ref In this case, Please be careful the scope.

srv, err := calendar.New(client)
if err != nil {
  log.Fatalln(err)
}
calendarID := "###"
event := &calendar.Event{
  Start: &calendar.EventDateTime{
    DateTime: "2021-01-01T00:00:00.000+09:00",
  },
  End: &calendar.EventDateTime{
    DateTime: "2021-01-01T00:30:00.000+09:00",
  },
  Attendees: []*calendar.EventAttendee{&calendar.EventAttendee{Email: "###"}},
  ConferenceData: &calendar.ConferenceData{
    CreateRequest: &calendar.CreateConferenceRequest{
      RequestId: "sample123",
      ConferenceSolutionKey: &calendar.ConferenceSolutionKey{
        Type: "hangoutsMeet",
      },
    },
  },
  Summary:  "sample event with Meet link",
  Description: "sample description",
}
res, err := srv.Events.Insert(calendarID, event).ConferenceDataVersion(1).Do()
if err != nil {
  log.Fatalln(err)
}
fmt.Println(res)

Google Apps Script

Before you use this script, please enable Calendar API at Advanced Google services. Ref

function createNewEventWithMeet() {
  const calendarId = "###";
  const resource = {
    start: { dateTime: "2021-01-01T00:00:00.000+09:00" },
    end: { dateTime: "2021-01-01T00:30:00.000+09:00" },
    attendees: [{ email: "###" }],
    conferenceData: {
      createRequest: {
        requestId: "sample123",
        conferenceSolutionKey: { type: "hangoutsMeet" },
      },
    },
    summary: "sample event with Meet link",
    description: "sample description",
  };
  const res = Calendar.Events.insert(resource, calendarId, {
    conferenceDataVersion: 1,
  });
  console.log(res);
}

Node.js

About auth, please check the Quickstart for Node.js. Ref In this case, Please be careful the scope.

const calendar = google.calendar({ version: "v3", auth });
const calendarId = "###";
const resource = {
  start: { dateTime: "2020-12-01T00:00:00.000+09:00" },
  end: { dateTime: "2020-12-01T00:30:00.000+09:00" },
  attendees: [{ email: "###" }],
  conferenceData: {
    createRequest: {
      requestId: "sample123",
      conferenceSolutionKey: { type: "hangoutsMeet" },
    },
  },
  summary: "sample event with Meet link",
  description: "sample description",
};
calendar.events
  .insert({
    calendarId: calendarId,
    resource: resource,
    conferenceDataVersion: 1,
  })
  .then(({ data }) => console.log(data))
  .catch(({ errors }) => console.log(errors));

PHP

About auth, please check the Quickstart for PHP. Ref In this case, Please be careful the scope.

$service = new Google_Service_Calendar($client);
$calendarId = "###";
$event = new Google_Service_Calendar_Event([
    'start' => ['dateTime' => '2021-01-01T00:00:00.000+09:00'],
    'end' => ['dateTime' => '2021-01-01T00:30:00.000+09:00'],
    'attendees' => array(['email' => '###']),
    'conferenceData' => [
        'createRequest' => [
            'requestId' => 'sample123',
            'conferenceSolutionKey' => ['type' => 'hangoutsMeet']
        ]
    ],
    'summary' => 'sample event with Meet link',
    'description' => 'sample description'
]);
$res = $service->events->insert($calendarId, $event, array('conferenceDataVersion' => 1));
print($res);

Python

About auth, please check the Quickstart for Python. Ref In this case, Please be careful the scope.

service = build("calendar", "v3", credentials=creds)
calendarId = "###"
event = {
    "start": {"dateTime": "2021-01-01T00:00:00.000+09:00"},
    "end": {"dateTime": "2021-01-01T00:30:00.000+09:00"},
    "attendees": [{"email": "###"}],
    "conferenceData": {"createRequest": {"requestId": "sample123", "conferenceSolutionKey": {"type": "hangoutsMeet"}}},
    "summary": "sample event with Meet link",
    "description": "sample description"
}
res = service.events().insert(calendarId=calendarId, sendNotifications=True, body=event, conferenceDataVersion=1).execute()
print(res)

Ruby

About auth, please check the Quickstart for Ruby. Ref In this case, Please be careful the scope.

service = Google::Apis::CalendarV3::CalendarService.new
service.authorization = authorize
calendar_id = "###"
event = Google::Apis::CalendarV3::Event.new(
  start: Google::Apis::CalendarV3::EventDateTime.new(date_time: "2021-01-01T00:00:00.000+09:00"),
  end: Google::Apis::CalendarV3::EventDateTime.new(date_time: "2021-01-01T00:30:00.000+09:00"),
  attendees: [email: "###"],
  conference_data: Google::Apis::CalendarV3::ConferenceData.new(
    create_request: Google::Apis::CalendarV3::CreateConferenceRequest.new(
      request_id: "sample123",
      conference_solution_key: Google::Apis::CalendarV3::ConferenceSolutionKey.new(
        type: "hangoutsMeet"
      )
    )
  ),
  summary: "sample event from ruby",
  description: "sample event from ruby"
)
res = service.insert_event(calendar_id, event, conference_data_version: 1)
puts res

Curl

$ curl -X POST \
  -H 'Authorization: Bearer ### accessToken ###' \
  -H 'Content-Type: application/json' \
  -d '{"start":{"dateTime":"2021-01-01T00:00:00.000+09:00"},"end":{"dateTime":"2021-01-01T00:30:00.000+09:00"},"attendees":[{"email":"### email ###"}],"conferenceData":{"createRequest":{"requestId":"sample123","conferenceSolutionKey":{"type":"hangoutsMeet"}}},"summary":"sample event with Meet","description":"sample description"}' \
  'https://www.googleapis.com/calendar/v3/calendars/### calendarId ###/events?conferenceDataVersion=1'

References

  • Events

    • conferenceData.createRequest.requestId: The client-generated unique ID for this request. Clients should regenerate this ID for every new request. If an ID provided is the same as for the previous request, the request is ignored.

  • Events: insert

 Share!