With this small library it should be possible to send SMS, WhatsApp & Co messages via cm.com. And, of course, to make other functions of the API usable.
go get github.com/jjideenschmiede/gocm
In order to send one, or more messages via the Business Messages API, you can use the following function. Here you can find an additional description from the manufacturer.
Currently the following channels can be used: WhatsApp, Push, RCS, Viber, SMS
// Define body
body := gocm.MessageBody{
Messages: gocm.MessageBodyMessages{
Authentication: gocm.MessageBodyAuthentication{
Producttoken: "",
},
Msg: []gocm.MessageBodyMsg{},
},
}
// Create a message
body.Messages.Msg = append(body.Messages.Msg, gocm.MessageBodyMsg{
AllowedChannels: []string{"SMS"},
From: "Test",
To: []gocm.MessageBodyTo{},
Body: gocm.MessageBodyBody{
Type: "auto",
Content: "Test message",
},
})
// Add receiver
body.Messages.Msg[0].To = append(body.Messages.Msg[0].To, gocm.MessageBodyTo{
Number: "004941521234567",
})
// Send message
message, err := gocm.Message(body)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(message)
}