mavoweb / plugins

Teach Mavo new tricks!
https://plugins.mavo.io
7 stars 36 forks source link

[Plugin-Request] Google Calendar connection #106

Closed GalinhaLX closed 2 years ago

GalinhaLX commented 2 years ago

Hi

While there's already a plugin to connect to Google Sheets, I came to a use case, where it would be nice to be able to register to an event, connected to Google calendar

I guess it's possible to connect Google Calendar, to Google Sheets, then to Mavo (needs a specific spreadsheet, plugs ins on Google side that links spreadsheet to Google calendar... painfull for a simple user)

But it would be a really nice feature to be able to connect Mavo to a Google Calendar directly

something like Microsoft

  1. Use case 1:

Display availability of a meeting room

  1. Use case 2:

Register to a course/event 1 calendar for a classroom Teachers can add events to this calendar, with courses descriptions

Mavo would then handle the process of submeeting new attendees (A button on a Mavo page, to register to event)

Then outside mavo User would then receive a confirmation from Google calendar, to his email, confirming he has been added as attendee

LeaVerou commented 2 years ago

This would be cool for things like doodle as well.

DmitrySharabin commented 2 years ago

Hey folks! 👋🏻

Could you give me a favor and play with the first iteration of the Google Calendar plugin before I add it to the plugin register? Any feedback is appreciated.

Please note that for now this backend is read-only. So some use cases won't be addressed. And since this plugin is not in the register yet, please include it in your apps manually. Here is the URL: https://dmitrysharabin.github.io/mavo-gcalendar/mavo-gcalendar.js

Thanks!

DmitrySharabin commented 2 years ago

Btw, I still need to update OAuth consent screen (and verify it with Google), so Mavo might appear to you as an untrusted app. That's OK for now. :)

GalinhaLX commented 2 years ago

Hi @DmitrySharabin

Congratulations ! for your work, I'm sure it will open a lot of new ideas

Use case: "occupied -vs- availability"

A parent, want's to book an interview with a teacher. The idea is not to display all booked slots, but to propose 30 or 60 minutes interview, during available time (calendar free zones) -> Is there a way to request 'free zones' from Google?

-> Or will Mavo need to request all occupied slots, and make calculations to propose empty slots?

How do you see the solution for this use case?

DmitrySharabin commented 2 years ago

I added the create_event() action, so one can create events based on its textual descriptions. I'll be grateful if you give it a try.

UPDATE: Another one action has arrived—delete_event(). :)

ANOTHER UPDATE: And the last one action—update_event().

DmitrySharabin commented 2 years ago

How do you see the solution for this use case?

I have an idea to try. Will let you know when I'm done. :)

DmitrySharabin commented 2 years ago

I believe I'm ready to publish the plugin in the plugins register. But first I need to finish some stuff with Google to make Mavo a trusted app.

If you have any feedback you'd like to share, I'm all ears. 😉

GalinhaLX commented 2 years ago

Hi @DmitrySharabin

I'm testing it tonight and tomorrow :)

Few things I don't fully understand: About "To be able to update events, the user must be logged in and has the corresponding permissions."

About "permissions":

About button mv-action="create_event('**Appointment at Somewhere on June 3rd 10am-10:25am**')">Create Event</button>

GalinhaLX commented 2 years ago

by the time I wrote my message, I see you added a lot of documentation :)

So forget about my 2 first questions

Just curious about the format of the text we can pass to create_event

GalinhaLX commented 2 years ago

Question: what about response from created_event?

How does mavo knows the event was correctly created?

btw, I created this codepen:

Will you have a codepen to share? To check if I'm doing things right

DmitrySharabin commented 2 years ago

Hey @GalinhaLX 👋🏻

Thank you very much for your feedback—I definitely need to improve the docs. Will do it asap.

Does it mean logged in = authentificated user in mavo (could be with Github or other?) Or does it need to be Google account authentification?

It means authenticated in Mavo (via the Login button) with the Google account.

I guess mavo takes into account the Google calendar permissions? (meaning you can create event only if you set it in Google calendar to allow it?)

Exactly!

Is this text managed by Google? Does it need a specific format, like what, where, when and duration? Or, Google will try to do its best to understand what's the text about?

AFAIK, Google will do its best to parse the provided text. I believe you can follow the pattern you mentioned since it matches the example provided by Google in their docs (I stole it from there 😅).

DmitrySharabin commented 2 years ago

How does mavo knows the event was correctly created?

If there were no errors (in toasts) and/or warnings in the console, the event was created successfully (and the corresponding data will be updated and rendered automatically, so the user will see it).

I'm able to display event name, but I'm ot able to display date, or attendees

For debug purposes and to examine the structure of the event collection, you may try to add [events] after the list with events. You'll see that the attendees array is empty or contains empty strings. And to get the end date of the event, you need to add the dateTime property (or date for all-day events) inside the end property (see the start property as an example). That should help.

GalinhaLX commented 2 years ago

How does mavo knows the event was correctly created?

If there were no errors (in toasts) and/or warnings in the console, the event was created successfully (and the corresponding data will be updated and rendered automatically, so the user will see it).

ha! so i'll have a different use case: in case I want Mavo to create the event, without displaying the google calendar but i guess this could be done on requesting the specific event with mavo, then if it exists, we could toast something

I'm able to display event name, but I'm ot able to display date, or attendees

For debug purposes and to examine the structure of the event collection, you may try to add [events] after the list with events. You'll see that the attendees array is empty or contains empty strings. And to get the end date of the event, you need to add the dateTime property (or date for all-day events) inside the end property (see the start property as an example). That should help.

Good to know for [events] , I see all... but still no attendees:

despite this 'mavo' calendar being free to public (read and write)

GalinhaLX commented 2 years ago

Hi,

Test results for "read calendar":

Google calendar allows to have multiple calendars for same email adress, and

For, global calendar which is private, the link looks like: https://calendar.google.com/calendar/u/0?cid=bWU3NGQzdTJmODZ0aDFnajE1NjBnNHFjdDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ -> mavo replies I need to login to have access to it (including reading)

For specific calendar which is public, the link is different: https://calendar.google.com/calendar/embed?src=me74d3u2f86th1gj1560g4qct4%40group.calendar.google.com -> I can connect from Mavo without loggin (but it doesn't display attendees, and I guess other information)

On a public calendar, with a link with the email only (could be usefull to provide) https://calendar.google.com/calendar/embed?src=test4mavo%40gmail.com -> I can connect without loggin, and display attendees, (meaning I invited myself only, and set options to automaticly accept invitations to that email adress) but In this case, it doesn't display external attendees (even with gmail adress), even if they accepted the invitation (something strange here)

I would suggest to add, on Setting up documentation, some examples of how the calendar link should looklikes, because depending on the link, reading results are different, and it will impact the create_event action that will create the event on that specific calendar only

GalinhaLX commented 2 years ago

Also add on documentation, that people should read google calendar settings documentation carrefully :) Because you can for example, share a calendar, where all can add invitations, or where attendess can forward event, and add other attendees ... 🎉 Project-X 😱

(Fortunately, google offers, on their settings, the possibility to prevent guests from forwarding the invitation to someone else)

DmitrySharabin commented 2 years ago

@GalinhaLX Wow! Thank you so much for your detailed feedback and all the experiments you performed. I appreciate that. 🤝 I'll work through your comments and update the docs.

DmitrySharabin commented 2 years ago

The plugin is live. Yay! 🎉

I suggest continuing our discussion in the plugin's repo. Together we can make it better!

Thank you all! ❤️