create e-mail responses with fastmail and OpenAI n8n Workflow Template

n8n workflow template · 9 nodes · Email (IMAP)

create e-mail responses with fastmail and OpenAI is a free n8n workflow template that starts when a new email arrives over IMAP and works with Email (IMAP) and OpenAI. It has 9 nodes, 1 of them AI nodes (OpenAI). The notes inside the workflow say: “This n8n workflow automates the drafting of email replies for Fastmail using OpenAI's GPT-4 model. Here’s the overall process” To run it, you add your own credentials for HTTP Header Auth, IMAP and OpenAI API.

At a glance

Trigger
Email Trigger (IMAP) (Email Trigger (IMAP))
Nodes
9
Apps
Email (IMAP) and OpenAI
AI nodes
1
Credentials
3 types
Category
Email automation

Apps and integrations

  • Email (IMAP)
  • OpenAI

Node types used

  • HTTP Request
  • Split Out
  • Email Trigger (IMAP)
  • Edit Fields (Set)
  • OpenAI
  • Filter

How it works

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Workflow Description

This n8n workflow automates the drafting of email replies for Fastmail using OpenAI's GPT-4 model. Here’s the overall process

  1. Email Monitoring: The workflow continuously monitors a specified IMAP inbox for new, unread emails.
  2. Email Data Extraction: When a new email is detected, it extracts relevant details such as the sender, subject, email body, and metadata.
  3. AI Response Generation: The extracted email content is sent to OpenAI's GPT-4, which generates a personalized draft response.
  4. Get Fastmail Session and Mailbox IDs: Connects to the Fastmail API to retrieve necessary session details and mailbox IDs.
  5. Draft Identification: Identifies the "Drafts" folder in the mailbox.
  6. Draft Preparation: Compiles all the necessary information to create the draft, including the generated response, original email details, and specified recipient.
  7. Draft Uploading: Uploads the prepared draft email to the "Drafts" folder in the Fastmail mailbox.

Setup notes

The text below comes from the sticky notes inside the workflow. We removed links, code samples and anything that looks like a key or token.

Prerequisites

  1. IMAP Email Account: You need to configure an IMAP email account in n8n to monitor incoming emails.
  2. Fastmail API Credentials: A Fastmail account with JMAP API enabled. You should set up HTTP Header authentication in n8n with your Fastmail API credentials.
  3. OpenAI API Key: [redacted] API key from OpenAI to access GPT-4. Make sure to configure the OpenAI credentials in n8n.

Nodes in this workflow

The 9 nodes in file order (sticky notes excluded). Branches and connections determine execution order in n8n:

  1. Session (HTTP Request)
  2. Get Mailbox IDs (HTTP Request)
  3. Split Out (Split Out)
  4. Email Trigger (IMAP) (Email Trigger (IMAP))
  5. Get fields from source email (Edit Fields (Set))
  6. OpenAI (OpenAI)
  7. Filter for drafts folder (Filter)
  8. upload draft email (HTTP Request)
  9. gather data for draft email (Edit Fields (Set))

Credentials you need

  • HTTP Header Auth – used by Get Mailbox IDs, Session and upload draft email
  • IMAP – used by Email Trigger (IMAP)
  • OpenAI API – used by OpenAI

Configure your own credentials after importing. Create each credential in n8n, then select it in the node.

How to import into n8n

  1. Download the JSON file with the button above.
  2. In n8n, open a new workflow, select the ... menu and choose Import from File. You can also paste the JSON straight into the editor canvas.
  3. Open each node that shows a warning and select or create its credential.
  4. Read the notes on the canvas, test the workflow with sample data, then activate it.

Do you need somewhere to run it? Read our guide to self-hosted n8n.

Need this customised?

We can adapt this workflow to your apps, data and process, then deploy and support it.

Contact Us