d.deepak chauhanFULL STACK DEVELOPERLet’s talk
ONE PORTFOLIO. THREE PERSPECTIVES.

AI ENGINEERING / BY DEEPAK CHAUHAN

Async AI call transcription and analysis with OpenAI, Claude, and BullMQ

By Deepak Chauhan6 min read

Waiting on audio transcription and LLM summarization inside an HTTP request handler causes timeouts, blocks Node.js request capacity, and leaves partial results stranded if an upstream API drops. Moving the pipeline onto BullMQ workers with clear state transitions makes call analysis reliable and debuggable.

Keep webhook ingestion fast and enqueue background workers

Telephony webhooks and CRM call-logging endpoints expect quick 2xx acknowledgments. Performing audio downloads, OpenAI transcription, and Anthropic Claude summarization inline risks webhook retries and duplicate processing under load.

Persist an initial call record with status = 'queued', enqueue a BullMQ job keyed by callId so duplicate webhook deliveries coalesce, and return HTTP 202 immediately while dedicated workers handle downstream inference.

Idempotent BullMQ enqueue for call transcription and analysis

await callPipelineQueue.add(
  "process-call",
  { callId, recordingUrl, workspaceId },
  {
    jobId: `call-${callId}`,
    attempts: 4,
    backoff: { type: "exponential", delay: 3000 },
    removeOnComplete: { age: 3600, count: 500 },
  },
);

Separate raw transcription from structured LLM extraction

Storing the raw transcript in PostgreSQL before calling the reasoning model means transient LLM rate limits never force you to re-transcribe the audio file. Each stage becomes independently retryable and observable.

Define a strict TypeScript schema for extracted CRM fields—such as summary, action items, sentiment, and objections—and validate the model's JSON response before updating the call status to 'completed'.

  • Checkpoint the transcript first so stage-two retries skip audio transcription costs.
  • Fingerprint transcript + promptVersion before LLM calls to avoid duplicate token spend on replays.
  • Mark malformed audio or revoked workspace credentials as UnrecoverableError so workers fail fast.

References: OpenAI Speech to Text Guide · Anthropic Structured Outputs · BullMQ Retrying Failing Jobs

Expose deterministic pipeline states to the frontend

Instead of leaving users staring at an ambiguous spinner, model explicit call states in PostgreSQL: queued, transcribing, analyzing, completed, and failed. Recording stage timestamps and retry counts lets product teams inspect stuck calls immediately.

Pair state updates with the same PostgreSQL uniqueness and Redis rate-limiting patterns used across CRM automation pipelines so bursts of imported recordings stay within provider quotas.