Most business automation articles about AI stop at "and then you call the API." This one doesn't. We're going through actual implementation patterns for real workflows — the kind your business runs every day — with working Python code you can adapt.
Setup: Get Running in 5 Minutes
# Set your API key
export ANTHROPIC_API_KEY="your-key-here"
client = anthropic.Anthropic()
# Basic call
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Summarize this email in 2 sentences."}]
)
print(message.content[0].text)
Automation Pattern 1: Document Classification and Routing
One of the highest-ROI applications: automatically classifying inbound documents (emails, support tickets, contracts, invoices) and routing them to the right team or workflow.
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=256,
system="""Classify the document and return JSON with:
- type: one of [invoice, contract, support_ticket, complaint, inquiry]
- priority: one of [high, medium, low]
- department: one of [finance, legal, support, sales]
- summary: one sentence
Return only valid JSON, no explanation.""",
messages=[{"role": "user", "content": text}]
)
import json
return json.loads(response.content[0].text)
# Usage
result = classify_document(email_body)
route_to_team(result["department"], result["priority"])
Automation Pattern 2: Contract Review and Risk Flagging
Claude's 200K token context window makes it uniquely suited for contract analysis. You can pass an entire contract in one call and get a structured risk assessment back.
response = client.messages.create(
model="claude-opus-4-6", # Use Opus for high-stakes reasoning
max_tokens=2048,
system="""You are a legal contract analyst. Review the contract and return JSON with:
- risk_level: high/medium/low
- red_flags: list of concerning clauses with page references
- missing_clauses: standard clauses that are absent
- recommended_changes: list of suggested modifications
- summary: 2-3 sentence executive summary""",
messages=[{"role": "user", "content": contract_text}]
)
return json.loads(response.content[0].text)
Automation Pattern 3: Customer Support Draft Generation
Feed Claude a support ticket plus your knowledge base, get back a draft response in your company's voice. Human agent reviews and sends — dramatically reducing handle time.
kb_context = "\n\n".join(kb_articles[:5]) # Top 5 relevant articles
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=512,
system=f"""You are a customer support agent for Acme Corp.
Tone: professional, empathetic, solution-focused.
Never make up information not in the knowledge base.
If you can't fully resolve from the KB, acknowledge and escalate.
Knowledge Base:
{kb_context}""",
messages=[{"role": "user", "content": f"Support ticket:\n{ticket}"}]
)
return response.content[0].text
Automation Pattern 4: Structured Data Extraction
Extracting structured data from unstructured documents — invoices, resumes, research papers, news articles — is one of Claude's most reliable capabilities.
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=512,
system="""Extract invoice data and return JSON:
{vendor, invoice_number, date, due_date, line_items: [{description, qty, unit_price, total}], subtotal, tax, total_amount, payment_terms}
Use null for missing fields. Return only JSON.""",
messages=[{"role": "user", "content": invoice_text}]
)
return json.loads(response.content[0].text)
Production tip: Always validate Claude's JSON output with a schema library like Pydantic before passing it downstream. Add retry logic with exponential backoff for API errors. For high-volume pipelines, use the Batches API to cut costs by 50% on non-latency-sensitive workloads.
Automation Pattern 5: Meeting Summary and Action Item Extraction
Feed Claude a transcript, get back a structured summary with action items, owners, and deadlines — ready to post to Slack or your project management tool.
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="""Process the meeting transcript and return JSON with:
- summary: 3-5 bullet points of key discussion points
- decisions: list of decisions made
- action_items: [{task, owner, due_date, priority}]
- follow_up_required: boolean
Use null for due_date if not mentioned.""",
messages=[{"role": "user", "content": transcript}]
)
return json.loads(response.content[0].text)
Choosing the Right Claude Model
- claude-haiku-4-5 — fastest, cheapest. Good for simple classification, short summaries, high-volume pipelines where speed matters.
- claude-sonnet-4-6 — the sweet spot. Excellent quality at reasonable cost. Use this as your default for most business automation.
- claude-opus-4-6 — maximum reasoning. Use for high-stakes decisions: contract review, compliance analysis, complex multi-step reasoning. Worth the premium.
Want These Patterns Deployed in Your Business?
We build production-grade Claude integrations that connect to your existing systems — CRM, ERP, ticketing, documents. Deployed, not just demoed.
Talk to the Team