The following page describes how to set up assistant actions for Google Calendar and Gmail.
Add Google Calendar actions
When Google Calendar actions are turned on, end users can ask the assistant to create Google Calendar events for them.
For example, a user could enter "schedule a meeting with user1@example.com at 3pm tomorrow". The assistant asks for additional details if necessary, and then asks the user to confirm creating the event.
The assistant can read and edit the following Google Calendar fields through actions:
Field | Description |
---|---|
Attendees | Required. List of attendee email addresses. The requesting user is automatically added to the list. |
Title | Title of the meeting. |
Start time | Start time of the meeting. |
Duration | Duration of the meeting. Default is 30 minutes. |
Time zone | Time zone for meeting. If not provided the user's time zone is used. |
Description | Description of the meeting. |
Set up authentication and permissions for Google Calendar
Before turning on Google Calendar actions, an administrator must enable the Google Calendar API and set up authorization.
Enable the Google Calendar API
In the Agentspace, enable the following APIs:
The Google Calendar API: Enable the API
The Google People API: Enable the API
Create an OAuth app and add scopes
- Go to the APIs & Services > OAuth consent screen: Go to the OAuth consent screen
- Select Internal and then click Create.
- Enter a name for your OAuth app.
- Enter a user support email.
- Enter developer contact information.
- Click Save and continue.
Create an OAuth client ID
This procedure describes how to create a new OAuth client ID for Google Cloud actions. This OAuth client ID and secret can also be used for other Google Cloud actions. If you have an existing Google Cloud OAuth client ID for Google Cloud actions, you can use that client ID and secret for Google Calendar actions instead of creating a new client ID.
- Go to the Credentials page and click Create credentials > OAuth client ID.
- Select Web application.
- Enter a name for your client ID.
- Click Add URI and enter the following URI:
https://vertexaisearch.cloud.google.com/oauth-redirect
- Click Create and copy the following information:
- Client ID
- Client secret
Add a Google Calendar action
Before you begin, make sure the following is completed:
- A Google Cloud administrator has completed the steps in
Set up authentication and permissions for Google Calendar
and provided you with the following:
- Client ID
- Client secret
Configure Google Calendar actions in the Google Cloud console
To add actions to your app using the console, do the following:
- In the Agentspace, go to the Agentspace page.
- Go to your app.
- Go to the Actions page.
- For Google Calendar, click Connect.
- Enter a name for your connector.
- Enter authorization information for your connector
- Select which actions to enable.
- Click Finish setup. Your action is displayed on the Actions page. It takes 5 to 15 minutes for actions to begin to work in your app.
Configure Google Calendar actions using the API
To add actions to your app using the API, do the following.
Create a Google Calendar connector for actions.
SERVER=https://discoveryengine.googleapis.com curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-GFE-SSL: yes" \ -H "X-Goog-User-Project: YOUR_COLLECTION_DISPLAY_NAME" \ "$SERVER/v1alpha/projects/PROJECT_NUMBER/locations/global:setUpDataConnector" \ -d '{ "collectionId": "PROJECT_NUMBER", "collectionDisplayName": "YOUR_COLLECTION_DISPLAY_NAME", "dataConnector": { "dataSource": "google_calendar", "entities": [ { "entityName": "google_calendar" } ], "syncMode": "PERIODIC", } }'
Update the connector to include the action that you configured.
SERVER=https://discoveryengine.googleapis.com PROJECT_NUMBER={YOUR PROJECT_NUMBER} COLLECTION_ID="{YOUR COLLECTION ID}" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token --project "${PROJECT_NUMBER}")" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: ${PROJECT_NUMBER}" \ "$SERVER/v1alpha/projects/${PROJECT_NUMBER}/locations/global/collections/${COLLECTION_ID}/dataConnector?update_mask=action_config" \ -d '{ "name": "projects/${PROJECT_NUMBER}/locations/global/collections/${COLLECTION_ID}/dataConnector", "action_config": { "is_action_configured": true, "action_params": { "client_id": "{client id from Google Calendar OAuth API}", "client_secret": "{client secret from Google Calendar OAuth API}" } } }'
Enable Google Calendar actions for your assistant.
SERVER=https://discoveryengine.googleapis.com PROJECT_NUMBER={YOUR PROJECT_NUMBER} ENGINE_ID="{YOUR ENGINE ID}" CONNECTOR_ID="{THE CONNECTOR'S COLLECTION ID YOU GENERATED IN PREVIOUS STEP}" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token --project "${PROJECT_NUMBER}")" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: ${PROJECT_NUMBER}" \ "$SERVER/v1alpha/projects/${PROJECT_NUMBER}/locations/global/collections/default_collection/engines/${ENGINE_ID}/assistants/default_assistant?update_mask=enabledActions" \ -d '{ "name": "projects/'"${PROJECT_NUMBER}"'/locations/global/collections/default_collection/engines/'"${ENGINE_ID}"'/assistants/default_assistant", "enabledActions": { "projects/'"${PROJECT_NUMBER}"'/locations/global/collections/'"${CONNECTOR_ID}"'/dataConnector": { "actionInfo": [ { "actionName": "create_calendar_event", "actionDisplayName": "Create Calendar Event" } ] } } }'
After you add actions, the assistant can perform those actions on behalf of your end users in the app. The first time a user asks the assistant to perform a Google Calendar action, they are asked to authorize access to their Google Calendar account. To use the assistant, users must have Agentspace Enterprise Plus licenses.
Add Gmail actions
When Gmail actions are turned on, end users can ask the assistant to send emails for them.
For example, a user could enter "send an email to user1@example.com with title 'Hi there' and content 'how are you doing?'". The assistant asks for additional details if necessary, then asks the user to confirm sending the email.
The assistant can read and edit the following Gmail fields through actions:
Field | Description |
---|---|
To | Required. Recipients email list. |
Subject | Required. Subject of the email |
Content | Required. Contents of the email in Markdown format. |
CC | Email's CC list. |
BCC | Email's BCC list. |
Set up authentication and permissions for Gmail
Before turning on Gmail actions, an administrator must enable the Gmail API and set up authorization.
Enable the Gmail API
In the Agentspace, enable the following APIs:
The Gmail API: Enable the API
The Google People API: Enable the API
Create an OAuth app and add scopes
- Go to the APIs & Services > OAuth consent screen: Go to the OAuth consent screen
- Select Internal and then click Create.
- Enter a name for your OAuth app.
- Enter a user support email.
- Enter developer contact information.
- Click Save and continue.
Create an OAuth client ID
This procedure describes how to create a new OAuth client ID for Google Cloud actions. This OAuth client ID and secret can also be used for other Google Cloud actions. If you have an existing Google Cloud OAuth client ID for Google Cloud actions, you can use that client ID and secret for Gmail actions instead of creating a new client ID.
- Go to the Credentials page and click Create credentials > OAuth client ID.
- Select Web application.
- Enter a name for your client ID.
- Click Add URI and enter the following URI: https://vertexaisearch.cloud.google.com/oauth-redirect
- Click Create and copy the following information:
- Client ID
- Client secret
Configure a Gmail action
Before you begin, make sure the following is completed:
- A Google Cloud administrator has completed the steps in
Set up authentication and permissions for Gmail
and provided you with the following:
- Client ID
- Client secret
Configure Gmail actions in the Agentspace
To add actions to your app using the console, do the following:
- In the Agentspace, go to the Agentspace page.
- Go to the Actions page.
- For Gmail, click Connect.
- Enter a name for your connector.
- Enter authorization information for your connector
- Select which actions to enable.
- Click Finish setup. Your action is displayed on the Actions page. It takes 5 to 15 minutes for actions to begin to work in your app.
Configure Gmail actions using the API
To add actions to your app using the API, do the following.
Create a Gmail connector for actions:
SERVER=https://discoveryengine.googleapis.com curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-GFE-SSL: yes" \ -H "X-Goog-User-Project: YOUR_COLLECTION_DISPLAY_NAME" \ "$SERVER/v1alpha/projects/PROJECT_NUMBER/locations/global:setUpDataConnector" \ -d '{ "collectionId": "PROJECT_NUMBER", "collectionDisplayName": "YOUR_COLLECTION_DISPLAY_NAME", "dataConnector": { "dataSource": "google_mail", "entities": [ { "entityName": "google_mail" } ], "syncMode": "PERIODIC", } }'
Update the connector to include action configurations.
SERVER=https://discoveryengine.googleapis.com PROJECT_NUMBER={YOUR PROJECT_NUMBER} COLLECTION_ID="{YOUR COLLECTION ID}" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token --project "${PROJECT_NUMBER}")" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: ${PROJECT_NUMBER}" \ "$SERVER/v1alpha/projects/${PROJECT_NUMBER}/locations/global/collections/${COLLECTION_ID}/dataConnector?update_mask=action_config" \ -d '{ "name": "projects/${PROJECT_NUMBER}/locations/global/collections/${COLLECTION_ID}/dataConnector", "action_config": { "is_action_configured": true, "action_params": { "client_id": "{client id from Google Mail OAuth API}", "client_secret": "{client secret from Google Mail OAuth API}" } } }'
Enable Gmail actions for your assistant.
SERVER=https://discoveryengine.googleapis.com PROJECT_NUMBER={YOUR PROJECT_NUMBER} ENGINE_ID="{YOUR ENGINE ID}" CONNECTOR_ID="{THE CONNECTOR'S COLLECTION ID YOU GENERATED IN PREVIOUS STEP}" curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token --project "${PROJECT_NUMBER}")" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: ${PROJECT_NUMBER}" \ "$SERVER/v1alpha/projects/${PROJECT_NUMBER}/locations/global/collections/default_collection/engines/${ENGINE_ID}/assistants/default_assistant?update_mask=enabledActions" \ -d '{ "name": "projects/'"${PROJECT_NUMBER}"'/locations/global/collections/default_collection/engines/'"${ENGINE_ID}"'/assistants/default_assistant", "enabledActions": { "projects/'"${PROJECT_NUMBER}"'/locations/global/collections/'"${CONNECTOR_ID}"'/dataConnector": { "actionInfo": [ { "actionName": "send_email", "actionDisplayName": "Send Email" } ] } } }'
After you add actions, the assistant can perform those actions on behalf of your end users in the app. The first time a user asks the assistant to perform a Gmail action, they are asked to authorize access to their Gmail account. To use the assistant, users must have Agentspace Enterprise Plus licenses.