Salebot.ai
Search…
Google Calendar

How to create a service account

For this, you need to create your own account in Google services.
Go to this link and create a new project:
Think of the name for the project:
Press “Create” and wait a bit while the project is created.
Reload the page and then press on the just created project. Check in the field on the left your access status - it has to say “Owner (1)”:
Now move on to the service account’s settings:
There you need to open the section “Service accounts” and press “ + Create Service Account”:
Enter the name and the email of the service account:
Then choose the Owner role:
Press “Done” and then “Manage keys” on the chosen project. Then press “Create new key”
Choose the JSON key type and press “Create”
After you create the key, it automatically gets saved to your computer
Then you need to download it to the hosting or to Salebot and share the link to it in the request parameters by sharing the obtained URL in the creds_path parameter.
Now you also need to add our API-integrations. To do this, go here:
Then you need to enable APIs and services and search for Google Calendar API in the opened window:
Press on the search result and then on “Enable”:
This step finishes up the creation of your service account.

How to download the key file

Move into the project on Salebot and download the obtained key file into a block, for example, like this:
Press “Save” and move to the free testing window:
Enter the phrase you set as a condition (in this case it’s “123”). You’ll get a link to the file with keys as a reply:
You cannot delete the block, otherwise the file gets deleted from the server and you’ll have to add it again.
Don’t forget to make the block of the Not state type, so it doesn’t bother you.
You can save this link in a variable or transfer it in the creds_path parameter as it is.

How to find the calendar id

You can find the id of the existing calendar in its settings in the “Integrate calendar” section:

How to create a new calendar

You can create a new calendar one of two ways: manually and by using a function.

Manual calendar creation:

So that you could add notes and edit an existing calendar (or manually created one), you should grant access to the service account. To do this, simply add the email of the service account in the needed calendar’s settings:

Calendar creation with the use of a function

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
Parameters:
creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - create name - calendar name description - calendar description
Additional parameters:
time_zone - the calendar’s time zone. IANA Time Zone id. By default it’s Europe/Moscow (GMT+3) location - a geographical location of the calendar as a text of the arbitrary form
You can also grant access to a different account, for example, your main one:
owner_email - email of the account that gets added as the calendar’s owner
By default, the calendar will be created in the service account. To be able to visually edit the calendar from your own account, transfer your email in the owner_email parameter.
Stored values from the JSON-reply
After the successful execution, the function returns these next parameters that you can save and store:
{'kind': 'calendar#calendar', 'etag': '"WgASl9FY_5zrEmCZvrt4Qlh6tGQ"', 'id': '[email protected]', 'summary': 'Calendar name’', 'timeZone': 'UTC'}
Let’s store the created calendar’s id: id -> calendar_id
For testing, you can display the variable #{custom_answer}.
If the email (owner_email) was transferred, then after the successful request, it’s required to move to your email inbox and confirm the calendar being added to your account:

How to get the information about the calendar

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
Parameters:
creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - get_calendar; calendar_id - the chosen calendar’s id
Stored values
After the successful execution, the function returns these next parameters that you can save and store.
An example of the function reply:
{'kind': 'calendar#calendar', 'etag': '"6KN4OTLeoqGGu7Nr5uNIQgCGYsU"', 'id': '[email protected]', 'summary': 'Calendar name', 'timeZone': 'UTC'}

How to get the list of the service account’s calendars

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
Parameters:
creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - calendars_list
Stored values
After the successful execution, the function returns these next parameters that you can save and store.
An example of the function reply:
{ 'kind': 'calendar#calendarList', 'etag': '"p32o8pm47rfqf20g"', 'nextSyncToken': 'CLCM2Ifb9PECEi5nc2hlZXRzQGdzaGVldHMtMjU0NzEzLmlhbS5nc2VydmljZWFjY291bnQuY29t', 'items': [ { 'kind': 'calendar#calendarListEntry', 'etag': '"1625235372775000"', 'id': '[email protected]', 'summary': 'AAAAAAAAaa', 'timeZone': 'Asia/Singapore', 'colorId': '17', 'backgroundColor': '#9a9cff', 'foregroundColor': '#000000', 'selected': True, 'accessRole': 'owner', 'defaultReminders': [ ] }, { 'kind': 'calendar#calendarListEntry', 'etag': '"1625235805096000"', 'id': '[email protected]', 'summary': 'AAAAAAAAaa', 'timeZone': 'Asia/Singapore', 'colorId': '21', 'backgroundColor': '#cca6ac', 'foregroundColor': '#000000', 'selected': True, 'accessRole': 'owner', 'defaultReminders': [ ] } ] }

How to work with events

Adding an event quickly

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
Parameters:
creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - quick_add_event; calendar_id - the chosen calendar’s id; event_name - the name of the event
An example of the parameters:
{"creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "command": "quick_add_event","event_name": "Incredible Event"}
Stored values
After the successful execution, the function returns these next parameters that you can save and store. To be able to edit the created event later on, it’s recommended to save its id: id -> event_id.
An example of the function reply:
{ 'kind': 'calendar#event', 'etag': '"3253879667088000"', 'id': 'ljp7a3ocp8oorbov9u2cq221s0', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=bGpwN2Ezb2NwOG9vcmJvdjl1MmNxMjIxczAgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-22T07:43:53.000Z', 'updated': '2021-07-22T07:43:53.544Z', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Testov', 'self': True}, 'start': {'dateTime': '2021-07-22T07:43:53Z', 'timeZone': 'UTC'}, 'end': {'dateTime': '2021-07-22T08:43:53Z', 'timeZone': 'UTC'}, 'iCalUID': '[email protected]', 'sequence': 0, 'reminders': {'useDefault': True}, 'eventType': 'default' }

How to add an event

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - add_event calendar_id - the chosen calendar’s id event_name - the name of the event
You also need to set one of two parameter options: date OR date and time.
If the event takes place during the whole day, then you need to specify dates:
  1. 1.
    start_date - the date the event starts in the DD.MM.YYYY format (e.g. 23.07.2010)
  2. 2.
    end_date - the date the event ends in the DD.MM.YYYY format (e.g. 24.07.2010)
If the event takes place during the set time, then you need to specify the date and the time:
  1. 1.
    start_datetime - the date and the time the event starts at in the DD.MM.YYYY HH:MM format (e.g. 23.07.2010 12:00)
  2. 2.
    end_datetime - the date and the time the event ends at in the DD.MM.YYYY HH:MM format (e.g. 23.07.2010 13:00)
  3. 3.
    time_zone - the event’s time zone. IANA Time Zone id. By default, it’s Europe/Moscow (GMT+3)
If the calendar’s and the event’s time zones are different, then the event with time will be added to the calendar’s time zone.
Example:
The calendar is in the time zone (tz) Europe/Kyiv +3, and the event is added with the time zone Europe/Berlin +2. The time of the event of 12pm (tz +2) will be added to the calendar as 1pm, because in Kyiv time 1pm is 12pm in the +2 time zone.
Additional parameters:
event_description - the description of the event location - the geographical location of the event as a freeform text email_minutes - the time in minutes before the event to send a notification to the participants’ emails popup_minutes - the time in minutes before the event to send a notification to the participants as a pop up
An example of the parameters:
{"creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "command": "add_event", "event_name": "The greatest event of all time", "start_datetime": "27.07.2021 12:00", "end_datetime": "27.07.2021 14:00"}

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters which you can save and store.
For future editing of the created event it’s recommended to save its id:
id -> event_id

An example of the function reply:

{'kind': 'calendar#event', 'etag': '"3254057128970000"', 'id': 'ittr5291ppi7snapn8jbct5krs', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aXR0cjUyOTFwcGk3c25hcG44amJjdDVrcnMgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-23T08:22:35.000Z', 'updated': '2021-07-23T08:22:53.109Z', 'summary': 'New Event44', 'description': 'Descri xbb xhjxkv', 'location': 'city London', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': ‘Test’, 'self': True}, 'start': {'dateTime': '2021-07-23T13:30:00Z', 'timeZone': 'Europe/Kyiv}, 'end': {'dateTime': '2021-07-23T14:00:00Z', 'timeZone': 'Europe/Kyiv}, 'iCalUID': '[email protected]', 'sequence': 0, 'attendees': [{'email': [email protected]', 'displayName': John, 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default'}

Editing the event

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Mandatory parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - update_event; calendar_id - the calendar’s id; event_id - the id of the event you need to edit
Optional parameters for an update:
You can transfer one, as well as several parameters.
event_name - the name of the event event_description - the description of the event email_minutes - the time in minutes before the event to send a notification to the participants’ emails popup_minutes - the time in minutes before the event to send a notification to the participants as a pop up
If the event takes place during the whole day, then you need to specify dates:
start_date - the date the event starts in the DD.MM.YYYY format (e.g. 23.07.2010) end_date - the date the event ends in the DD.MM.YYYY format (e.g. 24.07.2010)
If the event takes place during the set time, then you need to specify the date and the time:
start_datetime - the date and the time the event starts at in the DD.MM.YYYY HH:MM format (e.g. 23.07.2010 12:00) end_datetime - the date and the time the event ends at in the DD.MM.YYYY HH:MM format (e.g. 23.07.2010 13:00) time_zone - the event’s time zone. IANA Time Zone id. By default, it’s Europe/Moscow (GMT+3)
An example of the parameters:
{"creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "event_id": "j1lcpm4q2p9c0cv705alv3brug", "command": "update_event", "event_name": "Edited event", "start_datetime": "27.07.2021 12:00", "end_datetime": "27.07.2021 14:00","popup_minutes": "11","email_minutes": "22"}

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters you can save and store.

An example of the function reply:

{"kind":"calendar#event","etag":""3276713558524000"","id":"j1lcpm4q2p9c0cv705alv3brug","status":"confirmed","htmlLink":"https://www.google.com/calendar/event?eid=ajFsY3BtNHEycDljMGN2NzA1YWx2M2JydWcgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw","created":"2021-12-01T10:40:11.000Z","updated":"2021-12-01T10:43:16.738Z","summary":"Amazing","creator":{"email":"[email protected]"},"organizer":{"email":"[email protected]","displayName":"Test","self":true},"start":{"dateTime":"2021-12-28T09:00:00Z","timeZone":"Europe/Moscow"},"end":{"dateTime":"2021-12-29T11:00:00Z","timeZone":"Europe/Moscow"},"iCalUID":"[email protected]","sequence":0,"reminders":{"useDefault":false,"overrides":[{"method":"email","minutes":22},{"method":"popup","minutes":12}]},"eventType":"default","update_status":"ok"}

Getting a list of events

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - get_event_list; calendar_id - the calendar’s id
If you don’t transfer additional parameters, then the result will be a list of today’s events
Additional parameters:
start_date - the date from which you want to find events for in the DD.MM.YYYY format (23.07.2021) end_date - the date until which you want to find events in the DD.MM.YYYY format (24.07.2021)
An example of the parameters:
The event for the 23rd of july will be found
{"creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "command": "get_event_list", "start_date": "22.07.2021", "end_date": "23.07.2021"}

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters you can save and store.
The list of found events can be saved in a variable:
items -> event_list

An example of the function reply:

{'kind': 'calendar#events', 'etag': '"p33odnesrinsv20g"', 'summary': 'Test', 'description': 'Test description', 'updated': '2021-07-23T12:13:05.686Z', 'timeZone': 'UTC', 'accessRole': 'owner', 'defaultReminders': [], 'items': [{'kind': 'calendar#event', 'etag': '"3254084771372000"', 'id': '6d8rocb9e2r21ue37jgsa0v06i', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=NmQ4cm9jYjllMnIyMXVlMzdqZ3NhMHYwNmkgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-23T12:11:13.000Z', 'updated': '2021-07-23T12:13:05.686Z', 'summary': 'DDDDDDDDD', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Testov', 'self': True}, 'start': {'date': '2021-07-20'}, 'end': {'date': '2021-07-21'}, 'transparency': 'transparent', 'iCalUID': '[email protected]', 'sequence': 0, 'reminders': {'useDefault': False}, 'eventType': 'default'}]}

How to move events to a different calendar

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - move_event; calendar_id - the id of the calendar from which the event is moved; event_id - the id of the event; destination_calendar_id - the id of the calendar to which the event is moved;

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters you can save and store.

An example of the function reply:

{'kind': 'calendar#event', 'etag': '"3253880350568000"', 'id': 'ljp7a3ocp8oorbov9u2cq221s0', 'status': 'cancelled', 'htmlLink': 'https://www.google.com/calendar/event?eid=bGpwN2Ezb2NwOG9vcmJvdjl1MmNxMjIxczAgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-22T07:43:53.000Z', 'updated': '2021-07-22T07:49:35.284Z', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Тестовый календарь'}, 'start': {'dateTime': '2021-07-22T07:43:53Z', 'timeZone': 'UTC'}, 'end': {'dateTime': '2021-07-22T08:43:53Z', 'timeZone': 'UTC'}, 'iCalUID': '[email protected]', 'sequence': 0, 'reminders': {'useDefault': True}, 'eventType': 'default'}

How to get information on the event

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - get_event; calendar_id - the id of the calendar; event_id - the id of the event

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters you can save and store.

An example of the function reply:

{'kind': 'calendar#event', 'etag': '"3254067331414000"', 'id': 'ittr5291ppi7snapn8jbct5krs', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aXR0cjUyOTFwcGk3c25hcG44amJjdDVrcnMgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-23T08:22:35.000Z', 'updated': '2021-07-23T11:12:55.553Z', 'summary': 'New Event44', 'description': 'Descri xbb xhjxkv', 'location': 'city London', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Test', 'self': True}, 'start': {'dateTime': '2021-07-23T13:30:00Z', 'timeZone': 'Europe/Moscow'}, 'end': {'dateTime': '2021-07-23T14:00:00Z', 'timeZone': 'Europe/Moscow'}, 'iCalUID': '[email protected]', 'sequence': 0, 'attendees': [{'email': '[email protected]', 'displayName': 'John', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default'}

How to delete an event

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - remove_event; calendar_id - the id of the calendar; event_id - the id of the event you want to delete

Stored values from the JSON-reply:

After the successful execution the function returns these next parameters you can save and store.

An example of the function reply:

{'status': 'ok'}

How to add an event participant

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - add_client; calendar_id - the id of the calendar; event_id - the id of the event; client_email - the email of the client you want to add
Additional parameters:
name - the name of the event; comment - comment of the participant
An example of the parameters:
{ "creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "command": "add_client", "event_id": "#{event_id}", "client_email": "[email protected]", "name": "John", "comment": "I’ll be the first!" }

Stored values from JSON-reply:

The function always returns the status add_status. It can hold on of three values:
ok - the client was added exist - the client already exists error - there was an error during the adding process, then additionally with add_status there will be a parameter error_message with the error text

An example of the function reply incase of success:

{'kind': 'calendar#event', 'etag': '"3254059247409000"', 'id': 'ittr5291ppi7snapn8jbct5krs', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aXR0cjUyOTFwcGk3c25hcG44amJjdDVrcnMgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-23T08:22:35.000Z', 'updated': '2021-07-23T08:58:11.548Z', 'summary': 'New Event44', 'description': 'Descri xbb xhjxkv', 'location': 'city London', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Test', 'self': True}, 'start': {'dateTime': '2021-07-23T13:30:00Z', 'timeZone': 'Europe/Moscow'}, 'end': {'dateTime': '2021-07-23T14:00:00Z', 'timeZone': 'Europe/Moscow'}, 'iCalUID': '[email protected]', 'sequence': 0, 'attendees': [{'email': '[email protected]', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': '[email protected]', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': '[email protected]', 'displayName': 'John2', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default', ‘add_status’: 'ok'}

How to delete a participant

Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json

Parameters:

creds_path - the link to the access key of the service account to the calendar’s API (obtained using the instruction above); command - remove_client; calendar_id - the id of the calendar; event_id - the id of the event; client_email - the email of the client

An example of the parameters:

{ "creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json", "calendar_id": "[email protected]", "command": "remove_client", "event_id": "#{event_id}", "client_email": "[email protected]" }

Stored values from JSON-reply:

The function always returns the status remove_status. It can hold one of three values:
1 - the client was successfully removed 0 - the client wasn’t found error - an error during the removal process, then additionally with remove_status there will be a parameter error_message with the error text

The function answer in case of success:

{'kind': 'calendar#event', 'etag': '"3254059247409000"', 'id': 'ittr5291ppi7snapn8jbct5krs', 'status': 'confirmed', 'htmlLink': 'https://www.google.com/calendar/event?eid=aXR0cjUyOTFwcGk3c25hcG44amJjdDVrcnMgaTlzdmVydHN0dm9vMmZxMW8waThjbjM5YThAZw', 'created': '2021-07-23T08:22:35.000Z', 'updated': '2021-07-23T08:58:11.548Z', 'summary': 'New Event44', 'description': 'Descri xbb xhjxkv', 'location': 'city London', 'creator': {'email': '[email protected]'}, 'organizer': {'email': '[email protected]', 'displayName': 'Test', 'self': True}, 'start': {'dateTime': '2021-07-23T13:30:00Z', 'timeZone': 'Europe/Moscow'}, 'end': {'dateTime': '2021-07-23T14:00:00Z', 'timeZone': 'Europe/Moscow'}, 'iCalUID': '[email protected]', 'sequence': 0, 'attendees': [{'email': '[email protected]', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': '[email protected]', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': '[email protected]', 'displayName': 'John2', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default', 'remove_status': '1'}
Copy link
On this page
How to create a service account
How to download the key file
How to find the calendar id
How to create a new calendar
Manual calendar creation:
Calendar creation with the use of a function
How to get the information about the calendar
How to get the list of the service account’s calendars
How to work with events
Adding an event quickly
How to add an event
Editing the event
Getting a list of events
How to move events to a different calendar
How to get information on the event
How to delete an event
How to add an event participant
How to delete a participant