Ai telnyx-voice-advanced-go

install
source · Clone the upstream repo
git clone https://github.com/team-telnyx/ai
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/team-telnyx/ai "$T" && mkdir -p ~/.claude/skills && cp -r "$T/providers/claude/plugin/skills/telnyx-voice-advanced-go" ~/.claude/skills/team-telnyx-ai-telnyx-voice-advanced-go && rm -rf "$T"
manifest: providers/claude/plugin/skills/telnyx-voice-advanced-go/SKILL.md
source content
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->

Telnyx Voice Advanced - Go

Installation

go get github.com/team-telnyx/telnyx-go

Setup

import (
  "context"
  "fmt"
  "os"

  "github.com/team-telnyx/telnyx-go"
  "github.com/team-telnyx/telnyx-go/option"
)

client := telnyx.NewClient(
  option.WithAPIKey(os.Getenv("TELNYX_API_KEY")),
)

All examples below assume

client
is already initialized as shown above.

Error Handling

All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:

import "errors"

result, err := client.Messages.Send(ctx, params)
if err != nil {
  var apiErr *telnyx.Error
  if errors.As(err, &apiErr) {
    switch apiErr.StatusCode {
    case 422:
      fmt.Println("Validation error — check required fields and formats")
    case 429:
      // Rate limited — wait and retry with exponential backoff
      fmt.Println("Rate limited, retrying...")
    default:
      fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error())
    }
  } else {
    fmt.Println("Network error — check connectivity and retry")
  }
}

Common error codes:

401
invalid API key,
403
insufficient permissions,
404
resource not found,
422
validation error (check field formats),
429
rate limited (retry with exponential backoff).

Join AI Assistant Conversation

Add a participant to an existing AI assistant conversation. Use this command to bring an additional call leg into a running AI conversation.

POST /calls/{call_control_id}/actions/ai_assistant_join
— Required:
conversation_id
,
participant

Optional:

client_state
(string),
command_id
(string)

	response, err := client.Calls.Actions.JoinAIAssistant(
		context.Background(),
		"call_control_id",
		telnyx.CallActionJoinAIAssistantParams{
			ConversationID: "v3:abc123",
			Participant: telnyx.CallActionJoinAIAssistantParamsParticipant{
				ID:   "v3:abc123def456",
				Role: "user",
			},
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

conversation_id
(uuid),
result
(string)

Update client state

Updates client state

PUT /calls/{call_control_id}/actions/client_state_update
— Required:
client_state

	response, err := client.Calls.Actions.UpdateClientState(
		context.Background(),
		"call_control_id",
		telnyx.CallActionUpdateClientStateParams{
			ClientState: "aGF2ZSBhIG5pY2UgZGF5ID1d",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

Send DTMF

Sends DTMF tones from this leg. DTMF tones will be heard by the other end of the call. Expected Webhooks:

There are no webhooks associated with this command.

POST /calls/{call_control_id}/actions/send_dtmf
— Required:
digits

Optional:

client_state
(string),
command_id
(string),
duration_millis
(int32)

	response, err := client.Calls.Actions.SendDtmf(
		context.Background(),
		"call_control_id",
		telnyx.CallActionSendDtmfParams{
			Digits: "1www2WABCDw9",
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

SIPREC start

Start siprec session to configured in SIPREC connector SRS.

Expected Webhooks:

  • siprec.started
  • siprec.stopped
  • siprec.failed

POST /calls/{call_control_id}/actions/siprec_start

Optional:

client_state
(string),
connector_name
(string),
include_metadata_custom_headers
(boolean),
secure
(boolean),
session_timeout_secs
(integer),
sip_transport
(enum: udp, tcp, tls),
siprec_track
(enum: inbound_track, outbound_track, both_tracks)

	response, err := client.Calls.Actions.StartSiprec(
		context.Background(),
		"call_control_id",
		telnyx.CallActionStartSiprecParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

SIPREC stop

Stop SIPREC session. Expected Webhooks:

  • siprec.stopped

POST /calls/{call_control_id}/actions/siprec_stop

Optional:

client_state
(string),
command_id
(string)

	response, err := client.Calls.Actions.StopSiprec(
		context.Background(),
		"call_control_id",
		telnyx.CallActionStopSiprecParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

Noise Suppression Start (BETA)

POST /calls/{call_control_id}/actions/suppression_start

Optional:

client_state
(string),
command_id
(string),
direction
(enum: inbound, outbound, both),
noise_suppression_engine
(enum: Denoiser, DeepFilterNet, Krisp, AiCoustics),
noise_suppression_engine_config
(object)

	response, err := client.Calls.Actions.StartNoiseSuppression(
		context.Background(),
		"call_control_id",
		telnyx.CallActionStartNoiseSuppressionParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

Noise Suppression Stop (BETA)

POST /calls/{call_control_id}/actions/suppression_stop

Optional:

client_state
(string),
command_id
(string)

	response, err := client.Calls.Actions.StopNoiseSuppression(
		context.Background(),
		"call_control_id",
		telnyx.CallActionStopNoiseSuppressionParams{},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)

Switch supervisor role

Switch the supervisor role for a bridged call. This allows switching between different supervisor modes during an active call

POST /calls/{call_control_id}/actions/switch_supervisor_role
— Required:
role

	response, err := client.Calls.Actions.SwitchSupervisorRole(
		context.Background(),
		"call_control_id",
		telnyx.CallActionSwitchSupervisorRoleParams{
			Role: telnyx.CallActionSwitchSupervisorRoleParamsRoleBarge,
		},
	)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", response.Data)

Returns:

result
(string)


Webhooks

Webhook Verification

Telnyx signs webhooks with Ed25519. Each request includes

telnyx-signature-ed25519
and
telnyx-timestamp
headers. Always verify signatures in production:

// In your webhook handler:
func handleWebhook(w http.ResponseWriter, r *http.Request) {
  body, _ := io.ReadAll(r.Body)
  event, err := client.Webhooks.Unwrap(body, r.Header)
  if err != nil {
    http.Error(w, "Invalid signature", http.StatusBadRequest)
    return
  }
  // Signature valid — event is the parsed webhook payload
  fmt.Println("Received event:", event.Data.EventType)
  w.WriteHeader(http.StatusOK)
}

The following webhook events are sent to your configured webhook URL. All webhooks include

telnyx-timestamp
and
telnyx-signature-ed25519
headers for Ed25519 signature verification. Use
client.webhooks.unwrap()
to verify.

EventDescription
callConversationEnded
Call Conversation Ended
callConversationInsightsGenerated
Call Conversation Insights Generated
callDtmfReceived
Call Dtmf Received
callMachineDetectionEnded
Call Machine Detection Ended
callMachineGreetingEnded
Call Machine Greeting Ended
callMachinePremiumDetectionEnded
Call Machine Premium Detection Ended
callMachinePremiumGreetingEnded
Call Machine Premium Greeting Ended
callReferCompleted
Call Refer Completed
callReferFailed
Call Refer Failed
callReferStarted
Call Refer Started
callSiprecFailed
Call Siprec Failed
callSiprecStarted
Call Siprec Started
callSiprecStopped
Call Siprec Stopped

Webhook payload fields

callConversationEnded

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.conversation.endedThe type of event being delivered.
data.id
uuidUnique identifier for the event.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.created_at
date-timeTimestamp when the event was created in the system.
data.payload.assistant_id
stringUnique identifier of the assistant involved in the call.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call leg.
data.payload.call_session_id
stringID that is unique to the call session (group of related call legs).
data.payload.client_state
stringBase64-encoded state received from a command.
data.payload.calling_party_type
enum: pstn, sipThe type of calling party connection.
data.payload.conversation_id
stringID unique to the conversation or insight group generated for the call.
data.payload.duration_sec
integerDuration of the conversation in seconds.
data.payload.from
stringThe caller's number or identifier.
data.payload.to
stringThe callee's number or SIP address.
data.payload.llm_model
stringThe large language model used during the conversation.
data.payload.stt_model
stringThe speech-to-text model used in the conversation.
data.payload.tts_provider
stringThe text-to-speech provider used in the call.
data.payload.tts_model_id
stringThe model ID used for text-to-speech synthesis.
data.payload.tts_voice_id
stringVoice ID used for TTS.

callConversationInsightsGenerated

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.conversation_insights.generatedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.calling_party_type
enum: pstn, sipThe type of calling party connection.
data.payload.insight_group_id
stringID that is unique to the insight group being generated for the call.
data.payload.results
array[object]Array of insight results being generated for the call.

callDtmfReceived

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.dtmf.receivedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringIdentifies the type of resource.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.to
stringDestination number or SIP URI of the call.
data.payload.digit
stringThe received DTMF digit or symbol.

callMachineDetectionEnded

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.machine.detection.endedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.to
stringDestination number or SIP URI of the call.
data.payload.result
enum: human, machine, not_sureAnswering machine detection result.

callMachineGreetingEnded

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.machine.greeting.endedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.to
stringDestination number or SIP URI of the call.
data.payload.result
enum: beep_detected, ended, not_sureAnswering machine greeting ended result.

callMachinePremiumDetectionEnded

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.machine.premium.detection.endedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.to
stringDestination number or SIP URI of the call.
data.payload.result
enum: human_residence, human_business, machine, silence, fax_detected, not_surePremium Answering Machine Detection result.

callMachinePremiumGreetingEnded

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.machine.premium.greeting.endedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.to
stringDestination number or SIP URI of the call.
data.payload.result
enum: beep_detected, no_beep_detectedPremium Answering Machine Greeting Ended result.

callReferCompleted

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.refer.completedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.

callReferFailed

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.refer.failedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.

callReferStarted

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: call.refer.startedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringUnique ID for controlling the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.client_state
stringState received from a command.
data.payload.from
stringNumber or SIP URI placing the call.
data.payload.sip_notify_response
integerSIP NOTIFY event status for tracking the REFER attempt.
data.payload.to
stringDestination number or SIP URI of the call.

callSiprecFailed

FieldTypeDescription
data.record_type
enum: eventIdentifies the resource.
data.event_type
enum: siprec.failedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.failure_cause
stringQ850 reason why siprec session failed.

callSiprecStarted

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: siprec.startedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.

callSiprecStopped

FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.event_type
enum: siprec.stoppedThe type of event being delivered.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.payload.call_control_id
stringCall ID used to issue commands via Call Control API.
data.payload.connection_id
stringCall Control App ID (formerly Telnyx connection ID) used in the call.
data.payload.call_leg_id
stringID that is unique to the call and can be used to correlate webhook events.
data.payload.call_session_id
stringID that is unique to the call session and can be used to correlate webhook events.
data.payload.client_state
stringState received from a command.
data.payload.hangup_cause
stringQ850 reason why the SIPREC session was stopped.