Production pattern: LangGraph Inbox-to-CRM agent with Slack human-in-the-loop approval (Next.js + Postgres)

Hey everyone — wanted to share an architecture pattern that worked well for a recent production build, especially around preventing an agent from sending bad emails or corrupting CRM records.

The Problem
A revenue ops team had a shared inbox piling up with inbound leads. Simple LLM auto-responders were too risky because wrong pricing or duplicate CRM entries created more cleanup work than typing manually.

The Stack

  • Orchestration: LangGraph (stateful graph with Postgres checkpointer)
  • UI / Review Queue: Next.js dashboard + Slack interactive webhooks
  • Tools: Typed CRM lookup/upsert tools + enrichment API

How the Graph Is Structured

  1. Ingest & Deduplicate: Normalizes the inbound thread and checks Postgres so duplicate webhooks don’t trigger double runs.
  2. Enrich & Match: Looks up sender domain and existing CRM contact/deal state using strict Pydantic input schemas.
  3. Draft & Interrupt (interrupt_before): Generates the CRM field updates and a proposed reply, then hits a LangGraph interrupt before any write/send tool executes.
  4. Human Approval Gate: Pushes a summary card to Slack and a lightweight Next.js review screen. A human approves, edits, or rejects, which resumes the thread from the Postgres checkpoint.

3 Guardrails That Saved Us in Production

  • Hard per-thread token & step caps: Prevents retry loops when an upstream CRM API throws a 429 or 500.
  • Read-only vs. Write tool separation: Enrichment tools run automatically; any tool that mutates CRM state or sends an email lives behind the interrupt boundary.
  • Full step audit log: Every tool input/output is logged to Postgres so when a prompt drifts, we can replay the exact state.

I wrote up the full breakdown, state flow, and lessons learned here if anyone is building something similar:
:backhand_index_pointing_right: Full Inbox-to-CRM write-up on AgentCrafts

Happy to share the checkpointing setup or how we structured the Pydantic tool schemas if anyone is working through human-in-the-loop patterns in LangGraph!