How to Insert Event in Google Calendar

How to Insert Event in G Calendar ?

It is quite complicated according to their docs
Do you have any blocks code?
Has Anyone Every tried this?
@darren @jared @jane @cttricks ?
Any Ideas
@thunkableexperts?
@AnyoneWhocouldhelp

And Please do not give WEB Api Docs.

Your Regards,
TchInd Technologies’
(Formerly Called Techindia Is Here)

I know you don’t want the API Documentation link but I’m posting this for other people who might read your question:

It’s going to require a POST call to the API. I’ve been trying to figure out how to do those from within Thunkable but haven’t succeeded. I can get them (not Google Calendar but other API POST calls) to work with the Postman application or a curl command in Terminal on a Mac.

2 Likes

You can use Google Apps Script to created a webhook to create event in G Calendar.
Get Server/Webhook Codes from Github.

Note : You can do more with G-Calendar by using this webhook (View Docs).

Blocks Screen Shot

Click here to view sample Calendar project made on x.thunkalbe
Ct tricks

2 Likes

Did you skip some steps in your post here? I’ve tried this and several different variations with no success.

Thanks

In Whose calendar do you want events inserted? Yours or your users?

It’s a lot easier to add it to yours than others calendars.

But, setup oauth and sky’s the limit.

https://x.thunkable.com/projectPage/61e4e200e0ca1b001138c8b3

Here’s one way of doing it ^^^^

This example only GETs cal events but does so as an authenticated user. Get this far and I can show you how to create events for any user who gives your app permission!

2 Likes

I have also never had success with google app script , @overshield . But here is another approach - How to set Reminder Notifications with Zapier in Thunkable X? - YouTube

I’m wanting users to be able to add or remove to my calendar only.

I suppose it might be an added benefit to allow users to update their calendar also, but that’s assuming they use google calendar.

But again primarily just needs to be my calendar to add appointments, if they cancel their appointments in app it should delete the event too.

Currently my users can cancel appointments so I just need to add the delete event it seems.

1 Like

There’s also share links that google provides. A link that when clicked allows users to add events to their calendar. Might work for you. Gonna try to dig that up today!

2 Likes

See this

1 Like

I saw this one, but it does allow the user to edit the calendar which could cause problems, is there a way to use this link and execute it or does it require that final step to confirm?

1 Like

Use Google Apps Script

Example

function addEvents() {
   return CalendarApp.getDefaultCalendar().createEventFromDescription('test event, today 9AM');
 }

If you add this to your script and call this function, it will add an event to your calendar.

1 Like

Ok I got this to work via my google script screen and it did in fact create the event in my calendar, the first time I ran it, it failed, then I clicked run again and it sent me to the auth page to allow it. It also said it hasn’t been verified by google but I proceeded anyway, once I did all of that it created the event.

How do I call this function from the app?
Here’s what I’ve got so far…

1 Like

To run it from Thunkable you need to first Deploy it to the Web. However, to pass any parameters to it you need to wrap it in doGet function.

This is typical with every GAS (Google Apps Script) function.

1 Like

I went ahead and deployed it and got the macro/s/***/exec URL

I’m not sure how to wrap that into a doGet function though

1 Like

See this tutorial. It is for saving Canvas image to GDrive but will give you insight of how to use doGet/doPost to pass parameters from Thunkable to GAS.

1 Like

Ok I have the following, works from inside the google web page, but I must have something wrong in the app. I’m getting a 401 status


Is this correct with the doPost in the object component?

1 Like

Your Thunkable blocks should only pass the text of the event.

image

Your function will then be something like this.

function doPost(event) {
   return CalendarApp.getDefaultCalendar().createEventFromDescription(event.parameters.eventDesc);
 }
1 Like

I thought you edit the date and time from that text box. But you are saying only the description?

1 Like

There are many functions in the calendar object. I’m using here the function createEventFromDescription so you need to pass description such as:
Thunkable advanced meeting 10AM. The function will parse the description and create a meeting event from it.

You could see the list of functions and choose the one that fits your need.

1 Like

I now have the following but I’m not getting a calendar event

function doPost(event) {
   return CalendarApp.getDefaultCalendar().createEventFromDescription(event.parameters.eventDesc);
 }

1 Like