The following page describes how to set up assistant actions for Google Calendar and Gmail.
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, a Google Cloud administrator must enable the Google Calendar API and set up authorization as follows.
Enable the Google Calendar API
In the Google Cloud console, 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
If you don't have an OAuth app, follow these steps. If you already have an OAuth app, skip to Create an OAuth client credentials.
Click Get started.
Enter a name for your OAuth app.
Enter a user support email.
Select Internal.
Enter developer contact information.
Click Create.
Create OAuth client credentials
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.
Click Create client.
For Application type, select Web application.
For Name, enter a name for your client ID.
In the Authorized redirect URIs section, 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
Follow these steps to create a Google Calendar action using the console or the API:
Before you begin
Before you can add a Google Calendar action, make sure that you have the necessary prerequisites, including an existing app and authentication details.
A Google Cloud administrator must first complete the steps in the Set up authentication and permissions for Google Calendar section and provide you with the client ID and client secret before you can add actions.
You must have an existing Agentspace app that is connected to a Google Calendar data store. To create a new app, see Create an app.
If you recently enabled the Discovery Engine API in your Google Cloud project and created an app, wait for a minimum of 15 minutes for the app setup to complete before you configure Google Calendar actions.
Configure Google Calendar actions
Console
To add actions to your app using the console, do the following:
- In Agentspace, go to the Agentspace page.
- Choose your Google Agentspace app.
- Go to the Actions page.
Add an action:
If this is your first action, click Add action.
If you have created actions previously, click Create.
For Google Calendar, click Connect.
Enter a name for your action connector.
Enter authorization information for your action connector:
- For New client ID and New client secret, enter the client ID and client secret created by your administrator, in the Create OAuth client credentials section.
- Click Verify Auth and grant the Agentspace app access to your Google Calendar.
Select which actions to enable.
Click Finish Setup. Your action is displayed on the Actions page.
REST
To add actions to your app using the API, do the following.
Create an action connector for the Google Calendar action.
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: PROJECT_ID" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION:setUpDataConnector" \ -d '{ "collection_id":"CONNECTOR_ID", "collection_display_name":"CONNECTOR_DISPLAY_NAME", "data_connector":{ "data_source":"google_calendar", "action_config":{ "is_action_configured":true, "action_params":{ "client_id":"CLIENT_ID", "client_secret":"CLIENT_SECRET" } }, "connector_modes": ["ACTIONS"] } }'
PROJECT_ID
: the ID of the project where you want to create the Google Calendar action connector.LOCATION
: the multi-region of your Google Calendar action connector:global
,us
, oreu
.CONNECTOR_STORE_ID
: the ID of the connector that you want to create. This ID can contain only lowercase letters, digits, underscores, and hyphens.CONNECTOR_DISPLAY_NAME
: the display name of the connector that you want to create.CLIENT_ID
: the client ID created by your administrator, in the Create OAuth client credentials.CLIENT_SECRET
: the client secret created by your administrator, in the Create OAuth client credentials.
Link the Google Calendar action connector you created to an existing app.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: PROJECT_ID" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant?update_mask=enabled_tools" \ -d '{ "name": "projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant", "enabled_tools": { "projects/PROJECT_ID/locations/LOCATION/collections/CONNECTOR_ID/dataConnector": { "tool_info": [ { "tool_name": "create_calendar_event", "tool_display_name": "Create Calendar Event" } ] } } }'
PROJECT_ID
: the ID of the project where your app and Google Calendar action connector is located.LOCATION
: the multi-region of your app and action connector:global
,us
oreu
.APP_ID
: the ID of the app to which you want to attach the action.CONNECTOR_ID
: the ID of the Google Calendar action connector created in the previous step.
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.
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, a Google Cloud administrator must enable the Gmail API and set up authorization.
Enable the Gmail API
In the Google Cloud console, enable the following APIs:
The Gmail API: Enable the API.
The Google People API: Enable the API.
Create an OAuth app and add scopes
If you don't have an OAuth app, follow these steps. If you already have an OAuth app, skip to Create an OAuth client credentials.
Click Get started.
Enter a name for your OAuth app.
Enter a user support email.
Select Internal.
Enter developer contact information.
Click Create.
Create OAuth client credentials
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.
Click Create client.
For Application type, select Web application.
For Name, enter a name for your client ID.
In the Authorized redirect URIs section, 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 Gmail action
Follow these steps to create a Gmail action using the console or the API:
Before you begin
Before you can add a Gmail action, make sure that you have the necessary prerequisites, including an existing app and authentication details.
A Google Cloud administrator must first complete the steps in the Set up authentication and permissions for Gmail section and provide you with the client ID and client secret before you can add actions.
You must have an existing Agentspace app that is connected to a Gmail data store. To create a new app, see Create an app.
If you recently enabled the Discovery Engine API in your Google Cloud project and created an app, wait for a minimum of 15 minutes for the app setup to complete before you configure Gmail actions.
Configure Gmail actions
Console
To add actions to your app using the console, do the following:
- In Agentspace, go to the Agentspace page.
- Choose your Google Agentspace app.
- Go to the Actions page.
Add an action:
If this is your first action, click Add action.
If you have created actions previously, click Create.
For Gmail, click Connect.
Enter a name for your action connector.
Enter authorization information for your action connector:
- For New client ID and New client secret, enter the client ID and client secret created by your administrator, in the Create OAuth client credentials section.
- Click Verify Auth and grant the Agentspace app access to your Gmail.
Select which actions to enable.
Click Finish Setup. Your action is displayed on the Actions page.
REST
To add actions to your app using the API, do the following.
Create an action connector for the Gmail action.
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: PROJECT_ID" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION:setUpDataConnector" \ -d '{ "collection_id":"CONNECTOR_ID", "collection_display_name":"CONNECTOR_DISPLAY_NAME", "data_connector":{ "data_source":"google_calendar", "action_config":{ "is_action_configured":true, "action_params":{ "client_id":"CLIENT_ID", "client_secret":"CLIENT_SECRET" } }, "connector_modes": ["ACTIONS"] } }'
PROJECT_ID
: the ID of the project where you want to create the Gmail action connector.LOCATION
: the multi-region of your Gmail action connector:global
,us
oreu
.CONNECTOR_STORE_ID
: the ID of the connector that you want to create. This ID can contain only lowercase letters, digits, underscores, and hyphens.CONNECTOR_DISPLAY_NAME
: the display name of the connector that you want to create.CLIENT_ID
: the client ID created by your administrator, in the Create OAuth client credentials.CLIENT_SECRET
: the client secret created by your administrator, in the Create OAuth client credentials.
Link the Gmail action connector you created to an existing app.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ -H "X-Goog-User-Project: PROJECT_ID" \ "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant?update_mask=enabled_tools" \ -d '{ "name": "projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant", "enabled_tools": { "projects/PROJECT_ID/locations/LOCATION/collections/CONNECTOR_ID/dataConnector": { "tool_info": [ { "tool_name": "send_email", "tool_display_name": "Send Email" } ] } } }'
PROJECT_ID
: the ID of the project where your app and Gmail action connector is located.LOCATION
: the multi-region of your app and connector:global
,us
oreu
.APP_ID
: the ID of the app to which you want to attach the action.CONNECTOR_ID
: the ID of the Gmail action connector created in the previous step.
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.
Link both Google Calendar and Gmail actions to an app
The following API request demonstrates how to link both Google Calendar and Gmail actions to an existing app.
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: PROJECT_ID" \
"https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant?update_mask=enabled_tools" \
-d '{
"name":"projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID/assistants/default_assistant",
"enabled_tools":{
"projects/PROJECT_ID/locations/LOCATION/collections/CALENDAR_CONNECTOR_ID/dataConnector":{
"tool_info":[
{
"tool_name":"send_email",
"tool_display_name":"Send Email"
}
]
},
"projects/PROJECT_ID/locations/LOCATION/collections/GMAIL_CONNECTOR_ID/dataConnector":{
"tool_info":[
{
"tool_name":"create_calendar_event",
"tool_display_name":"Create Calendar Event"
}
]
}
}
}'
PROJECT_ID
: the ID of the project where your app and Google Calendar and Gmail action connectors are located.LOCATION
: the multi-region of your app and connectors:global
,us
oreu
.APP_ID
: the ID of the app to which you want to attach the action.CALENDAR_CONNECTOR_ID
: the ID of the Google Calendar action connector created in the previous step.GMAIL_CONNECTOR_ID
: the ID of the Gmail action connector created in the previous step.
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 or a Gmail action, they are asked to authorize access to their account.