Google calendar API & inserting event

Hi!

I’m fairly new to coding and corvid and javascript but I’m trying to use to Google Calendar API to insert an event from my site to my calendar. I’m trying to read all the info I want to insert in the event from a container on a dynamic page which shows data from a dataset. I’ve tried to google a solution for this problem and went through the google provided documentation, but I’m not getting any results.

Problem: I need to use OAuth 2.0 to be able to connect to my calendar, but can’t make it work with javascript.

Does anyone here have the same problem and/or solution for it?

Thanks,
Hannu

Hannu, how brave of you. Are you using Google´s API directly? Are you aware that there are 2 other possibilities: the google calendar (light) NPM and using Zapier (which is the one I used). For that, you need to create a free Zapier account, define a Zapier Webhook as a trigger and use the URL-endpoint they give you to send data to it using wix-fetch (post) from the backend.

Well I’m feeling less and less brave all the time. I think I should use the Zapier also, what Zap exactly are you using for this? All I could find was the Wix Answers to calendar events and the google sheets to calendar zaps, but I’m not sure which one to use yet.

Thanks for replying Giri!

Hannu, I did a write-up about it on my blog, since I think more people might be interested.

Look here: https://girizano.wixsite.com/codecorner/post/writing-events-to-google-calendar-with-zapier

Let me know if you run into trouble.

#google #calendar #zapier #zap

Ooooh! Thank you Giri, this one seems to be working. Except that the sample data does not get through to Zapier, altough it sends an email from wix to my gmail. Gonna retest this and eventually succeed anyhow.

You can see how to use the Google API with the following example:

Save Data to a Google Sheet Using NPM

Use the Google APIs Node.js Client package included in the Wix Package Manager to access a Google Sheet .

The example is for a Google sheet, but you can apply the principles to other Google APIs.

Hi Giri! I got it working allright, but I was wondering if it is possible to make it work with a custom form that gets its data from a database/collection? Currently not able to make it work :smiley:

Hannu, good to hear it worked for you. First version write-ups usually lack in some places, but I am glad you got it working.
About your question: do you mean that you simply want to save the event data first and then write it also to gCalendar, or (because you wrote “gets its data …”) as a delayed action, like a scheduled (cron) job?

What I mean is that I have a custom form in a repeater that shows data from a database. I have a user input form on another page, where my customers input data. I then need to add couple of input fields for my own use and which I need to see in the calendar event.

What I’m asking is that I got it working with a Wix Form, but not with a custom form that displays data from a collection, so is it possible to make it work with a custom form?

Thank you so much for this help!

Same question to you Yisrael: is it possible to make your example work so that the form where you have the input fields, would get some data from a database and a few blank fields where the site admin would fill in the needed data and after that send it to google sheets? Haven’t tried it yet myself so no need to stress over it, just wondering.

It’s a difficult example to modify as a beginner so I guess I’ll try other resources first.

Shouldn’t be a problem using a form since that’s what the example uses. And you’re right - it’s not a trivial example.

Yes, should be do-able. The most obvious scenario would be:

  1. you collect all the info you need from different sources (forms and your data)
  2. you store all that together in an “events”-collection using dataset´s .save() method
  3. .save() returns a Promise, holding all the values for the row you just stored in JSON-format
  4. now you map those fields (using dot-notation) onto the JSON-object that sends info to Zapier

or, instead of 3, you don´t wait for the Promise to return and just prepare the JSON-object from the input you gathered in 1 (they shoulld be 100% identical).

EDIT: What I do not understand is this: do you mean a user fills out a form on your site and YOU want to add info to this MANUALLY? If so, you have to split it up into parts:

  1. let user fill out form
  2. store it in a collection
  3. send an email to yourself “You have work to do” with a link to another form on your site (Admin)
  4. click on the link in email, show another form with the extra fields, fill it out
  5. store and send to gCalendar
  6. maybe: send Confirmation email to user

Hi Yisrael,

Your google sheets NPM example is excellent, however it proving very difficult for a beginner coder to adapt it to other APIs due to its complexity.

It would be great to see a similar example for connecting to the Google calendar API - e.g how to set up OAuth 2.0 with some examples for using the API in Corvid and with the Wix DB.

Thank you

Giri’s Example is perfect but I managed to cook up something independent of Zapier. If you want to have a look here is the link: https://www.wix.com/corvid/forum/community-discussion/tutorial-google-calendar-api-create-event-in-your-google-calendar-with-corvid

re you using Google´s API directly? Are you aware that there are 2 other possibilities: the google calendar (light) NPM and using Zapier (which is the one I used). For that, you need to create a free Zapier account, define a Zapier Webhook as a trigger and use the URL-endpoint they give you to send data to it using wix-fetch (post) from the backend.

How do I add events here? https://www.dreamcalendars.com/calendar/2020

Thanks Yisrael. This link is now broken. Is there a new link you can share?

I am looking to make a list of non-repeating events in text form from google calendar api. Does my api key get stored in frontend, or does wix make the request and rebuild my site every time something changes on the api’s side? I know JavaScript and html, but haven’t used wix before; just trying to help a friend with their site.

Thanks Shan. This link is now broken. Is there a new link you can share?

I am looking to make a list of non-repeating events in text form from google calendar api. Does my api key get stored in frontend, or does wix make the request and rebuild my site every time something changes on the api’s side? I know JavaScript and html, but haven’t used wix before; just trying to help a friend with their site.