This page provides an instruction & guide for developers building a GPT Action for a specific application. Before you proceed, make sure to first familiarize yourself with the following information:
This GPT Action provides an overview of how to connect to Google Gmail, Google’s Private & Secure Email for Personal or Business. This Action is connected to the Google Gmail APIs that can read, send, list, and draft emails in the authorized account.
Value: The Gmail GPT will serve as a powerful tool to streamline communication processes, improve customer engagement, and optimize resource allocation.
Example Use Cases:
Check out these links from the application before you get started:
Before you get started, make sure you’ve a Google Cloud account and that the Gmail API is enabled:
Once you've created a Custom GPT, copy the text below in the Instructions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.
**Context**
Act as an email assistant designed to enhance user interaction with emails in various ways. This GPT can assist with productivity by summarizing emails/threads, identifying next steps/follow-ups, drafting or sending pre-written responses, and programmatically interacting with third-party tools (e.g., Notion to-dos, Slack channel summaries, data extraction for responses). This GPT has full scope access to the GMAIL OAuth 2.0 API, capable of reading, composing, sending, and permanently deleting emails from Gmail.
**Instructions**
- Always conclude an email by signing off with logged in user's name, unless otherwise stated.
- Verify that the email data is correctly encoded in the required format (e.g., base64 for the message body).
- Email Encoding Process: 1\ Construct the email message in RFC 2822 format. 2\ Base64 encode the email message. 3\Send the encoded message using the API.
- If not specified, sign all emails with the user name.
- API Usage: After answering the user's question, do not call the Google API again until another question is asked.
- All emails created, draft or sent, should be in plain text.
- Ensure that the email format is clean and is formatted as if someone sent the email from their own inbox. Once a draft is created or email sent, display a message to the user confirming that the draft is ready or the email is sent.
- Check that the "to" email address is valid and in the correct format. It should be in the format "recipient@example.com".
- Only provide summaries of existing emails; do not fabricate email content.
- Professionalism: Behave professionally, providing clear and concise responses.
- Clarification: Ask for clarification when needed to ensure accuracy and completeness in fulfilling user requests.
- Privacy and Security: Respect user privacy and handle all data securely.
Once you've created a Custom GPT, copy the text below in the Actions panel. Have questions? Check out Getting Started Example to see how this step works in more detail.
openapi: 3.1.0
info:
title: Gmail Email API
version: 1.0.0
description: API to read, write, and send emails in a Gmail account.
servers:
- url: https://gmail.googleapis.com
paths:
/gmail/v1/users/{userId}/messages:
get:
summary: List All Emails
description: Lists all the emails in the user's mailbox.
operationId: listAllEmails
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The user's email address. Use "me" to indicate the authenticated user.
- name: q
in: query
schema:
type: string
description: Query string to filter messages (optional).
- name: pageToken
in: query
schema:
type: string
description: Token to retrieve a specific page of results in the list.
- name: maxResults
in: query
schema:
type: integer
description: Maximum number of messages to return.
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/MessageList'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal Server Error
/gmail/v1/users/{userId}/messages/send:
post:
summary: Send Email
description: Sends a new email.
operationId: sendEmail
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The user's email address. Use "me" to indicate the authenticated user.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
responses:
'200':
description: Email sent successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'500':
description: Internal Server Error
/gmail/v1/users/{userId}/messages/{id}:
get:
summary: Read Email
description: Gets the full email content including headers and body.
operationId: readEmail
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The user's email address. Use "me" to indicate the authenticated user.
- name: id
in: path
required: true
schema:
type: string
description: The ID of the email to retrieve.
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/FullMessage'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal Server Error
/gmail/v1/users/{userId}/messages/{id}/metadata:
get:
summary: Get Email Metadata
description: Gets the metadata of an email, including subject line.
operationId: getEmailMetadata
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The user's email address. Use "me" to indicate the authenticated user.
- name: id
in: path
required: true
schema:
type: string
description: The ID of the email to retrieve metadata for.
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/MessageMetadata'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
'500':
description: Internal Server Error
/gmail/v1/users/{userId}/drafts:
post:
summary: Create Draft
description: Creates a new email draft.
operationId: createDraft
parameters:
- name: userId
in: path
required: true
schema:
type: string
description: The user's email address. Use "me" to indicate the authenticated user.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Draft'
responses:
'200':
description: Draft created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Draft'
'400':
description: Bad Request
'401':
description: Unauthorized
'403':
description: Forbidden
'500':
description: Internal Server Error
components:
schemas:
MessageList:
type: object
properties:
messages:
type: array
items:
$ref: '#/components/schemas/Message'
nextPageToken:
type: string
Message:
type: object
properties:
id:
type: string
threadId:
type: string
labelIds:
type: array
items:
type: string
snippet:
type: string
raw:
type: string
format: byte
description: The entire email message in an RFC 2822 formatted and base64url encoded string.
FullMessage:
type: object
properties:
id:
type: string
threadId:
type: string
labelIds:
type: array
items:
type: string
snippet:
type: string
payload:
type: object
properties:
headers:
type: array
items:
type: object
properties:
name:
type: string
value:
type: string
parts:
type: array
items:
type: object
properties:
mimeType:
type: string
body:
type: object
properties:
data:
type: string
MessageMetadata:
type: object
properties:
id:
type: string
threadId:
type: string
labelIds:
type: array
items:
type: string
snippet:
type: string
headers:
type: array
items:
type: object
properties:
name:
type: string
value:
type: string
EmailDraft:
type: object
properties:
to:
type: array
items:
type: string
cc:
type: array
items:
type: string
bcc:
type: array
items:
type: string
subject:
type: string
body:
type: object
properties:
mimeType:
type: string
enum: [text/plain, text/html]
content:
type: string
Draft:
type: object
properties:
id:
type: string
message:
$ref: '#/components/schemas/Message'
Below are instructions on setting up authentication with this 3rd party application. Have questions? Check out Getting Started Example to see how this step works in more detail.
Before you set up authentication in ChatGPT, please take the following steps in the application.
In ChatGPT, click on "Authentication" and choose "OAuth". Enter in the information below.
Once you've set up authentication in ChatGPT, follow the steps below in the application to finalize the Action.
Are there integrations that you’d like us to prioritize? Are there errors in our integrations? File a PR or issue in our github, and we’ll take a look.