Google Calendar
Last updated
Last updated
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.
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.
You can find the id of the existing calendar in its settings in the “Integrate calendar” section:
You can create a new calendar one of two ways: manually and by using a function.
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:
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': '7e2q3mka5dmfmcohdltfupclj4@group.calendar.google.com', '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:
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': 'rcdd8mimc6gjtasan9ansn8354@group.calendar.google.com', 'summary': 'Calendar name', 'timeZone': 'UTC'}
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': '74u4aogu34hisgvi9v0pjriqho@group.calendar.google.com',
'summary': 'AAAAAAAAaa',
'timeZone': 'Asia/Singapore',
'colorId': '17',
'backgroundColor': '#9a9cff',
'foregroundColor': '#000000',
'selected': True,
'accessRole': 'owner',
'defaultReminders': [
]
},
{
'kind': 'calendar#calendarListEntry',
'etag': '"1625235805096000"',
'id': '5u9q24kdh571mnm667t2d3q16c@group.calendar.google.com',
'summary': 'AAAAAAAAaa',
'timeZone': 'Asia/Singapore',
'colorId': '21',
'backgroundColor': '#cca6ac',
'foregroundColor': '#000000',
'selected': True,
'accessRole': 'owner',
'defaultReminders': [
]
}
]
}
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": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com", "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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'},
'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com',
'displayName': 'Testov',
'self': True},
'start': {'dateTime': '2021-07-22T07:43:53Z', 'timeZone': 'UTC'},
'end': {'dateTime': '2021-07-22T08:43:53Z', 'timeZone': 'UTC'},
'iCalUID': 'ljp7a3ocp8oorbov9u2cq221s0@google.com',
'sequence': 0,
'reminders': {'useDefault': True},
'eventType': 'default'
}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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:
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)
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": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com", "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"}
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
{'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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'}, 'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com', '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': 'ittr5291ppi7snapn8jbct5krs@google.com', 'sequence': 0, 'attendees': [{'email': john@gmail.com', 'displayName': John, 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default'}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com", "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"}
After the successful execution the function returns these next parameters you can save and store.
{"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":"gsheets@gsheets-254713.iam.gserviceaccount.com"},"organizer":{"email":"i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com","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":"j1lcpm4q2p9c0cv705alv3brug@google.com","sequence":0,"reminders":{"useDefault":false,"overrides":[{"method":"email","minutes":22},{"method":"popup","minutes":12}]},"eventType":"default","update_status":"ok"}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com", "command": "get_event_list", "start_date": "22.07.2021", "end_date": "23.07.2021"}
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
{'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': 'adnimdd@gmail.com'}, 'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com', 'displayName': 'Testov', 'self': True}, 'start': {'date': '2021-07-20'}, 'end': {'date': '2021-07-21'}, 'transparency': 'transparent', 'iCalUID': '6d8rocb9e2r21ue37jgsa0v06i@google.com', 'sequence': 0, 'reminders': {'useDefault': False}, 'eventType': 'default'}]}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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;
After the successful execution the function returns these next parameters you can save and store.
{'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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'}, 'organizer': {'email': '88q8fvkrv5ue7orsh109t6o60s@group.calendar.google.com', 'displayName': 'Тестовый календарь'}, 'start': {'dateTime': '2021-07-22T07:43:53Z', 'timeZone': 'UTC'}, 'end': {'dateTime': '2021-07-22T08:43:53Z', 'timeZone': 'UTC'}, 'iCalUID': 'ljp7a3ocp8oorbov9u2cq221s0@google.com', 'sequence': 0, 'reminders': {'useDefault': True}, 'eventType': 'default'}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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
After the successful execution the function returns these next parameters you can save and store.
{'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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'}, 'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com', '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': 'ittr5291ppi7snapn8jbct5krs@google.com', 'sequence': 0, 'attendees': [{'email': 'adnimdd@gmail.com', 'displayName': 'John', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default'}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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
After the successful execution the function returns these next parameters you can save and store.
{'status': 'ok'}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com",
"command": "add_client",
"event_id": "#{event_id}",
"client_email": "asdc@mail.com",
"name": "John",
"comment": "I’ll be the first!"
}
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
{'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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'}, 'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com', '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': 'ittr5291ppi7snapn8jbct5krs@google.com', 'sequence': 0, 'attendees': [{'email': 'adnimdd@gmail.com', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': 'adnimd@gmail.com', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': 'adnidgmd@gmail.com', 'displayName': 'John2', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default', ‘add_status’: 'ok'}
Function URL: https://store.salebot.ai/function/gcalendar Request type: POST-json
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
{
"creds_path": "https://files.salebot.ai/uploads/message/file/30037/calendar-project-320517-c241d9ab0565.json",
"calendar_id": "i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com",
"command": "remove_client",
"event_id": "#{event_id}",
"client_email": "asdc@mail.com"
}
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
{'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': 'gsheets@gsheets-254713.iam.gserviceaccount.com'}, 'organizer': {'email': 'i9svertstvoo2fq1o0i8cn39a8@group.calendar.google.com', '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': 'ittr5291ppi7snapn8jbct5krs@google.com', 'sequence': 0, 'attendees': [{'email': 'adnimdd@gmail.com', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': 'adnimd@gmail.com', 'displayName': 'John', 'responseStatus': 'needsAction'}, {'email': 'adnidgmd@gmail.com', 'displayName': 'John2', 'responseStatus': 'needsAction'}], 'reminders': {'useDefault': False, 'overrides': [{'method': 'email', 'minutes': 10}, {'method': 'popup', 'minutes': 10}]}, 'eventType': 'default', 'remove_status': '1'}