Send an SMS with Thinwrap (Go)
Send an SMS via the Thinwrap SMS facade in Go — one call shape for Twilio, Vonage, MessageBird and every other provider.
1. Install
go get github.com/thinwrap/notifications-go2. Send the call
import "github.com/thinwrap/notifications-go"
s := notifications.NewSms(notifications.TwilioConfig{
AccountSid: os.Getenv("TWILIO_ACCOUNT_SID"),
AuthToken: os.Getenv("TWILIO_AUTH_TOKEN"),
From: "+15551112222",
})
res, err := s.Send(ctx, notifications.SmsSendInput{
To: "+15552223333",
Body: "Hello from Thinwrap",
})
if err != nil {
var ce *notifications.ConnectorError
if errors.As(err, &ce) {
log.Printf("%s: %s", ce.ProviderCode, ce.ProviderMessage)
}
return
}
fmt.Println(res.Status, res.ProviderMessageID)
Same code works for all supported providers — just change the provider ID.