Talk to Franz

Article

Enable your ChatGPT CustomGPTs to send Emails

Three parts: an email service API, a Cloudflare Worker as glue and an OpenAPI action in the GPT. ChatGPT writes the code. You copy, paste and click.

ChatGPT with Email Integration

Key takeaways

  • You need a verified sender and an API key from an email sending service, for example Brevo.
  • A Cloudflare Worker connects the email service API to the Custom GPT.
  • ChatGPT writes the worker script and the OpenAPI 3.1.0 specification from two prompts.
  • A "Method not allowed" page after deploying the worker is ok.
  • The same approach works for any other API integration with Custom GPTs.

Get an API key from an email service

  1. Sign up at an email sending service of your choice, e.g. Brevo (formerly SendInBlue), and select the free version.
  2. Verify a sender under https://app.brevo.com/senders/list so the service is allowed to use your email address.
  3. On the API page, e.g. https://app.brevo.com/settings/keys/api, click “Generate new API Key”.
  4. Save the API key in a text file.

Create a Cloudflare Worker

  1. Sign up at www.cloudflare.com and select the free version.
  2. In the navigation open “Workers & Pages”. Click “Create”, then “Create Worker”.
  3. Give your worker a funny name and click “Save”.
  4. Click “Finish”.
  5. Click “Edit code”. The code editor takes the glue between your mail service API and your Custom GPT.

Let ChatGPT write the worker script

  1. Open ChatGPT in the 4o version, which I used in June 2024. Do not try to code with the 3.5 version.
  2. Copy the URL of your service’s email sending API documentation. Brevo’s: https://developers.brevo.com/docs/send-a-transactional-email.
  3. Write something like this, with your own email and API key:

    I want to create a customGPT that sends emails via their OpenAPI integration.

    First I now need a cloudflare worker script that takes the API described here https://developers.brevo.com/docs/send-a-transactional-email and takes whatever request is then gets from the CustomGPT to send the email via the Email Services API. We only want to send text emails with subject and body. Easiest implementation possible.

    My verified sender email is [email protected]

    This is my API key: xkeysib-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  4. Copy the code you get.
  5. Paste it into the Cloudflare editor.
  6. Click “Deploy”, then the blue underlined “workers.dev” link.
  7. “Method not allowed” or similar is ok. Copy the URL of that page.

Let ChatGPT write the OpenAPI specification

  1. In the same ChatGPT thread, type something like this. The OperatorId note is there because ChatGPT sometimes forgets it.

    Thank you for the worker code. The worker is now deployed under https://hudri-wudri-7e76.XXXXXXXXXXXX.workers.dev/

    I now need the simplest possible OpenAPI 3.1.0 specification file so that the CustomGPT can access the API and trigger the event.

    The OpenAPI specification must fit the provided worker code perfectly. Include OperaterIDs

  2. Copy the code that comes out.

Add the action to your Custom GPT

  1. On the “Create new Custom GPT” page, set the necessary fields.
  2. Click “Create new action” and paste the OpenAPI specification.
  3. To publish the GPT on the open web, add a link to your privacy policy.
  4. Click the second back button from the top. (Bad UX from the OpenAI team.)

Test it, then publish

  1. Test it. When asked, click “Confirm”.


  2. Happy with the result (the integration, not the jokes)? Click “Create” to publish.

All articles