Skip to content

feat: add Edge Robo-Call Screener example (TypeScript Stateful Actor) - #70

Open
sonamg-droid wants to merge 1 commit into
mainfrom
feat/edge-robo-call-screener-typescript
Open

feat: add Edge Robo-Call Screener example (TypeScript Stateful Actor)#70
sonamg-droid wants to merge 1 commit into
mainfrom
feat/edge-robo-call-screener-typescript

Conversation

@sonamg-droid

Copy link
Copy Markdown
Contributor

What

New example: Edge Robo-Call Screener — inbound call screener on Telnyx Edge Compute Stateful Actors. Answers calls, asks a screening question, AI judges if it's a robocall, hangs up on robocalls and forwards legitimate callers.

Why

First TypeScript example in the repo using Edge Compute Stateful Actors — demonstrates the stateful actor pattern with durable per-number storage. No ngrok needed; runs at *.telnyxcompute.com. Solves a real problem (robocalls) using Voice API + AI Inference together.

What's included

  • edge-robo-call-screener-typescript/ — TypeScript project with src/index.ts (fetch handler), src/callScreener.ts (StatefulActor), telnyx.toml (actor binding), package.json, tsconfig.json, README/API.md/GUIDE.md, .env.example
  • Uses Call Control (answer, gather using speak, hangup, transfer, reject) + AI Inference (chat completions for robocall judgment)
  • @telnyx/edge-runtime@0.8.0 — includes StatefulActor exports

How it works

  1. Caller dials your number → Telnyx sends call.answered webhook to Edge
  2. Actor checks blocklist (durable storage) → reject if blocked
  3. Answer + gather (TTS question + STT) → call.gather.ended webhook
  4. AI Inference judges the transcript (robocall/legitimate/unknown)
  5. Robocall (confidence ≥ 0.7) → hang up + blocklist. Legitimate → transfer.

Stateful Actor

  • One CallScreener instance per screened phone number
  • Durable storage: blocklist, call history (50 most recent), cumulative stats
  • Persists across invocations without a database

Endpoints

  • POST /webhooks/voice — Telnyx voice webhook target
  • GET /stats — cumulative screening stats
  • GET /calls — recent call records
  • POST /blocklist/clear — clear the blocklist
  • GET /health/{liveness,readiness} — health checks

Infrastructure changes

  • Updated scripts/verify.py to accept telnyx.toml as a valid code file for edge examples (alongside existing func.toml support). This is needed for stateful actor projects which use telnyx.toml instead of func.toml.

Registry

  • Added entry to scripts/examples_mapping.yaml (product: voice, language: nodejs, framework: edge)
  • Regenerated llms.txt and catalog.json via scripts/gen_llms_txt.py

Verification

  • npx tsc --noEmit → 0 errors (with @telnyx/edge-runtime@0.8.0)
  • scripts/verify.py --only edge-robo-call-screener-typescript → 0 errors
  • scripts/gen_llms_txt.py --check → PASS

Inbound call screener deployed on Telnyx Edge Compute Stateful Actors.
Answers calls, asks a screening question via TTS, gathers speech via
STT, then AI Inference judges if it's a robocall. Hangs up on robocalls
(and auto-blocklists the caller), forwards legitimate callers to your
phone. Per-number actor instance with durable storage for blocklist,
call history, and stats. No ngrok needed — runs at *.telnyxcompute.com.

Files: src/index.ts (fetch handler + webhook routing), src/callScreener.ts
(StatefulActor), telnyx.toml (actor binding), package.json, tsconfig.json.
Uses Call Control (answer, gather, hangup, transfer, reject) + AI Inference.

Also updates scripts/verify.py to accept telnyx.toml as a valid code file
for edge examples (alongside existing func.toml support).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant