DEV Community

Sonam
Sonam

Posted on

Build an Edge Backend for a Telnyx AI Assistant

Voice AI demos get interesting when the assistant needs real backend context.

It is one thing to have an assistant answer a call. It is another thing to have that assistant greet the caller with dynamic context, collect information, call a backend tool, and read a confirmation back during the same phone call.

This Go example shows how to use one Telnyx Edge Compute function as the backend for a Telnyx AI Assistant.

Code: https://github.com/team-telnyx/telnyx-code-examples/tree/main/edge-ai-assistant-backend-go

Full guide: https://developers.telnyx.com/docs/edge-compute/guides/ai-assistant-backend

What it does

The app is a Go Edge Compute function with one public URL.

That one URL handles two AI Assistant callbacks:

  • dynamic variables at call start
  • a webhook tool call during the conversation

In the demo, the assistant is a home-services lead screener. It can resolve a company name for the greeting, then call a schedule_estimate webhook tool after collecting enough information from the caller.

Why I like this pattern

Usually, the moment an AI assistant needs application context, you need to build a webhook server.

That means hosting, deployment, secrets, request verification, and a public URL.

With Edge Compute, that backend can live close to the Telnyx communications layer. You deploy a function, store secrets, and point the assistant callbacks to the function URL.

No separate server. No Docker setup. No Kubernetes just to answer a webhook.

The important pieces

The handler does three useful things:

  1. verifies Telnyx Ed25519 signatures
  2. dispatches based on request body shape
  3. returns the right JSON format for either dynamic variables or tool results

Dynamic variables must be returned under a dynamic_variables key:

{
  "dynamic_variables": {
    "company_name": "Pinecrest Home Services",
    "timeframe": "two business days"
  }
}
Enter fullscreen mode Exit fullscreen mode

The webhook tool returns data the assistant can use in the live conversation:

{
  "scheduled_date": "2025-04-10",
  "scheduled_time": "10:00",
  "confirmation_number": "CONF-1715234567",
  "estimate_id": "EST-1715234567"
}
Enter fullscreen mode Exit fullscreen mode

Run it

Scaffold a Go function:

telnyx-edge new-func -l go -n edge-ai-assistant-backend
cd edge-ai-assistant-backend
Enter fullscreen mode Exit fullscreen mode

Fetch your Telnyx public key and store it as an Edge secret:

PUBLIC_KEY=$(curl -s -H "Authorization: Bearer $TELNYX_API_KEY" \
  https://api.telnyx.com/v2/public_key | jq -r '.data.public')

telnyx-edge secrets add TELNYX_PUBLIC_KEY "$PUBLIC_KEY"
Enter fullscreen mode Exit fullscreen mode

Deploy:

telnyx-edge ship
telnyx-edge list
Enter fullscreen mode Exit fullscreen mode

Then configure your AI Assistant so both the dynamic variables webhook URL and the schedule_estimate webhook tool URL point to the same Edge Compute invoke URL.

The full setup is in the guide: https://developers.telnyx.com/docs/edge-compute/guides/ai-assistant-backend

Where this could go

This example uses a scheduling flow, but the backend pattern applies to:

  • order status lookups
  • appointment booking
  • account verification
  • lead qualification
  • dynamic greetings
  • warm transfer decisions
  • support ticket creation

The core idea is simple: keep the assistant conversational, and put the callback logic at the edge.

Resources

Edge Compute quickstart: https://developers.telnyx.com/docs/edge-compute/quickstart

AI Assistant dynamic variables: https://developers.telnyx.com/docs/inference/ai-assistants/dynamic-variables

Webhook signing: https://developers.telnyx.com/development/api-fundamentals/webhooks/receiving-webhooks#webhook-signing

Telnyx AI skills and toolkits: https://github.com/team-telnyx/ai

Top comments (0)