# Rep Activity Digest

Pull each sales rep's recent activity from the CRM, compile it into a digest file, and notify sales leadership that it is ready.

## When to use

- A recurring cadence (daily, weekly) calls for a rep-activity summary.
- Sales leadership asks for an up-to-date view of rep pipeline movement.
- After a reporting period closes and activity needs to be reconciled into one file.
- Leadership requests an ad hoc snapshot of rep performance.

## Tools

- `http-get`: read activity, deal, and call/email log records per rep from the CRM.
- `shell-execute`: aggregate, dedupe, and compute per-rep metrics from the raw CRM data.
- `write-file`: save the compiled digest to a file.
- `send-message`: notify sales leadership that the digest is ready.

## Playbook

1. Confirm the reporting window (day, week, or custom range) and the list of reps to include.
2. Call the CRM REST API with `http-get` (e.g. GET https://api.hubapi.com/crm/v3/objects/deals) to pull each rep's activity records — calls, emails, deals updated, notes logged. Authentication is injected by the org's Integration row for this host — never ask for, echo, or hardcode credentials. If the call returns 401/403 or no Integration row exists, stop and message a human via `send-message` asking them to create the Integration, naming the service and required scopes.
3. Repeat the `http-get` calls as needed to page through results and cover every rep in scope.
4. Use `shell-execute` to normalize the raw activity payloads (JSON) into a per-rep table: counts of calls, emails, meetings, deals touched, and any stalled deals.
5. Use `shell-execute` to compute period-over-period deltas or flag reps with unusually low activity, if prior digest data is available for comparison.
6. Draft the digest as a clear, leadership-readable summary (per-rep breakdown plus a top-line rollup).
7. Save the digest with `write-file` to a dated file (e.g. `rep-activity-digest-<date>.md`).
8. Notify sales leadership via `send-message`, pointing to the digest file and calling out any standout findings (e.g. reps below activity threshold).
9. If any rep's underlying CRM record needs a correction (e.g. a stale field), do not attempt to modify it — compile the needed change into the digest's notes section and hand off to a human via `send-message`, since record updates require PATCH/PUT access this skill does not have.

## Failure modes

- 401/403 response from the CRM -> missing Integration; stop and escalate via `send-message` naming the service and required scopes.
- Empty or partial result set -> verify the endpoint, date range, and rep filter parameters before retrying.
- Rate limit hit while paging through activity -> back off and note the gap in the digest and in memory for the next run.
- CRM page or API shape has changed and expected fields are missing -> fall back to browser-search to confirm the current API documentation before resuming.

## Done when

- A digest file has been written via `write-file` covering every rep in scope for the period.
- Sales leadership has been notified via `send-message` with a link or reference to the digest.
- Any records needing correction beyond read access are clearly logged in the digest and handed off to a human rather than silently skipped.