Skip to content
Notifications
Clear all

Guide: Automating sales report summaries with Claude and our CRM

1 Posts
1 Users
0 Reactions
4 Views
(@devops_dad_v2)
Estimable Member
Joined: 4 months ago
Posts: 122
Topic starter   [#2952]

We've been using Claude to automate a tedious daily task for our sales team: generating summary reports from our CRM data. It replaced a manual process that was taking a lead engineer 30-45 minutes each morning. Now it's a zero-touch, scheduled workflow that's been running reliably for months.

The core pattern is simple: a scheduled job pulls raw data via the CRM API, formats it into a prompt for Claude, parses the structured output, and posts it to a Slack channel. The real value came from hardening the pipeline.

Here's the basic workflow we built with Terraform and a Kubernetes CronJob, using the Anthropic API:

```hcl
# CronJob definition (Terraform k8s provider)
resource "kubernetes_cron_job_v1" "sales_summary" {
metadata {
name = "claude-sales-summary"
namespace = "automation"
}
spec {
schedule = "30 8 * * 1-5" # 8:30 AM on weekdays
job_template {
spec {
template {
spec {
container {
name = "summary-generator"
image = "our-registry/summary-bot:latest"
env {
name = "ANTHROPIC_API_KEY"
value_from {
secret_key_ref {
name = "anthropic-secrets"
key = "api-key"
}
}
}
# ... CRM credentials, Slack webhook
}
}
}
}
}
}
}
```

The key was crafting a precise system prompt and asking for structured JSON output:

```text
System: You are a sales analyst summarizing key metrics from raw data.
Human: Given the following JSON array of deal records for yesterday, output a JSON object with:
1. A 'summary' string (3 sentences max).
2. A 'top_deals' array (max 3 deals with 'name' and 'amount').
3. A 'risk_alert' string if any deal is stalled over 30 days.

Raw Data: {sales_data}
```

Battle-tested patterns we learned:
* **Idempotency & Retry Logic:** The script saves the raw API response to S3 with a date-key before processing. If Claude's API call fails, it retries with exponential backoff using the saved data.
* **Cost Control:** We initially used `claude-3-opus` but found `claude-3-haiku` provided nearly identical quality for this structured summarization task at a fraction of the cost.
* **Validation:** The container includes a JSON schema validation step (using a Python `jsonschema` lib) on Claude's output before posting to Slack. Invalid outputs trigger an alert to us, not the sales team.
* **Fallback:** If the Anthropic API is unreachable after retries, a bare-minimum summary is generated from a simple template. Silence is not an option for a daily report.

The result is a 95% reduction in engineering time spent on this task, and the sales team gets a consistent, formatted summary waiting for them when they start their day. The pipeline's reliability comes from treating the LLM call as a potentially flaky component in an otherwise robust system.



   
Quote