Back to archive
IV. Client Builds & Logistics Platformssupportingsolo

Asterisk Call Sampler → Telegram QA

Despite the name — this is an Asterisk call-recording sampler for QA: it SSHes into a PBX server, reads CDR from MySQL (asteriskcdrdb), randomly picks 10–15 answered-call recordings from the last N hours, downloads them over SCP and posts the audio to Telegram with captions (time, src→dst, duration). A single file on Bun/TS, zero dependencies.

Status
prototype
Period
2026-04-18 → 2026-04-18
AI sessions
Stack
Languages
TypeScript
Frameworks · Infra
Bun
§01

Overview

  • What it is: A small ops utility for sampled QA of call-center calls on Asterisk. The name tg_invoice_listener is misleading (likely a legacy of bun init or a rename) — by the code this is a "call-recording QA sampler → Telegram".
  • Type / status / role: cli / ops script · prototype · solo (1 commit by the user).
  • Activity period: 2026-04-18 (one day, 1 commit).
§02

Stack

  • Bun + TypeScript, NO external dependencies — only Bun built-ins: Bun.$ (shell), Bun.file, Bun.env, native fetch/FormData. System sshpass for SSH/SCP over password.
  • Data source: Asterisk CDR (asteriskcdrdb MySQL), recording files under /var/spool/asterisk/monitor/YYYY/MM/DD/.
  • Delivery: Telegram Bot API (sendAudio, multipart FormData).
  • Config via env (SSH host/user/password, TG token/chat, lookback/sample parameters).
§03

What was shipped

  • A single commit (2026-04-18): a complete working index.ts script (176 lines).
  • Logic: fetchCandidates() (SQL over CDR: ANSWERED, billsec ≥ threshold, recording present, GROUP BY recordingfile, ORDER BY RAND() LIMIT), pickCount() (random 10–15), SCP download into a temp folder, sendAudio() with a formatted caption, tmp cleanup in finally, exit code based on result.
§04

Technical challenges

Confirmed by index.ts:

  • SSH/SCP automation by password (sshpass -e + strict -o options: host-key check disabled, password-auth only, timeout): access to a remote PBX without keys. → practical ops integration.
  • Random sampling for QA (ORDER BY RAND() + pickCount 10–15): a representative sample of recordings instead of all of them. → thoughtful QA approach.
  • Zero-dependency on Bun built-ins (Bun.$, Bun.file, native fetch/FormData): no node_modules dependencies, all I/O via the Bun runtime. → a modern, lightweight style.
  • Careful resources and errors: temp folder with PID+timestamp, guaranteed cleanup in finally, per-file try/catch, meaningful exit code (fail if nothing was sent). → reliability for cron runs.
  • `requireEnv` with an explicit error on a missing variable. → fail-fast config.
§05

AI-assisted development

  • Sessions found: 0. The repo has .claude/ (with a Bun guide in CLAUDE.md) and .cursor/ — AI tooling was used, but no Claude Code transcripts.
  • What was done with AI: likely generated/refined with Cursor/Claude (CLAUDE.md is the standard Bun guide).
  • AI-workflow patterns: minimal data.
§06

Achievements & metrics

  • Working ops utility: Asterisk CDR → SCP → Telegram, ~176 lines, zero deps.
  • Configurable sampling, safe cleanup, cron readiness.
§07

Contributors

git shortlog · all branches

  1. Dave931
1 contributor1 commits total
Currently

Open to Senior / Staff engineering roles and selective freelance — production AI, platform, and full-stack work.

Get in touch