Skip to content
ServicesPortfolioBlogAboutContactPolski

Blog4 min read

My chatbot stopped booking calls. One switch was to blame

7 days

after which Google invalidates the token of an app in testing mode

In short

The assistant on my website books phone calls straight into my Google Calendar. On 22 October it stopped doing that and replied with “technical error”. The cause was a single switch in Google’s settings. I describe how I found it, what I fixed, and what I now check on every project like this.

The assistant works simply. When someone writes that they want to talk and gives their name, phone number and a time between 3 pm and 9 pm, a 30-minute event appears in my calendar and I get a notification on my phone. For the website to write to the calendar, Google issues it an access key, called a token. The site keeps it on the server and uses it for every booking.

The symptom

Instead of a confirmation, the assistant said the call could not be saved because of a technical error, and asked for a different time. The second part was worse than the error itself. A different time would not have worked either, because the problem had nothing to do with the time.

Diagnosis: logs, not guesswork

The first step was the server logs from the moment of that conversation. They contained one specific error: invalid_grant. Google answers this way when a token is invalid, meaning it has expired or been revoked. The code was unchanged; the key had stopped working.

So the question was: why did a key that was supposed to work indefinitely expire? The answer was in the project settings in Google Cloud. The app the site uses to connect to the calendar had the status Testing. In that mode Google invalidates tokens after 7 days. It is a safeguard for apps under construction. On a live website it means something quietly breaks every week.

The fix in three steps

  1. Completing the app details: the website address, a link to the privacy policy and the domain. Without them Google does not let you change the status.
  2. Changing the status to “In production”. In this mode the token does not expire after a week. It only stops working if someone revokes access in their Google account.
  3. A new token. A key issued while the app was still in testing mode would expire anyway, so after the status change I signed in again and put the new one on the server. Then I checked that the site had access to the calendar again.

What if the calendar fails for another reason

Fixing the cause is not enough on its own. An external service can stop responding for many reasons, so I also changed how the assistant behaves when that happens:

  • it no longer asks for a different time, because that changes nothing,
  • the name, phone number and proposed time reach me as an urgent notification, so the enquiry is not lost,
  • the customer is told honestly that I will call back, and if the notification fails too, they get my number and email.

What it taught me

My own note for this project said the token “does not expire”. That was only half true, because it depended on a setting the note did not mention. I corrected it. From now on, for every assistant that writes to a calendar or another Google service, I check the production status before handover, not after the first failure.

If your website has a form, a chat or bookings connected to another service and you are not sure they really work, get in touch. I will check what happens after someone clicks “send”.