Classificateur d’intention de courriel
Les équipes de support, les CRM et les automatisations de service d’assistance reçoivent des milliers de courriels par jour, et les acheminer un par un à la main ne passe pas à l’échelle. Ce prompt transforme n’importe quel courriel entrant en une classification structurée : une intention unique, un score de confiance, un résumé en une phrase, un ton de réponse suggéré et un indicateur de suivi humain. Il est conçu pour les files de tri qui attribuent automatiquement les billets, rédigent les premières réponses ou font remonter les clients mécontents avant qu’ils ne partent. Attention aux pièges : les plaintes polies se cachent souvent derrière un simple « petite question rapide », les demandes de désinscription sont parfois enfouies dans un paragraphe amical, et un courriel de marketing peut ressembler à une vraie demande. Le score de confiance existe précisément pour cette ambiguïté : acheminez automatiquement les courriels à haute confiance et envoyez tout ce qui est sous votre seuil vers une file humaine plutôt que de deviner.
Prompt système
You are an email intent classifier. Read the email below and return a single JSON object that matches the provided schema exactly. Classify the email's primary intent as one of: question, complaint, request, feedback, spam, unsubscribe. Choose the single best fit; if the email is clearly unsolicited bulk mail or a phishing attempt, use spam. Set confidence to a number between 0 and 1 reflecting how certain you are about the intent. Write summary as one concise sentence capturing what the sender wants. Choose suggested_reply_tone from friendly, formal, apologetic: use apologetic when the sender is upset or something went wrong, formal for official or legal matters, friendly otherwise. Set needs_follow_up to true when a human must act or reply beyond a simple acknowledgement, otherwise false. Rules: - Output only the JSON object, with no extra text, no markdown fences, and no commentary. - Extract the best value present in the email. Do not invent details that are not in the email. - If a required field cannot be determined from the email, do not produce any output. - The summary must be a single sentence and must not be empty.
Schéma JSON brut
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "EmailIntent",
"type": "object",
"additionalProperties": false,
"required": ["intent", "confidence", "summary", "suggested_reply_tone", "needs_follow_up"],
"properties": {
"intent": {
"type": "string",
"enum": ["question", "complaint", "request", "feedback", "spam", "unsubscribe"]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"summary": {
"type": "string",
"minLength": 1
},
"suggested_reply_tone": {
"type": "string",
"enum": ["friendly", "formal", "apologetic"]
},
"needs_follow_up": {
"type": "boolean"
}
}
}
Zod (TypeScript)
import { z } from "zod";
export const EmailIntentSchema = z.strictObject({
intent: z.enum(["question", "complaint", "request", "feedback", "spam", "unsubscribe"]),
confidence: z.number().min(0).max(1),
summary: z.string().min(1),
suggested_reply_tone: z.enum(["friendly", "formal", "apologetic"]),
needs_follow_up: z.boolean(),
});
export type EmailIntent = z.infer<typeof EmailIntentSchema>;
Pydantic v2 (Python)
from pydantic import BaseModel, ConfigDict, Field, field_validator
from typing import Literal
class EmailIntent(BaseModel):
model_config = ConfigDict(extra="forbid")
intent: Literal["question", "complaint", "request", "feedback", "spam", "unsubscribe"]
confidence: float = Field(..., ge=0, le=1)
summary: str = Field(..., min_length=1)
suggested_reply_tone: Literal["friendly", "formal", "apologetic"]
needs_follow_up: bool
@field_validator("summary", mode="before")
@classmethod
def _strip_summary(cls, v):
if not isinstance(v, str):
return v
return v.strip()