cookbook · Extractor · Support and CRM records
Turn a support email into a ticket
A support email has everything a ticket needs, buried in prose: who wrote, which order, what went wrong, and what they want. This recipe fills a ticket record from one email, with the issue type picked from your own list, the delivery date resolved from 'last Thursday' using reference_date, and the tracking number left null because the customer never gave one.
Request
POST /v1/extract, documented in the Extractor reference.
curl https://meragpt.com/v1/extract \
-H "Authorization: Bearer $MERAGPT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "extractor-1",
"reference_date": "2026-11-24",
"text": "Subject: Order 77-31094 arrived broken\n\nHi there,\n\nMy order (#77-31094) was delivered last Thursday but the glass carafe in the coffee set was shattered when I opened the box. The rest of the set is fine. I'\''ve attached a photo. I'\''d rather have a replacement carafe than a refund if you have one in stock, otherwise refund the carafe please.\n\nThanks,\nPriya Raman\npriya.raman@fastmail.com",
"schema": {
"type": "object",
"properties": {
"customer_name": {
"type": "string"
},
"customer_email": {
"type": "string"
},
"order_id": {
"type": "string"
},
"issue_type": {
"type": "string",
"enum": [
"damaged",
"missing",
"wrong_item",
"late",
"billing",
"other"
]
},
"delivered_on": {
"type": "string",
"format": "date"
},
"affected_items": {
"type": "array",
"items": {
"type": "string"
}
},
"wants": {
"type": "string",
"enum": [
"replacement",
"refund",
"either",
"unclear"
],
"description": "What the customer asks for first."
},
"tracking_number": {
"type": "string"
}
}
}
}'What came back
The real output from running this recipe, unedited.
{
"customer_name": "Priya Raman",
"customer_email": "priya.raman@fastmail.com",
"order_id": "77-31094",
"issue_type": "damaged",
"delivered_on": "2026-11-20",
"affected_items": [
"glass carafe"
],
"wants": "replacement",
"tracking_number": null
}Python
import os, requests
API = "https://meragpt.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MERAGPT_API_KEY']}"}
from datetime import date
email = open("email.txt").read()
schema = {
"type": "object",
"properties": {
"customer_name": {
"type": "string"
},
"customer_email": {
"type": "string"
},
"order_id": {
"type": "string"
},
"issue_type": {
"type": "string",
"enum": [
"damaged",
"missing",
"wrong_item",
"late",
"billing",
"other"
]
},
"delivered_on": {
"type": "string",
"format": "date"
},
"affected_items": {
"type": "array",
"items": {
"type": "string"
}
},
"wants": {
"type": "string",
"enum": [
"replacement",
"refund",
"either",
"unclear"
],
"description": "What the customer asks for first."
},
"tracking_number": {
"type": "string"
}
}
}
r = requests.post(f"{API}/extract", headers=HEADERS, json={
"model": "extractor-1",
"text": email,
"schema": schema,
"reference_date": date.today().isoformat(), # resolves "last Thursday"
}).json()
ticket = r["data"]
queue = {"damaged": "returns", "missing": "logistics", "wrong_item": "returns"}.get(ticket["issue_type"], "general")
print(queue, ticket["order_id"], ticket["wants"])
TypeScript
const API = "https://meragpt.com/v1";
const headers = {
Authorization: `Bearer ${process.env.MERAGPT_API_KEY}`,
"Content-Type": "application/json",
};
import { readFileSync } from "node:fs";
const schema = {
"type": "object",
"properties": {
"customer_name": {
"type": "string"
},
"customer_email": {
"type": "string"
},
"order_id": {
"type": "string"
},
"issue_type": {
"type": "string",
"enum": [
"damaged",
"missing",
"wrong_item",
"late",
"billing",
"other"
]
},
"delivered_on": {
"type": "string",
"format": "date"
},
"affected_items": {
"type": "array",
"items": {
"type": "string"
}
},
"wants": {
"type": "string",
"enum": [
"replacement",
"refund",
"either",
"unclear"
],
"description": "What the customer asks for first."
},
"tracking_number": {
"type": "string"
}
}
};
const r = await fetch(`${API}/extract`, {
method: "POST",
headers,
body: JSON.stringify({
model: "extractor-1",
text: readFileSync("email.txt", "utf8"),
schema,
reference_date: new Date().toISOString().slice(0, 10),
}),
}).then((res) => res.json());
console.log(r.data.issue_type, r.data.order_id, r.data.wants);
When to trust it
All eight fields came back right, including the date: with reference_date set to Monday 24 November 2026, 'last Thursday' became 2026-11-20. Always send reference_date when emails talk in relative dates. The issue type is constrained to your enum, so it is safe to route on; a free-text field like affected_items is worth showing to the agent rather than acting on alone.
Try it without code in the playground, or see more Extractor recipes: read an invoice into your ap system, pull the key terms out of a contract, get action items out of meeting notes, turn a receipt photo into an expense entry, extract memories from a conversation.