Home / All Integrations / Google Calendar for Google Workspace

Connect Google Calendar for Google Workspace to your chatbot

Manage Google Calendar events


This app, compatible with Google Calendar for Google Workspace, lets you:

  • Create and invite participants to Google Calendar events
  • Search for free time slots between participants
  • Find your organization's rooms by name

Setup

In order to use this app, you need to create a Service Account from your Google Cloud account and setup your Google Workspace account.

To do so, go to https://console.cloud.google.com/, create a project, enable the Google Calendar API then create a Service Account with Project Editor access role, and retrieve a key in JSON format. This file contains your service account's client_id, client_email and private_key, which you will need to configure this app.

You will also need to configure your Google Workspace (formerly GSuite) account to enable domain-wide delegation to this service account. You can do so by following these instructions.

The scopes you need to allow on your domain-wide delegation for this client ID are:

Methods

createEvent

Create a Google Calendar event and invite all participants.

This method does not check for the participants' availability. To check for availability, use the below method: findFreeTimeSlots.

do meeting = Fn(
  "google/calendar",
  method = "createEvent"
  params = {
    "currentUserEmail": "joe@company.com",                      // Email of the user making the request.
    "invitedUsers": [ "joe@company.com", "jane@company.com" ],  // An array of email to invite.
    "eventStartTime": "2020-09-30T14:30:00",                    // ISO date, YYYY-MM-DDThh-mm-ss.
    "eventDuration": 30,                                        // Optional. Event duration in minutes. Default is 60min.
    "timeZone": "Europe/Paris",                                 // Optional. Timezone of the event. Default is Etc/UTC.
    "room": "Room1",                                            // Optional. Name or email of the room you want to do your meeting in.
    "meet": true,                                               // Optional. If true, will also create a google meet /event and add the link to the calendar event. Default false.
    "summary": "My calendar event",                             // Optional. The title of the event.
    "description": "Event created via CSML",                    // Optional. The description of the event.
  }
)

Response:

{
  "success": true,
  "response": {
    "status": 200,
    "id": "k4fasp3dasjd02dlsa92",
    "htmlLink": "https://www.google.com/calendar/event?eid=dasihdiosahdosahodhsaiodhoaishdosahdoi123dha",
    "message": "Agenda event successfully created",
    "start": "2020-09-30T14:30:00+02:00"
  }
}

findRoomByName

Use this method to find a room matching the name you sent via parameters.

If we don't find an exact match, we will return rooms containing the name you sent.

To call this function via csml here is what parameters should look like:

do room = Fn(
  "google/calendar",
  method = "findRoomByName"
  params = {
    "name": "LoRoom ipsum",               // The name of the room you want to search for.
    "currentUserEmail": "joe@company.com" // The email of the user making the request.
    "limit": 10,                          // Optional. The number of rooms to return in case there is no exact match. Default is 10
  }
)

Response if a resource was found with the same name:

{
  "success": true,
  "response": {
    "exactMatch": true,
    "results": [
      {
        "kind": "admin#directory#resources#calendars#CalendarResource",
        "etags": "asiwqdo_dsahjdoisahdiowqhdoqhDWQdho/UDsbuodqw_Hdsaodhoqw",
        "resourceId": "198309874891",
        "resourceName": "Room1",
        "generatedResourceName": "Building name-1-Room1 (25)",
        "resourceEmail": "company.com_273982691264912649@resource.calendar.google.com",
        "capacity": 25,
        "buildingId": "Building name",
        "floorName": "1",
        "resourceCategory": "CONFERENCE_ROOM"
      }
    ]
  }
}

Response with the closest matches by resource name:

{
  "success": true,
  "response": {
    "exactMatch": false,
    "results": [
      {
        "resourceName": "Room1",
        ...
      },
      {
        "resourceName": "Room2",
        ...
      }
    ]
  }
}

findFreeTimeSlots

Find time slots where all users passed in the method will be free.

An optional parameter, createMeeting, enables you to automatically create the event at the first free slot instead of returning time slots.
To call this function via csml here is what parameters should look like:

do slots = Fn(
  "google/calendar",
  method = "findFreeTimeSlots"
  params = {
    room: "Room1",                                                // Optional. Name or email of the room you want to do your meeting in.
    currentUserEmail: "joe@company.com",                          // Email of the user making the request.
    invitedUsers: [ "jane@company.com", "lawrence@company.com" ], // An array of email to invite.
    eventDuration: 30,                                            // Optional. Default is 60min. Event duration in minutes.
    createMeeting: false                                          // Optional. Default is true. Create a calendar event once the time slot has been found.
    timeSlot: {                                                   // The time slot to look for.
      start: "2020-10-12T09:00:00",                               // timeSlot can also be a string: i.e timeSlots: "2020-10-12T09:00:00". In this case, we will look  for the entire day.
      end: "2020-10-12T12:00:00",                                 // timeSlot is optional, if no timeSlot is given, we will look for free slots in the entire following month.
    },
    timeZone: "Europe/Paris",                                     // Optional. Default is Etc/UTC. Timezone of the event.

    // Optional parameters, only used if `createMeeting` = true.
    meet: true,                                         // Optional. Default false. If true, will also create a google meet /event and add the link to the calendar event.
    summary: "My calendar event",                       // Optional. The title of the event.
    description: "Event created via CSML",              // Optional. The description of the event.
  }
)

Response:

{
  "success": true,
  "response": {
    "message": "We successfully found free agenda slots matching your query.",
    "data" : [
      { "start": "2020-10-12T09:40:00.000+02:00" },
      { "start": "2020-10-12T10:55:00.000+02:00" }
    ]
  }
}

If createMeeting is set to true, a meeting will be created and the response will be as shown in createEvent

Many more integrations are coming!

If you have a cool integration in mind, drop us an email on contact@csml.dev and tell us all about it!

Many of our 45 currently available integrations come directly from your suggestions!

Join the Community
on Slack Slack

Come and learn all about CSML with other chatbot enthusiasts on the Slack CSML Community! ūü§ó