Dev.to AI πŸ€– Ai πŸ‘ 0 πŸ“– 6 min read

I Built a Voice Fraud Step-Up Workflow with Telnyx

A caller can know the right account details, tell a convincing story, and sound exactly like the person they are pretending to be. That makes voice a useful interaction channel, but a weak standalone identity factor for

A caller can know the right account details, tell a convincing story, and sound exactly like the person they are pretending to be.

That makes voice a useful interaction channel, but a weak standalone identity factor for sensitive actions.

I built a TypeScript Telnyx code example that treats voice authenticity as one risk signal in a larger fraud workflow. The example protects a high-risk support request, such as a wire transfer, and chooses between proceeding, requiring a flashcall step-up, or routing the request to manual review.

The code example:

https://github.com/team-telnyx/telnyx-code-examples/tree/main/voice-fraud-step-up-agent

The video walkthrough:

https://youtu.be/DQ3RLClemqM

The Use Case

Imagine a customer calls a support line and asks to send $2,500 to an external account.

A simple voice workflow might ask the caller a question, accept a positive answer, and continue. That is not enough for a high-risk action. A fraudster can use a cloned voice, and a human-sounding voice still does not prove account ownership.

The safer workflow starts by opening a risk gate:

support request
  -> blocked pending
  -> voice-authenticity check
  -> policy decision
  -> proceed, step up, or human review
~~~

The gate is intentionally separate from the final business action. It determines what verification should happen next. It does not claim that the caller has been fully authenticated.

That separation also makes the demo easier to reason about. The caller experiences a normal phone interaction, while the application keeps the security decision in structured state. Support teams can see whether the request passed the voice screen, required a challenge, or needs a person to review it.

## What The Example Uses

The sample runs on Telnyx Edge Compute and uses:

- Telnyx Call Control to place the outbound call
- Telnyx Deepfake Detection to classify the remote-party audio
- Telnyx webhooks to deliver the result
- Embedded SQL storage for the per-account audit ledger
- Telnyx Verify flashcall as an optional step-up
- Call Control speech for deterministic prompts and verdicts

The live path does not start an autonomous AI Assistant after detection. That choice is deliberate. The policy result should come from code and stored state, not from a model improvising a message to the caller.

## Opening The Risk Gate

The actor receives a sensitive action such as a wire transfer request and records the initial state:

~~~plaintext
blocked_pending β€” request opened
~~~

That state is intentional. The request does not begin in an approved state while the phone call is still waiting for a result.

## Enabling Deepfake Detection

The outbound Call Control request includes Deepfake Detection:

~~~ts
deepfake_detection: {
  enabled: true,
  timeout: 30,
}
~~~

The request also carries client state containing the account ID. When the webhook arrives, the Edge function decodes that state and routes the result to the correct account actor.

The call continues while the detection service evaluates the remote-party audio. The caller hears a short verification prompt through Call Control speech:

~~~plaintext
This call includes a voice-authenticity screen, not identity verification.
Please state your name and confirm whether you requested the two thousand five
hundred dollar wire transfer on this account.
~~~

The wording is intentionally explicit. The caller is told that the call is checking voice authenticity, not proving account ownership.

## Applying The Result

Telnyx sends a result such as:

~~~plaintext
real
fake
silence_timeout
~~~

The policy combines that result with recent ledger history.

A clean real result returns:

~~~plaintext
proceed
~~~

That means the voice-authenticity policy passed and the workflow can continue to an independent identity factor.

A fake result returns a flashcall step-up when the Verify profile is configured. A recent risky ledger event can also force the step-up even if the latest audio appears human.

A silence_timeout or provider error returns manual review. The workflow fails closed when the signal is missing or inconclusive.

The resulting ledger is easy to inspect:

~~~plaintext
blocked_pending β€” request opened
proceed         β€” human-sounding voice result and clean recent ledger
~~~

The word proceed is not the same as identity verified. It means the policy has allowed the next stage.

## Why The Ledger Matters

A fraud decision should be explainable after the call ends.

The actor stores request and outcome rows in embedded SQL. That provides a durable audit trail for questions such as:

- Which account opened the request?
- Which call produced the result?
- Was the result real, fake, or inconclusive?
- Was there a recent risky event?
- Did the workflow proceed, step up, or go to review?

This also gives the application memory across restarts. A later request can see that the account had a recent risky event and require another factor instead of evaluating the newest call in isolation.

## Deterministic Call Messages

The sample originally used an assistant to deliver the post-detection result. The live path now uses Call Control speech instead.

That is a small but important reliability decision. The code chooses the exact message from the policy outcome:

~~~plaintext
proceed
  -> the voice passed the synthetic-voice screen

step_up_flashcall
  -> additional verification is required

manual_review
  -> a specialist will review the request
~~~

The caller hears the same outcome that appears in the ledger. There is no second autonomous decision layer between the policy and the message.

## Running The Example

Start with local validation:

~~~bash
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/voice-fraud-step-up-agent
npm install
cp .env.example .env
npm run typecheck
npm run smoke
~~~

The smoke test exercises the policy locally and does not place a call or send a verification message.

For a live run, configure the Edge secrets and target a phone you control:

~~~bash
npm run demo:live
~~~

The local monitor prints the Call Control payload with the target number masked. The API key remains in the deployed Edge function.

## Production Boundaries

This sample is a policy pattern, not a complete identity system.

A production implementation should:

- Add an independent identity factor before completing a sensitive action
- Limit repeated attempts and step-up retries
- Retain ledger data according to the organization’s security policy
- Avoid putting secrets or full phone numbers in logs
- Route uncertain detection results to trained reviewers
- Add account-level velocity and transaction-risk signals
- Keep the voice-authenticity result separate from authorization

The most important boundary is simple: a human-sounding voice is not proof of account ownership.

## Frequently Asked Questions

### Does a real Deepfake Detection result verify the caller?

No. It means the audio appeared human to the detector. The application still needs an independent identity factor.

### What happens when the result is fake?

The policy can trigger a Telnyx Verify flashcall step-up when a Verify profile is configured.

### What happens when detection times out?

The sample fails closed to manual review instead of allowing the sensitive action.

### Why use a durable Edge actor?

The actor gives each account a place to store its pending action, recent risk history, and audit ledger so the next request can use that context.

### Does the live call use an AI Assistant?

No. The live path uses deterministic Call Control speech for the prompt and final verdict.

## Resources

- Code example: https://github.com/team-telnyx/telnyx-code-examples/tree/main/voice-fraud-step-up-agent
- Video walkthrough: https://youtu.be/DQ3RLClemqM
- Deepfake Detection: https://telnyx.com/products/deepfake-detection
- Verify API: https://telnyx.com/products/verify-api
- Stateful Edge Functions: https://telnyx.com/resources/stateful-edge-functions
- Embedded SQL for Edge Functions: https://telnyx.com/resources/serverless-sql-database-edge-functions
πŸ“° Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.