Skip to content

Recipe: Echo Agent and a Status Poller

Two small recipes for a team that is wiring Wetel into its own product. The first builds an echo agent that answers without calling a model, so you can test the call path (start, join, speak, transcript) with a predictable reply. The second is a Go smoke program that polls the Platform Status API and checks that its answer has the documented shape.

The agent greets the caller, says it is a test assistant and repeats what it heard. Its workflow is two nodes, start and one response node, so no model runs: the reply is a template rendered from the caller’s words. That makes it useful for checking the plumbing of a voice call or a chat integration without model latency or model variance in the way.

Every call uses a dashboard login: Authorization: Bearer <jwt> and x-huat-platform: customer (see Authentication).

flowchart LR
start([start]) --> echo[echo: response]
mutation CreateAgent($input: CreateAgentInput!) {
createAgent(input: $input) {
id
}
}
{
"input": {
"name": "Echo Test Assistant",
"position": "Test Agent",
"useCase": "SUPPORT",
"personaPrompt": "A test assistant that repeats what it hears."
}
}

Assume the id is 61. The personaPrompt is not used by the workflow below; it only describes the agent in the dashboard.

mutation CreateWorkflow($input: CreateWorkflowInput!) {
createWorkflow(input: $input) {
id
}
}
{
"input": {
"name": "Echo test",
"description": "Replies with a fixed greeting and the caller's own words. No model call."
}
}

Assume the id is 42. Save the graph:

mutation UpdateWorkflow($input: UpdateWorkflowInput!) {
updateWorkflow(input: $input) {
id
}
}
{
"input": {
"id": 42,
"nodes": [
{
"id": "start",
"type": "start",
"label": "Start",
"config": {},
"position": { "x": 0, "y": 0 }
},
{
"id": "echo",
"type": "response",
"label": "Greet and repeat",
"config": {
"messageTemplate": "Hello, I am an AI test assistant. I heard: {{userMessage}}",
"mood": "neutral"
},
"position": { "x": 0, "y": 100 }
}
],
"edges": [{ "id": "e1", "source": "start", "target": "echo" }]
}
}
  • {{userMessage}} is the text of the turn being answered. On a voice call the agent sends a first turn when the caller joins, and the workflow’s reply to it is the greeting, so the caller hears “I heard:” followed by that opening turn. That is expected for a test agent; see Voice-safe workflows.
  • The reply says that it is an AI, as a voice agent’s first sentence should.
  • Keep replies short: they are spoken.
mutation PublishWorkflow($id: Int!) {
publishWorkflow(id: $id) {
id
isPublished
version
}
}
{ "id": 42 }
mutation AttachWorkflow($id: ID!, $input: UpdateAgentInput!) {
updateAgent(id: $id, input: $input) {
id
workflowId
}
}
{ "id": "61", "input": { "workflowId": 42 } }

If the agent seems to ignore the graph, check that isPublished came back true; see Wiring up a workflow.

  1. Chat first. Start a session with sdkStart for agent 61, send “testing one two”, and expect Hello, I am an AI test assistant. I heard: testing one two.
  2. Then a call. Start a call with sdkStartVoiceCall and join it as in Start a call from your app. Speak, and read the lines in the lk.transcription text stream.

If the chat reply is right and the call is silent, the problem is in the call path (token, join, worker), not in the agent. Test one call at a time; see Capacity on the test environment.

This program polls GET /status/v1 every 30 seconds, treats a 503 with a body as an unavailable answer, honours Retry-After on 429, and reports “hide Wetel-dependent features” only after two consecutive unavailable answers, as the polling guidance recommends. It validates the schema version, the five component names and that the HTTP code agrees with the overall status, so it doubles as a smoke test: run it once against a new environment and read the first line.

package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"time"
)
type statusBody struct {
SchemaVersion int `json:"schemaVersion"`
Status string `json:"status"`
CheckedAt string `json:"checkedAt"`
Components map[string]string `json:"components"`
}
var validState = map[string]bool{
"operational": true, "degraded": true, "unavailable": true, "unknown": true,
}
// check calls GET /status/v1 once and verifies the shape and the status code.
func check(ctx context.Context, base string) (statusBody, time.Duration, error) {
var body statusBody
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, base+"/status/v1", nil)
if err != nil {
return body, 0, err
}
res, err := http.DefaultClient.Do(req)
if err != nil {
return body, 0, err
}
defer res.Body.Close()
switch res.StatusCode {
case http.StatusOK, http.StatusServiceUnavailable:
// Both carry the JSON body; 503 means status "unavailable".
case http.StatusTooManyRequests:
secs, _ := strconv.Atoi(res.Header.Get("Retry-After"))
return body, time.Duration(secs) * time.Second, fmt.Errorf("rate limited")
case http.StatusNotFound:
return body, 0, fmt.Errorf("status route is not enabled on this environment")
default:
return body, 0, fmt.Errorf("unexpected HTTP %d", res.StatusCode)
}
if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
return body, 0, fmt.Errorf("bad JSON: %w", err)
}
if body.SchemaVersion != 1 || body.Status == "unknown" || !validState[body.Status] {
return body, 0, fmt.Errorf("unexpected body: version %d, status %q", body.SchemaVersion, body.Status)
}
if (res.StatusCode == http.StatusServiceUnavailable) != (body.Status == "unavailable") {
return body, 0, fmt.Errorf("HTTP %d does not match status %q", res.StatusCode, body.Status)
}
for _, name := range []string{"api", "sessions", "workflows", "llm", "voice"} {
if !validState[body.Components[name]] {
return body, 0, fmt.Errorf("component %q missing or invalid", name)
}
}
return body, 0, nil
}
func main() {
base := os.Getenv("WETEL_API_URL") // the API base address, no trailing slash
if base == "" {
fmt.Fprintln(os.Stderr, "set WETEL_API_URL")
os.Exit(2)
}
failures := 0 // consecutive "unavailable" answers
for {
body, retryAfter, err := check(context.Background(), base)
wait := 30 * time.Second
switch {
case err != nil:
fmt.Println("check failed:", err)
if retryAfter > 0 {
wait = retryAfter
}
case body.Status == "unavailable":
failures++
default:
failures = 0
}
if err == nil {
fmt.Printf("%s status=%s components=%v\n", body.CheckedAt, body.Status, body.Components)
if failures >= 2 {
fmt.Println("hide Wetel-dependent features")
}
}
time.Sleep(wait)
}
}

Run it:

Terminal window
export WETEL_API_URL="https://<your API host>" # no trailing slash, no /graphql
go run .

A healthy answer prints one line per poll, for example 2026-11-19T08:00:05Z status=operational components=map[...]. A check failed: status route is not enabled on this environment line means the route answers 404 there: the switch is off for that environment.

The program was built with go vet and go build on Go 1.27 and run against a local stub that returns the documented body. It has not been run against a live Wetel environment, so confirm it against yours before you rely on it.