Thumbnail for ChatGPT with Gmail

ChatGPT with Gmail

Learn how to build a custom GPT in ChatGPT that manages emails in Gmail using Caddey — no coding required.

June 2, 2025


In this tutorial, you'll learn how to integrate Gmail with ChatGPT using Caddey. By setting up a custom GPT that connects to Caddey, you'll be able to list your emails, read messages, create drafts, and send new emails directly from a ChatGPT conversation – all without writing any code. Let's get started!

Prerequisites

  • ChatGPT Plus/Pro subscription: Access to custom GPT creation features in ChatGPT.
  • Caddey account: A Caddey account to create an OAuth client and connect Gmail.
  • Google account with Gmail access: A personal or work Google account that you use with Gmail.
  • Google Cloud Console access: Admin rights to create OAuth credentials for your Google account.

Unlike some other apps in Caddey's marketplace, Gmail requires you to create your own Google OAuth client due to Google's restricted scope requirements. This tutorial includes detailed steps to set up your Google Cloud project and OAuth credentials.

Step 1: Create a Google Cloud Project and OAuth Client

  1. Go to Google Cloud Console: Visit https://console.cloud.google.com/ and sign in with your Google account.
  2. Create or select a project: Use the project picker (top left) → New Project (or select an existing one). Name it something like "Caddey Gmail Integration."
  3. Enable the Gmail API: In the left nav, go to APIs & ServicesLibrary. Search for "Gmail API" and click Enable.
  4. Configure OAuth consent screen: Go to APIs & ServicesOAuth consent screen.
    • User type: Choose External (unless you're on Google Workspace and want Internal)
    • App information: Fill in App name (e.g., "My Gmail Assistant"), User support email, and Developer contact information
    • Scopes: Click Add or Remove Scopes and add: https://mail.google.com/ (full Gmail access)
    • Test users: Add the Google accounts that will test this integration (your account at minimum)
    • Save and continue (you can stay in Testing mode; verification isn't required for test users)
  5. Create OAuth 2.0 credentials: Go to APIs & ServicesCredentialsCreate CredentialsOAuth client ID.
    • Application type: Web application
    • Name: e.g., "Caddey Gmail Client"
    • Authorized redirect URIs: Add https://app.caddey.ai/oauth2/callback
    • Click Create and copy the Client ID and Client Secret (you'll need these for Caddey)

Step 2: Create a Caddey OAuth Client

  1. Log in to Caddey: Sign in to your Caddey account and navigate to the Clients section.
  2. Add a new client: Click Add Client, name it (e.g., "Gmail Assistant"), choose Confidential as the client type, and optionally add a description like "Manages my Gmail via ChatGPT."
  3. Leave redirect URI empty for now: We'll get the exact callback URL from ChatGPT in the next steps.
  4. Save the client: Click Save. Caddey will generate a Client ID and Client Secret for your OAuth client—copy both now as you'll need them for authentication.

The OAuth client represents your ChatGPT assistant's identity in Caddey. It allows ChatGPT to securely authenticate and call Gmail actions through Caddey using OAuth 2.0.

Step 3: Connect Gmail in Caddey

  1. Open the Apps section: In Caddey's dashboard, go to AppsMarketplace.
  2. Find Gmail: Search for Gmail and click Connect.
  3. Choose "Use your own key": Select the option to use your own OAuth credentials.
  4. Enter your Google OAuth credentials:
    • Client ID: Paste the Client ID from your Google Cloud Console
    • Client Secret: Paste the Client Secret from your Google Cloud Console
    • Click Save
  5. Complete Google sign-in: You'll be redirected to Google. Choose the Gmail account you added as a Test user and approve the requested scope https://mail.google.com/.
  6. Verify connection: Once successful, you'll return to Caddey and Gmail will appear as Connected under Apps.

Step 4: Create a Gmail Toolbox

  1. Go to Toolboxes: In Caddey, select Toolboxes.
  2. Create a new toolbox: Click Create Toolbox. Name it "Gmail Tools" and add a description, e.g., "Tools for managing my Gmail messages."
  3. Add Gmail tools: Click Add Tools and select the following actions:
    • List messages
    • Get message
    • Create draft
    • Send draft
    • Modify message labels

Step 5: Assign the Toolbox to Your Client

  1. Open your client: Return to Clients, and select your "Gmail Assistant" client.
  2. Add the toolbox: In the client's Toolboxes tab, click Add Toolbox and choose Gmail Tools.

Step 6: Create a Custom GPT in ChatGPT

  1. Open ChatGPT: Log into your ChatGPT Plus/Pro account and click Explore GPTs or Create GPT.
  2. Name your GPT: Enter a title, for example, "Gmail Assistant".
  3. Add a description: Something like "Helps manage my Gmail messages via Caddey". Optionally, add usage tips or personality notes.

Step 7: Connect the GPT to Caddey

  1. Add an action: In the GPT builder, click Add Action to configure an external API call.
  2. Configure authentication:
    • Method: OAuth
    • Authorization URL: https://auth.caddey.ai/realms/caddey/protocol/openid-connect/auth
    • Token URL: https://auth.caddey.ai/realms/caddey/protocol/openid-connect/token
    • Client ID: Your Caddey OAuth Client ID
    • Client Secret: Your Caddey OAuth Client Secret
    • Scope: openid profile email offline_access
  3. Copy the Callback URL: After configuring OAuth, ChatGPT will display a callback URL (it will look like https://chat.openai.com/aip/g-{unique-id}/oauth/callback). Copy this URL.
  4. Update your Caddey OAuth Client: Go back to your Caddey dashboard, edit the OAuth client you created in Step 2, and add the callback URL you just copied to the Redirect URIs field. Save the client.
  5. Update Google Cloud OAuth Client: Go back to Google Cloud Console, edit your OAuth client from Step 1, and add the same callback URL to the Authorized redirect URIs field (you should already have https://app.caddey.ai/oauth2/callback from Step 1, but add the ChatGPT callback URL as well). Save the changes.

If you need to revoke access, you can disable or delete the OAuth client in both Caddey and Google Cloud Console.

  1. Import OpenAPI schema: Choose Import OpenAPI from a URL and enter: https://api.caddey.ai/v3/api-docs/tools
  2. Verify endpoints: Ensure ChatGPT sees:
    • GET /tools/query (lists available tools)
    • POST /tools/{toolId}/execute (executes a tool)
  3. Save the action: Confirm and save—your custom GPT is now linked to Caddey.

Step 8: Test Your Gmail Assistant

Switch to the preview or start a chat with your new GPT:

  1. List available tools: Ask, "What tools can you use?"—it should list your Gmail tools.
  2. Retrieve emails: Try, "List my recent emails." The GPT will call List messages and display your inbox messages.
  3. Read a specific email: Prompt, "Show me the full content of the first email." It will use the Get message tool.
  4. Create and send an email: Ask, "Draft an email to [email protected] with subject 'Meeting Follow-Up' and body 'Thanks for meeting today. Let's stay in touch.' Then send it." The GPT will create a draft and send it.

You can expand functionality anytime by adding more Gmail actions or connecting other apps in Caddey—just update your toolbox and reassign it to the client.

Finalize and Deploy Your GPT

Once testing succeeds, click Save or Done in the GPT builder. Your Gmail Assistant will now appear in your ChatGPT interface—ready to manage your Gmail via natural language.

Troubleshooting

  • 403 insufficientPermissions from Gmail: Your Google token likely lacks the https://mail.google.com/ scope or the account isn't a Test user. Ensure the scope is added on the Consent screen and that you authorized the exact account.
  • redirect_uri_mismatch: The redirect URI in Google Cloud must exactly match the callback URL from ChatGPT. Update both the Google OAuth client and Caddey OAuth client with the correct callback URL.
  • "This app isn't verified" warning: This is normal in Testing mode for Test users. For broader distribution, you'll need Google verification for restricted scopes.
  • Gmail rate limits: Back off and retry with exponential delay. Keep message fetches to minimal formats when possible.

Happy emailing!