Classify inbound email with OpenAI and route results to Slack using Make.com and Gmail. Build a reliable classifier, map labels, and send Block Kit alerts automatically.
Introduction
You get high-volume inbound email, triage it manually, and priorities slip. Someone has to read subject lines, identify support versus sales, and forward or notify the right channel. That costs time and introduces human error.
This guide shows how to classify inbound email with OpenAI and route the results to Slack using Make.com and Gmail. By the end you will have a working scenario that labels messages, applies rules, and posts clear Block Kit alerts into the right Slack channel.
What you will know by the end: how to wire Gmail into Make.com, send the email text to OpenAI for classification, apply simple routing logic, and post a formatted Slack message with the label and confidence.
What You'll Need
- Gmail account with either Google Cloud Pub/Sub push or IMAP access, depending on how you want to receive messages. For production use Gmail push via Pub/Sub is recommended.
- Make.com account with connections for Gmail (or IMAP), OpenAI, and Slack. A paid Make.com plan is recommended for reliability and higher execution quotas.
- OpenAI API key with access to a capable classification model. Budget for API usage and consider rate limits.
- Slack workspace where a bot token can post Block Kit messages into channels.
- Basic developer access to create a Google Cloud Pub/Sub topic if you choose push notifications.
How It Works (The Logic)
Trigger: Gmail notifies your endpoint of new emails (either via Pub/Sub push to a webhook that Make.com receives, or Make.com polls IMAP). Make.com extracts the email subject and body, sanitises it, and sends it to OpenAI for classification. OpenAI returns a label and confidence. Make.com applies a filter or switch to decide the destination Slack channel and message format, then posts a Block Kit message containing label, confidence, sender, brief summary, and a link to the thread.
Gmail (new email) → Make.com extracts text → OpenAI classification → Make.com routes by label → Slack Block Kit alert
Step-by-Step Setup
- Decide labels and success criteria
- Start small: use 4–6 labels, for example Support, Sales, Billing, Spam, Internal, and Other.
- For each label define a minimum confidence threshold (for example Support >= 0.80). Use these thresholds in your Make.com filters.
- Prepare sample emails for each label to validate classifier accuracy.
- Configure Gmail ingestion
Option A, recommended: Gmail push via Google Cloud Pub/Sub
- Create a Google Cloud project and Pub/Sub topic, enable Gmail API, and issue a watch request that targets the Pub/Sub topic according to Google’s Gmail Push docs.
- In Make.com create an HTTP webhook module to receive Pub/Sub push messages, or use a small intermediary that acknowledges Pub/Sub and forwards a simplified payload to Make.com. Remember Pub/Sub requires prompt ack to prevent retries.
Option B, simpler: Make.com Gmail or IMAP watch module
- Use Make.com’s Gmail watch messages or Email/IMAP watch module. This is simpler to set up but relies on polling and may have latency.
Common gotcha: Pub/Sub can deliver duplicate notifications. Include the Gmail historyId or messageId in your idempotency checks to avoid processing the same message twice.
- Extract the useful text in Make.com
- Add a module to fetch the full message if your trigger gives only metadata. Map subject, from, date, and a cleaned body (strip quoted thread history). For classification you usually send subject plus first 800–1,500 characters of the cleaned body to keep costs down.
- Field mapping examples:
- subject -> classification_input_subject
- from.address -> sender_email
- snippet or cleaned_body -> classification_input_body
Tip: remove signatures and previous replies. A simple regex to cut at common markers like "On .* wrote:" helps reduce noise.
- Add the OpenAI classification module
- Use Make.com’s OpenAI module, action "Create completion" or the dedicated classification call if available. Build a short prompt template that defines the label set and expects a JSON response.
Prompt pattern example (kept in Make as a single text mapping):
You are a classifier. Possible labels: Support, Sales, Billing, Spam, Internal, Other. Classify the email. Respond with JSON: {"label":"","confidence":<0-1>} Email subject: "{{subject}}" Email body: "{{cleaned_body}}"
- In the module options set temperature to 0 and request a structured JSON response. If you have evaluation data, consider fine-tuning or few-shot examples for better accuracy.
Common gotcha: models can hallucinate or return malformed JSON. Add a Make.com JSON parse step with fallback logic to catch parse errors and route those messages to a moderation channel.
- Parse the classification response and apply routing logic
- Add a JSON parse module to extract label and confidence.
- Add a Router or Switch module in Make.com with branches per label. In each branch add a filter: confidence >= your threshold for that label.
- For low-confidence results (below every threshold) route to a manual triage Slack channel and add the full text for a human to decide.
- Post a Block Kit Slack message
- Use Slack "Post message with blocks" module. Build a concise Block Kit payload containing:
- Section with bold label and confidence, e.g. Support • 0.92
- Section with email subject and sender
- Context block with a 1-2 sentence OpenAI summary if you also ask the model to summarise
- Actions block with a link button to open the original Gmail thread or a triage checklist URL
Message example fields to map:
- label -> top line
- confidence -> context
- sender_email -> context
- short_summary -> body
- gmail_thread_link -> button URL
Common gotcha: Slack rate limits on message posting. Batch or throttle alerts if your inbox is high volume and consider grouping multiple emails into a digest.
- Test, evaluate, and iterate
- Run labeled test emails through the flow, log predictions and confidence into a Google Sheet for analysis. Measure precision and recall for each label and adjust prompt examples or thresholds.
- Monitor OpenAI error rates and Make.com execution limits. For mission-critical routing add a fallback rule to notify humans when classification fails.
Real-World Business Scenario
An MSP used this flow to triage incoming support versus sales leads. Emails classified as Support went to the support Slack channel with the ticket template and a Create Ticket button. Emails classified as Sales posted to the sales channel with a high-confidence marker and the account owner. The MSP reduced manual triage by one full-time contractor and improved SLA response times during business hours.
Common Variations
- Add a summarisation step: ask OpenAI to return a one-sentence summary for faster triage in Slack.
- Create or tag tickets automatically: when label=Support and confidence >= 0.85, add a ticket in Zendesk or create a ClickUp task.
- Human-in-the-loop: route low confidence results to a triage Slack channel where a person confirms or corrects label, then feed corrections back as training examples.
Practical wrap-up
You built an intermediate Make.com scenario that watches Gmail, sends cleaned email text to OpenAI for classification, then routes results into Slack using Block Kit. Start with a small label set, measure precision, and add human fallback paths for low-confidence results.
If you want this built and maintained across your Gmail, OpenAI, and Slack workspace, Olmec Dynamics implements these automations for businesses and tunes classifiers for production. See what we offer at Olmec Dynamics (https://olmecdynamics.com).