home / skills / openclaw / skills / telnyx-ai-assistants-go
/skills/dotcom-squad/telnyx-toolkit/api/go/telnyx-ai-assistants-go
This skill provides Go SDK examples to create and manage Telnyx AI Assistants with custom personalities and knowledge bases.
npx playbooks add skill openclaw/skills --skill telnyx-ai-assistants-goReview the files below or copy the command above to add this skill to your agents.
---
name: telnyx-ai-assistants-go
description: >-
Create and manage AI voice assistants with custom personalities, knowledge
bases, and tool integrations. This skill provides Go SDK examples.
metadata:
author: telnyx
product: ai-assistants
language: go
generated_by: telnyx-ext-skills-generator
---
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
# Telnyx Ai Assistants - Go
## Installation
```bash
go get github.com/team-telnyx/telnyx-go
```
## Setup
```go
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.
## List assistants
Retrieve a list of all AI Assistants configured by the user.
`GET /ai/assistants`
```go
assistantsList, err := client.AI.Assistants.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantsList.Data)
```
## Create an assistant
Create a new AI Assistant.
`POST /ai/assistants` — Required: `name`, `model`, `instructions`
```go
assistant, err := client.AI.Assistants.New(context.TODO(), telnyx.AIAssistantNewParams{
Instructions: "instructions",
Model: "model",
Name: "name",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Get an assistant
Retrieve an AI Assistant configuration by `assistant_id`.
`GET /ai/assistants/{assistant_id}`
```go
assistant, err := client.AI.Assistants.Get(
context.TODO(),
"assistant_id",
telnyx.AIAssistantGetParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Update an assistant
Update an AI Assistant's attributes.
`POST /ai/assistants/{assistant_id}`
```go
assistant, err := client.AI.Assistants.Update(
context.TODO(),
"assistant_id",
telnyx.AIAssistantUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Delete an assistant
Delete an AI Assistant by `assistant_id`.
`DELETE /ai/assistants/{assistant_id}`
```go
assistant, err := client.AI.Assistants.Delete(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Assistant Chat (BETA)
This endpoint allows a client to send a chat message to a specific AI Assistant.
`POST /ai/assistants/{assistant_id}/chat` — Required: `content`, `conversation_id`
```go
response, err := client.AI.Assistants.Chat(
context.TODO(),
"assistant_id",
telnyx.AIAssistantChatParams{
Content: "Tell me a joke about cats",
ConversationID: "42b20469-1215-4a9a-8964-c36f66b406f4",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Content)
```
## Assistant Sms Chat
Send an SMS message for an assistant.
`POST /ai/assistants/{assistant_id}/chat/sms` — Required: `from`, `to`
```go
response, err := client.AI.Assistants.SendSMS(
context.TODO(),
"assistant_id",
telnyx.AIAssistantSendSMSParams{
From: "from",
To: "to",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ConversationID)
```
## Clone Assistant
Clone an existing assistant, excluding telephony and messaging settings.
`POST /ai/assistants/{assistant_id}/clone`
```go
assistant, err := client.AI.Assistants.Clone(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Import assistants from external provider
Import assistants from external providers.
`POST /ai/assistants/import` — Required: `provider`, `api_key_ref`
```go
assistantsList, err := client.AI.Assistants.Imports(context.TODO(), telnyx.AIAssistantImportsParams{
APIKeyRef: "api_key_ref",
Provider: telnyx.AIAssistantImportsParamsProviderElevenlabs,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantsList.Data)
```
## List scheduled events
Get scheduled events for an assistant with pagination and filtering
`GET /ai/assistants/{assistant_id}/scheduled_events`
```go
page, err := client.AI.Assistants.ScheduledEvents.List(
context.TODO(),
"assistant_id",
telnyx.AIAssistantScheduledEventListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a scheduled event
Create a scheduled event for an assistant
`POST /ai/assistants/{assistant_id}/scheduled_events` — Required: `telnyx_conversation_channel`, `telnyx_end_user_target`, `telnyx_agent_target`, `scheduled_at_fixed_datetime`
```go
scheduledEventResponse, err := client.AI.Assistants.ScheduledEvents.New(
context.TODO(),
"assistant_id",
telnyx.AIAssistantScheduledEventNewParams{
ScheduledAtFixedDatetime: time.Now(),
TelnyxAgentTarget: "telnyx_agent_target",
TelnyxConversationChannel: telnyx.ConversationChannelTypePhoneCall,
TelnyxEndUserTarget: "telnyx_end_user_target",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", scheduledEventResponse)
```
## Get a scheduled event
Retrieve a scheduled event by event ID
`GET /ai/assistants/{assistant_id}/scheduled_events/{event_id}`
```go
scheduledEventResponse, err := client.AI.Assistants.ScheduledEvents.Get(
context.TODO(),
"event_id",
telnyx.AIAssistantScheduledEventGetParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", scheduledEventResponse)
```
## Delete a scheduled event
If the event is pending, this will cancel the event.
`DELETE /ai/assistants/{assistant_id}/scheduled_events/{event_id}`
```go
err := client.AI.Assistants.ScheduledEvents.Delete(
context.TODO(),
"event_id",
telnyx.AIAssistantScheduledEventDeleteParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
```
## List assistant tests with pagination
Retrieves a paginated list of assistant tests with optional filtering capabilities
`GET /ai/assistants/tests`
```go
page, err := client.AI.Assistants.Tests.List(context.TODO(), telnyx.AIAssistantTestListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create a new assistant test
Creates a comprehensive test configuration for evaluating AI assistant performance
`POST /ai/assistants/tests` — Required: `name`, `destination`, `instructions`, `rubric`
```go
assistantTest, err := client.AI.Assistants.Tests.New(context.TODO(), telnyx.AIAssistantTestNewParams{
Destination: "+15551234567",
Instructions: "Act as a frustrated customer who received a damaged product. Ask for a refund and escalate if not satisfied with the initial response.",
Name: "Customer Support Bot Test",
Rubric: []telnyx.AIAssistantTestNewParamsRubric{{
Criteria: "Assistant responds within 30 seconds",
Name: "Response Time",
}, {
Criteria: "Provides correct product information",
Name: "Accuracy",
}},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantTest.TestID)
```
## Get all test suite names
Retrieves a list of all distinct test suite names available to the current user
`GET /ai/assistants/tests/test-suites`
```go
testSuites, err := client.AI.Assistants.Tests.TestSuites.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", testSuites.Data)
```
## Get test suite run history
Retrieves paginated history of test runs for a specific test suite with filtering options
`GET /ai/assistants/tests/test-suites/{suite_name}/runs`
```go
page, err := client.AI.Assistants.Tests.TestSuites.Runs.List(
context.TODO(),
"suite_name",
telnyx.AIAssistantTestTestSuiteRunListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Trigger test suite execution
Executes all tests within a specific test suite as a batch operation
`POST /ai/assistants/tests/test-suites/{suite_name}/runs`
```go
testRunResponses, err := client.AI.Assistants.Tests.TestSuites.Runs.Trigger(
context.TODO(),
"suite_name",
telnyx.AIAssistantTestTestSuiteRunTriggerParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", testRunResponses)
```
## Get assistant test by ID
Retrieves detailed information about a specific assistant test
`GET /ai/assistants/tests/{test_id}`
```go
assistantTest, err := client.AI.Assistants.Tests.Get(context.TODO(), "test_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantTest.TestID)
```
## Update an assistant test
Updates an existing assistant test configuration with new settings
`PUT /ai/assistants/tests/{test_id}`
```go
assistantTest, err := client.AI.Assistants.Tests.Update(
context.TODO(),
"test_id",
telnyx.AIAssistantTestUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantTest.TestID)
```
## Delete an assistant test
Permanently removes an assistant test and all associated data
`DELETE /ai/assistants/tests/{test_id}`
```go
err := client.AI.Assistants.Tests.Delete(context.TODO(), "test_id")
if err != nil {
panic(err.Error())
}
```
## Get test run history for a specific test
Retrieves paginated execution history for a specific assistant test with filtering options
`GET /ai/assistants/tests/{test_id}/runs`
```go
page, err := client.AI.Assistants.Tests.Runs.List(
context.TODO(),
"test_id",
telnyx.AIAssistantTestRunListParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Trigger a manual test run
Initiates immediate execution of a specific assistant test
`POST /ai/assistants/tests/{test_id}/runs`
```go
testRunResponse, err := client.AI.Assistants.Tests.Runs.Trigger(
context.TODO(),
"test_id",
telnyx.AIAssistantTestRunTriggerParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", testRunResponse.RunID)
```
## Get specific test run details
Retrieves detailed information about a specific test run execution
`GET /ai/assistants/tests/{test_id}/runs/{run_id}`
```go
testRunResponse, err := client.AI.Assistants.Tests.Runs.Get(
context.TODO(),
"run_id",
telnyx.AIAssistantTestRunGetParams{
TestID: "test_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", testRunResponse.RunID)
```
## Get all versions of an assistant
Retrieves all versions of a specific assistant with complete configuration and metadata
`GET /ai/assistants/{assistant_id}/versions`
```go
assistantsList, err := client.AI.Assistants.Versions.List(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistantsList.Data)
```
## Get a specific assistant version
Retrieves a specific version of an assistant by assistant_id and version_id
`GET /ai/assistants/{assistant_id}/versions/{version_id}`
```go
assistant, err := client.AI.Assistants.Versions.Get(
context.TODO(),
"version_id",
telnyx.AIAssistantVersionGetParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Update a specific assistant version
Updates the configuration of a specific assistant version.
`POST /ai/assistants/{assistant_id}/versions/{version_id}`
```go
assistant, err := client.AI.Assistants.Versions.Update(
context.TODO(),
"version_id",
telnyx.AIAssistantVersionUpdateParams{
AssistantID: "assistant_id",
UpdateAssistant: telnyx.UpdateAssistantParam{},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Delete a specific assistant version
Permanently removes a specific version of an assistant.
`DELETE /ai/assistants/{assistant_id}/versions/{version_id}`
```go
err := client.AI.Assistants.Versions.Delete(
context.TODO(),
"version_id",
telnyx.AIAssistantVersionDeleteParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
```
## Promote an assistant version to main
Promotes a specific version to be the main/current version of the assistant.
`POST /ai/assistants/{assistant_id}/versions/{version_id}/promote`
```go
assistant, err := client.AI.Assistants.Versions.Promote(
context.TODO(),
"version_id",
telnyx.AIAssistantVersionPromoteParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", assistant.ID)
```
## Get Canary Deploy
Endpoint to get a canary deploy configuration for an assistant.
`GET /ai/assistants/{assistant_id}/canary-deploys`
```go
canaryDeployResponse, err := client.AI.Assistants.CanaryDeploys.Get(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", canaryDeployResponse.AssistantID)
```
## Create Canary Deploy
Endpoint to create a canary deploy configuration for an assistant.
`POST /ai/assistants/{assistant_id}/canary-deploys` — Required: `versions`
```go
canaryDeployResponse, err := client.AI.Assistants.CanaryDeploys.New(
context.TODO(),
"assistant_id",
telnyx.AIAssistantCanaryDeployNewParams{
CanaryDeploy: telnyx.CanaryDeployParam{
Versions: []telnyx.VersionConfigParam{{
Percentage: 1,
VersionID: "version_id",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", canaryDeployResponse.AssistantID)
```
## Update Canary Deploy
Endpoint to update a canary deploy configuration for an assistant.
`PUT /ai/assistants/{assistant_id}/canary-deploys` — Required: `versions`
```go
canaryDeployResponse, err := client.AI.Assistants.CanaryDeploys.Update(
context.TODO(),
"assistant_id",
telnyx.AIAssistantCanaryDeployUpdateParams{
CanaryDeploy: telnyx.CanaryDeployParam{
Versions: []telnyx.VersionConfigParam{{
Percentage: 1,
VersionID: "version_id",
}},
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", canaryDeployResponse.AssistantID)
```
## Delete Canary Deploy
Endpoint to delete a canary deploy configuration for an assistant.
`DELETE /ai/assistants/{assistant_id}/canary-deploys`
```go
err := client.AI.Assistants.CanaryDeploys.Delete(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
```
## Get assistant texml
Get an assistant texml by `assistant_id`.
`GET /ai/assistants/{assistant_id}/texml`
```go
response, err := client.AI.Assistants.GetTexml(context.TODO(), "assistant_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
```
## Test Assistant Tool
Test a webhook tool for an assistant
`POST /ai/assistants/{assistant_id}/tools/{tool_id}/test`
```go
response, err := client.AI.Assistants.Tools.Test(
context.TODO(),
"tool_id",
telnyx.AIAssistantToolTestParams{
AssistantID: "assistant_id",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
```
## List Integrations
List all available integrations.
`GET /ai/integrations`
```go
integrations, err := client.AI.Integrations.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", integrations.Data)
```
## List User Integrations
List user setup integrations
`GET /ai/integrations/connections`
```go
connections, err := client.AI.Integrations.Connections.List(context.TODO())
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", connections.Data)
```
## Get User Integration connection By Id
Get user setup integrations
`GET /ai/integrations/connections/{user_connection_id}`
```go
connection, err := client.AI.Integrations.Connections.Get(context.TODO(), "user_connection_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", connection.Data)
```
## Delete Integration Connection
Delete a specific integration connection.
`DELETE /ai/integrations/connections/{user_connection_id}`
```go
err := client.AI.Integrations.Connections.Delete(context.TODO(), "user_connection_id")
if err != nil {
panic(err.Error())
}
```
## List Integration By Id
Retrieve integration details
`GET /ai/integrations/{integration_id}`
```go
integration, err := client.AI.Integrations.Get(context.TODO(), "integration_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", integration.ID)
```
## List MCP Servers
Retrieve a list of MCP servers.
`GET /ai/mcp_servers`
```go
page, err := client.AI.McpServers.List(context.TODO(), telnyx.AIMcpServerListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
```
## Create MCP Server
Create a new MCP server.
`POST /ai/mcp_servers` — Required: `name`, `type`, `url`
```go
mcpServer, err := client.AI.McpServers.New(context.TODO(), telnyx.AIMcpServerNewParams{
Name: "name",
Type: "type",
URL: "url",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", mcpServer.ID)
```
## Get MCP Server
Retrieve details for a specific MCP server.
`GET /ai/mcp_servers/{mcp_server_id}`
```go
mcpServer, err := client.AI.McpServers.Get(context.TODO(), "mcp_server_id")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", mcpServer.ID)
```
## Update MCP Server
Update an existing MCP server.
`PUT /ai/mcp_servers/{mcp_server_id}`
```go
mcpServer, err := client.AI.McpServers.Update(
context.TODO(),
"mcp_server_id",
telnyx.AIMcpServerUpdateParams{},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", mcpServer.ID)
```
## Delete MCP Server
Delete a specific MCP server.
`DELETE /ai/mcp_servers/{mcp_server_id}`
```go
err := client.AI.McpServers.Delete(context.TODO(), "mcp_server_id")
if err != nil {
panic(err.Error())
}
```
This skill provides Go SDK examples for creating and managing Telnyx AI voice assistants, including personalities, knowledge bases, telephony integrations, and testing tools. It documents common API operations such as creating assistants, running chat and SMS interactions, scheduling events, managing versions, and configuring canary deployments. The examples assume a telnyx-go client initialized with an API key and focus on practical calls for assistant lifecycle and testing.
The skill demonstrates how to call Telnyx AI Assistant endpoints using the telnyx-go client: listing, creating, retrieving, updating, and deleting assistants and versions. It shows chat interactions (including SMS), scheduling events, cloning and importing assistants, running automated tests and test suites, and managing canary deployments to roll out versioned updates. Each example uses context-aware API calls with parameter structs provided by the SDK.
Do examples require the Go SDK?
Yes. The examples use the telnyx-go client and its parameter structs; install the SDK and set TELNYX_API_KEY in your environment.
How do I test assistant changes safely?
Use assistant tests and test suites to validate behavior, and use canary deploys to roll out changes incrementally before promoting a version to main.