Go SDK
The official Go SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and construct programmatic XML workflows synchronously in Go.
Source Code: vobiz-ai/vobiz-go-sdk
Installation
Clone the repository and integrate it locally:
git clone https://github.com/vobiz-ai/Vobiz-Go-SDK.git
cd Vobiz-Go-SDK
go mod tidyAuthentication
Like all SDKs, the Go client requires injecting your Auth ID and Auth Token. Find these within the Vobiz Console.
import "github.com/vobiz-ai/vobiz-go-sdk/client"
c := client.New("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")Quick Start (Outbound Calls)
Creating an outbound call requires passing your origin number, destination number, and webhook URLs using the native nested calls.CreateParams struct. When the call connects, the Vobiz engine will immediately ping your AnswerURL endpoint. You must respond to this HTTP request with a VobizXML payload so Vobiz knows what actions to execute on the call leg.
package main
import (
"fmt"
"github.com/vobiz-ai/vobiz-go-sdk/client"
"github.com/vobiz-ai/vobiz-go-sdk/services/calls"
)
func main() {
c := client.New("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
call, err := calls.New(c).Create(&calls.CreateParams{
From: "+1xxxxxxxxxx",
To: "+1xxxxxxxxxx",
AnswerURL: "https://yourserver.com/answer",
AnswerMethod: "POST",
})
if err != nil {
panic(err)
}
fmt.Println("Call UUID:", call.RequestUUID)
}VobizXML Module
The Go SDK ships out-of-the-box with a strongly typed xml builder resolving directly into valid stringified VobizXML. This module provides intelligent code-completion for all available XML verbs (Gather, Record, Dial), ensuring that your applications dynamically dictate call-flows safely without dealing with raw string templating.
import "github.com/vobiz-ai/vobiz-go-sdk/xml"
response := xml.NewResponse()
response.AddSpeak("Welcome to Vobiz!", "WOMAN", "en-US")
response.AddRecord(xml.RecordParams{
Action: "https://yourserver.com/recording",
MaxLength: 30,
PlayBeep: true,
})
fmt.Println(response.ToXML())Core Resources
The Go SDK utilizes strictly typed data-structure parameters mapping directly to our Cloud submodules. Here are a few auxiliary patterns beyond basic dialling.
Live Audio Routing
// Stream mp3 resources onto a live queue transparently
svc := calls.New(c)
svc.Play("call-uuid", &calls.PlayParams{
URLs: []string{"https://example.com/audio.mp3"},
Legs: "aleg",
})Conferences
import "github.com/vobiz-ai/vobiz-go-sdk/services/conferences"
svc := conferences.New(c)
// Force kick a member logically from the server
svc.Member.Delete("conference-name", "member-id")
// Start silent recording of the entire bridge
svc.Record("conference-name", &conferences.RecordParams{ FileFormat: "mp3" })