Build Go voice apps with the Vobiz SDK - place outbound calls, manage SIP trunks, and craft VobizXML synchronously for 130+ countries including India.
The official Go SDK for the Vobiz Voice API. Make outbound calls, manage SIP trunks, handle phone numbers, and drive live call flows from idiomatic, type-safe Go.
Source code: vobiz-ai/Vobiz-Go-SDK
Requires Go 1.21 or later. Add the SDK with go get:
bashgo get github.com/vobiz-ai/Vobiz-Go-SDK
Place an outbound call. When the call connects, Vobiz pings your AnswerURL endpoint, and you must respond with a VobizXML payload.
gopackage main import ( "context" "fmt" "log" "os" vobiz "github.com/vobiz-ai/Vobiz-Go-SDK" "github.com/vobiz-ai/Vobiz-Go-SDK/client" "github.com/vobiz-ai/Vobiz-Go-SDK/option" ) func main() { c := client.NewClient( option.WithAPIKey(os.Getenv("VOBIZ_AUTH_ID")), option.WithAuthToken(os.Getenv("VOBIZ_AUTH_TOKEN")), ) response, err := c.Calls.MakeCall(context.TODO(), &vobiz.MakeCallRequest{ AuthID: os.Getenv("VOBIZ_AUTH_ID"), From: "14155551234", To: "+919876543210", AnswerURL: "https://yourserver.com/answer", AnswerMethod: "POST", }) if err != nil { log.Fatalf("Error making call: %v", err) } fmt.Printf("Call queued: %+v\n", response) }
The Go client requires your Auth ID and Auth Token. Find both in the Vobiz Console.
Use option.WithAPIKey for your Auth ID (mapped to the X-Auth-ID header) and option.WithAuthToken for your Auth Token (mapped to X-Auth-Token):
goimport ( "github.com/vobiz-ai/Vobiz-Go-SDK/client" "github.com/vobiz-ai/Vobiz-Go-SDK/option" ) c := client.NewClient( option.WithAPIKey(os.Getenv("VOBIZ_AUTH_ID")), option.WithAuthToken(os.Getenv("VOBIZ_AUTH_TOKEN")), )
When Vobiz calls your AnswerURL, your handler must respond with a VobizXML document that defines the call flow. The SDK ships a typed builder in the github.com/vobiz-ai/Vobiz-Go-SDK/vobizxml subpackage - each Add* returns the created child for nesting, and vobizxml.Attr(key, value) sets attributes in order:
goimport "github.com/vobiz-ai/Vobiz-Go-SDK/vobizxml" func answerHandler(w http.ResponseWriter, r *http.Request) { resp := vobizxml.NewResponse() gather := resp.AddGather( vobizxml.Attr("action", "https://yourapp.com/menu-choice"), vobizxml.Attr("method", "POST"), vobizxml.Attr("inputType", "dtmf"), // Gather uses inputType / executionTimeout vobizxml.Attr("numDigits", 1), vobizxml.Attr("executionTimeout", 10), ) gather.AddSpeak("Press 1 for sales, 2 for support, or 0 for an operator.") resp.AddSpeak("We didn't receive your input. Goodbye.") resp.AddHangup() w.Header().Set("Content-Type", "application/xml") fmt.Fprint(w, resp.String()) // pretty; resp.StringCompact() for one line }
ℹ️ Note: Prefer the builder, but you can also return a raw VobizXML string if you like. See the VobizXML reference for all verbs and attributes.
gobalance, err := c.Balance.GetBalance(context.TODO(), &vobiz.GetBalanceRequest{ AuthID: os.Getenv("VOBIZ_AUTH_ID"), Currency: "USD", }) if err != nil { log.Fatalf("Error retrieving balance: %v", err) } fmt.Printf("Balance: %+v\n", balance)
goresponse, err := c.Cdr.ListCdrs(context.TODO(), &vobiz.ListCdrsRequest{ AuthID: os.Getenv("VOBIZ_AUTH_ID"), Page: vobiz.Int(1), PerPage: vobiz.Int(50), }) if err != nil { log.Fatalf("Error listing CDRs: %v", err) } fmt.Printf("CDRs: %+v\n", response)
gotrunk, err := c.Trunks.CreateTrunk(context.TODO(), &vobiz.CreateTrunkRequest{ AuthID: os.Getenv("VOBIZ_AUTH_ID"), Name: "My Outbound Trunk", TrunkType: "OUTBOUND", MaxConcurrentCalls: 10, }) if err != nil { log.Fatalf("Error creating SIP trunk: %v", err) } fmt.Printf("Trunk created: %+v\n", trunk)
The SDK returns a standard Go error for any non-2xx response. Always check err before using the response:
goresponse, err := c.Balance.GetBalance(context.TODO(), &vobiz.GetBalanceRequest{ AuthID: os.Getenv("VOBIZ_AUTH_ID"), Currency: "USD", }) if err != nil { log.Printf("API call failed: %v", err) return }
Connect 3CX PBX to Vobiz SIP trunking for inbound and outbound calling across 130+ countries - configure a generic SIP trunk in minutes.
Connect an Agora Conversational AI agent to Vobiz SIP trunking - add a Vobiz number to Agora for outbound campaigns and route inbound calls to your agent, including India and 130+ countries.
Bolna ships Vobiz as a built-in telephony provider. Paste two credentials into the Providers screen and your agents place and answer calls on numbers in 130+ countries, reaching 190, with audio streaming rather than a SIP trunk.
We use cookies to run this site and, with your permission, to understand how it's used. Read our Cookie Policy.