Interview Completion → SQS → Settlement + Report Enqueue
Bot marks the interview complete or failed; async settlement finalizes credits and enqueues report generation once.
Sequence
sequenceDiagram autonumber participant Bot as Interview bot participant API as Hono API participant BotSvc as bot-interview.service participant SQS1 as SQS interview-completed participant Lambda as interview-completed handler participant Settle as settlement.service participant Credits as credit.service participant SQS2 as SQS report-generate participant Mongo as MongoDB Bot->>API: POST /v1/bot/interviews/:id/complete BotSvc->>Mongo: status COMPLETED + timing BotSvc->>SQS1: publishInterviewCompleted SQS1->>Lambda: message Lambda->>Settle: settleCompletedInterview Settle->>Mongo: claim settledAt (idempotent) Settle->>Credits: settleCreditsInSession Settle->>SQS2: publishReportGenerate (first claim only)
Steps
- Bot posts complete (or fail) with timing; API updates terminal status and publishes to SQS.
- Lambda consumes the message and runs settlement for completed or failed interviews.
- Settlement claims
settledAtonce—duplicate deliveries skip without double-charging or double enqueue. - Completed path bills consumed minutes, releases unused reservation, and enqueues report generation on first claim only.
- Failed path releases the full reservation with zero consumption.