easyappointments icon indicating copy to clipboard operation
easyappointments copied to clipboard

Appointment creation in Google calendar

Open JiroMusik opened this issue 1 year ago • 11 comments

Hi guys,

is there any way to integrate the sync with Events created in Google Calendar? So when I create an event that does not match all required fields, the sync will not finish and shows an error message. Is there any way to set default options for all required fields?

Thanks jiromusik

JiroMusik avatar Aug 17 '23 02:08 JiroMusik

Hello!

There is currently already two way sync support with Google Calendar.

Which error are you getting during syncing?

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

alextselegidis avatar Aug 21 '23 12:08 alextselegidis

Only when there are new events created through Google Calendar there is following message: Client error: POST https://oauth2.googleapis.com/token/ resulted in a 400 Bad Request response: {"error":"invalid_grant","error_description":"Token has been expired or revoked"}

I have set following permission in OAuth: grafik

When I remove the event again, Sync from App to Google works again.

After reconnecting the Sync I now get following error: Not all required fields are provided: Array ( [start_datetime] => 2023-07-27 18:00:00 [end_datetime] => 2023-07-27 22:00:00 [is_unavailability] => 1 [location] => Heartbeat Studio [notes] => Long Single Session 4h [id_users_provider] => 4 [id_google_calendar] => apbogpf3m68p27q3hnc2lgadsc [id_users_customer] => [id_services] => )

JiroMusik avatar Aug 24 '23 12:08 JiroMusik

I've hit this issue as well.

In the WordPress plugin I used before (Webba), I could enter appointments directly in my Google Calendar and they would be picked up by Webba during the sync so that the slot I'd just booked out could not be selected by someone else. Now, i have to use the EA backend to do this which is really inconvenient if I'm in a meeting and need to block out my time, when all I have is my phone.

Would it be possible for EA to populate the necessary "missing" fields with default values when syncing an appointment that is created in Google Calendar so that this scenario, and the error detailed above by @JiroMusik, can be catered for?

brackenhill-mob avatar Aug 25 '23 14:08 brackenhill-mob

Hey sorry for asking again but how is the two-way sync supposed to work? I would love to integrate but what field in Google Calendar app needs to be populated?

Everything created in EA is synced to google but not the other way round

Edit: Changes to existing entries, created in EA are synchronized to EA. But not even a duplicated google calendar event is added.

JiroMusik avatar Sep 19 '23 23:09 JiroMusik

I think I found the culprit:

In a file on your server... I did..

nano application/controllers/Google.php

In this Google.php file look for the entry below.

// Record doesn't exist in the Easy!Appointments, so add the event now.
               $appointment = [
                   'start_datetime' => $event_start->format('Y-m-d H:i:s'),
                   'end_datetime' => $event_end->format('Y-m-d H:i:s'),
                   'is_unavailability' => TRUE,
                   'location' => $google_event->getLocation(),
                   'notes' => $google_event->getSummary() . ' ' . $google_event->getDescription(),
                   'id_users_provider' => $provider_id,
                   'id_google_calendar' => $google_event->getId(),
                   'id_users_customer' => NULL,
                   'id_services' => NULL,
               ];

change to thenumber that belongs to the provider that is connected to the email account NOT THE ADMIN drawback is that this will probably work for only 1 provider. The id_services can be whatever of course you'll see that service. Maybe create a custom services for this and use that id I found these values with phpmyadmin and for me it became

                   'id_users_customer' => 5,
                   'id_services' =>5,

If you book: Easy!appointments --> Google Calendar you'll see that booking almost instantly reflected to the Google calendar. Google --> Easy!appointments you'll need a cron job that checks every 10 minutes or so. Or push the button on the main calendar view

Forsskieken avatar Sep 29 '23 09:09 Forsskieken

@JiroMusik Could you please download and try the latest 1.5 dev package and see if you can reproduce the problem there? The google sync was updated to fix minor issues.

@Forsskieken Thanks for providing your solution here, but this will probably won't fix the problem

alextselegidis avatar Oct 09 '23 13:10 alextselegidis

About is showing 1.5.0-dev.4 Is there a newer package?

JiroMusik avatar Oct 09 '23 16:10 JiroMusik

As i put also here, to be able to get the address when booked in Google calendar, I would also add address, city and zipcode to the location field, when the client books:

booking.php:

            if (empty($appointment['location']) && !empty($service['location'])) {
                $appointment['location'] = $service['location'];
            }
            // if not location: use the full address given when booked
            if (empty($appointment['location'])) {
                $appointment['location'] = $customer['address'] . ' ' . $customer['zip_code'] . ' ' . $customer['city'];
            }

antsfiles avatar Oct 12 '23 22:10 antsfiles

@JiroMusik

There is no newer package out so far.

Hmm I'm using Google Sync for quite some time and the token would not get expired.

Could it be that the sync process was not executed for some time?

Are you using a cron job for syncing?

@iriikoad

Please create a new ticket for this

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

alextselegidis avatar Oct 23 '23 09:10 alextselegidis

I digged into this because this is not an issue in 1.4.3

@alextselegidis I do not understand how you cannot be affected by this issue (unless you have a local version that is different than the 1.5.0-dev4 release).

application/models/Appointments_model.php has a new code snipped for the validation function (see picture)

I uncommented the two lines that cause this issue and now it works again.

2024-02-08_12-46-49

Either this validation is unnecessary and can be removed or in application/models/Google.php in the sync function 'id_users_customer' and 'id_services' should not be set to NULL.

image

Grekkor avatar Feb 08 '24 11:02 Grekkor

My sync with the google calendar also still does not work correctly and somehow the working 1-way sync disconnects after few days or weeks too.Am 08.02.2024 12:33 schrieb Gregor @.***>: I now run into this issue as well since using the dev package. On 1.4.3 this was not an issue an my calendar events in Google were exactly the same.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

JiroMusik avatar Feb 08 '24 12:02 JiroMusik