Search code examples
actions-on-googledialogflow-esgoogle-calendar-apigoogle-assist-api

DialogFlow: Google Calendar Event function from Google Actions (Oauth2)?


I have created an agent in DialogFlow that interacts with the user giving her the ability to check for details like demographic from a back-end database. I have achieved this using Fulfillment/Webhook calls and have successfully parsed/returned different types of Responses to the user to play with. I have tested this on both an Android device and the Google Actions Simulator.

Now, what I want to achieve is to give user the ability to "Set a Reminder" on a platform like Google Calendar or similar through my App. By default, Google Assistant does this by simply telling it to "remind me..." and Google creates a reminder in the calendar. But as soon as I invoke my app, the Assistant is out of scope so using the "remind me" command won't work. I want to use the Google Calendar for example to create a reminder through my agent so that the user is notified at the due time.

I understand that when the user invokes an App in Google Assistant, she is using her Google credentials so I guess if I want to use the App to create a reminder, I should have the option. I have had a look at the Calendar API but I am not sure if I should proceed that way. Is there a better way of achieving this?

Please note, I want to use a reminder service that is available to the user without subscribing to a third-party service.


Solution

  • So for all those who are facing the same issue, here is what I did:

    1. First created an account on https://auth0.com
    2. Followed this guide to configure the necessary settings to link to Google Assistant (ignored the Jovo part)
    3. Used Auth0 guide to configure and link to my Google project credentials (ignored the Admins SDK Service part)
    4. Now when I run my Google Actions App on the device, a button "Link [App Name] to Google" showed up. Clicking on that "signed me in".
    5. Parsed the response in my webhook to grab originalRequest.data.user.accessToken

    This is the token mentioned in @lukedavis answer. The next step was to use the token to execute a call to the Calendar API. Upon trying that, I am facing a different problem which I am trying to find the solution for. But the above should assist those who wish get the accessToken.