workflows.fit
Back to n8n workflows
n8n templateFreeBy Oskar

Compose reply draft in Gmail with OpenAI assistant

This workflow uses OpenAI Assistant to compose draft replies for labeled email messages. It automatically connects the drafts to Gmail threads. šŸ’” You can add knowledge base to your OpenAI Assistant and make your repl...

DevelopmentCore NodesCommunicationHITLAILangchainSticky NoteGmail
Loading interactive preview...

Template notes

This workflow uses OpenAI Assistant to compose draft replies for labeled email messages. It automatically connects the drafts to Gmail threads.

šŸ’” You can add knowledge base to your OpenAI Assistant and make your reply drafts very customized (e.g. compose response with product information in response to inquiry from customer).

šŸŽ¬ See this workflow in action [in my YouTube video](https://youtu.be/a8Dhj3Zh9vQ) about automating Gmail.

How it works?

The workflow is triggered at regular intervals (default: every 1 minute – you can change this value) to check for messages with a specific label (e.g., "AI").

The content of the retrieved email message is then forwarded to the OpenAI Assistant node, and a reply draft is generated. Next, the response from the Assistant is converted to HTML, and a raw message in RFC standard is composed.

šŸ’” You can learn more about composing drafts with the Gmail API in [the official Google documentation](https://developers.google.com/gmail/api/reference/rest/v1/users.drafts/create).

The raw email message (reply draft) is encoded and attached to the original thread ID. Finally, the trigger label (in this case: "AI") is removed to prevent the workflow from looping.