See llms.txt for all machine-readable content.

Back to Templates

Reply to Arabic sales inquiries with Gmail and Ollama

Quick overview

This workflow monitors a Gmail inbox for unread messages from a specified sender, extracts and cleans the email content, uses an Ollama (Qwen) model to classify sales inquiries in Arabic and draft replies, and automatically replies in Gmail only when a reply draft is produced.

How it works

  1. Checks the Gmail inbox every minute for unread messages that match the configured sender filter.
  2. Extracts sender, subject, headers, and body text, cleans the content, and flags basic attributes like attachments and reply/forward status.
  3. Sends the cleaned email details to an Ollama chat model (qwen3.5:4b) to classify the message as action_required or follow_up and generate an Arabic reply draft when appropriate.
  4. Parses the model output into structured fields (category and replyDraft) and merges it back with the original Gmail metadata.
  5. Routes emails by category and continues only for action_required messages.
  6. Checks that replyDraft is not empty and replies to the original Gmail message with the generated Arabic text.

Setup

  1. Connect your Gmail account credentials for both the Gmail Trigger and the Gmail reply action, and ensure the connected account is the one that receives and replies to emails.
  2. In Gmail Trigger → Filters → Search, replace example.invalid with the full email address you will send test messages from. Keep the in:inbox and from: filters in place.
  3. Install and run Ollama, pull the qwen3.5:4b model, and set the Ollama Base URL in the Ollama connection so your n8n instance can reach it.
  4. Connect Ollama Chat Model and Structured Output Parser to the AI Email Classifier, then verify that a test run returns the category and replyDraft fields.
  5. Test with a sales inquiry and a “thank you” reply to confirm only action_required emails generate a Gmail reply and follow_up messages do not send anything.