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:
- https://www.googleapis.com/auth/calendar
- https://www.googleapis.com/auth/admin.directory.user.readonly
- https://www.googleapis.com/auth/admin.directory.resource.calendar.readonly
- https://www.googleapis.com/auth/admin.directory.customer.readonly
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 = App(
"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 = App(
"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 = App(
"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
Usage
Create an event
An event needs an array of invited users, a start date, a duration (in minute) and the email of the user making the request
When creating the event, you can also add optionals parameters like a summary, the description, a room information (name or email) or a boolean "meet" to also add a google meet link.
do event = App(
"google/calendar",
method = "createEvent",
params = {
"currentUserEmail": "joe@company.com",
"invitedUsers": [ "jane@company.com", "tata@tutu.com" ],
"eventStartTime": "2020-09-30T14:30:00",
"eventDuration": 30,
"timeZone": "Europe/Paris",
"room": "Room1",
"meet": true,
"summary": "My calendar event",
"description": "Event created via CSML",
}
)
Search for free time slots between users
do timeSlots = App(
"google/calendar",
method="findFreeTimeSlots",
params = {
"room": "Room1",
"currentUserEmail": "joe@company.com",
"invitedUsers": [
"jane@company.com",
"tata@tutu.com"
],
"eventDuration": 30,
"createMeeting": false,
"timeSlot": { "start": "2020-10-12T09:00:00", "end": "2020-10-12T12:00:00"},
"timeZone": "Europe/Paris"
}
)
Retrieve a Google resource object with a room name
This method will return one room if there is an exact match with the name
else it will return a number of rooms (defined by the limit argument) containing the name in their name.
do room = App(
"google/calendar",
method = "findRoomByName",
params = {
"name": "Room1",
"currentUserEmail": "joe@company.com",
"limit": 5
}
)