Whatsapp Cloud API Wrapper for Golang
About
Lightweight Whatsapp Cloud API Wrapper v14.0 for Golang with no dependency.
Made this cause I haven't found any reliable whatsapp cloud api wrapper for golang
Content
Install
go get github.com/febriliankr/whatsapp-cloud-api
or if you want to use specific version
go get github.com/febriliankr/whatsapp-cloud-api@v1.0.2
Usage
Create an instance of the Whatsapp Cloud API Client
wa := whatsapp.NewWhatsapp(token, myPhoneID)
Modifying instance
- Changing the language
wa.Language = TemplateLanguage{ Code: "id" }
- Changing the API version
wa.APIVersion = "v14.0"
- Changing the Whatsapp Phone ID
wa.PhoneNumberID = WHATSAPP_PHONE_ID
Send a templated message
With one parameter
parameters := wa.GenerateTemplateParameters("text", "48884")
components := wa.TemplateComponent("body", parameters)
res, err := wa.SendWithTemplate("RECEIVER_PHONE_NUMBER", "your_template_name", components)
with no parameter
res, err := wa.SendWithTemplate("RECEIVER_PHONE_NUMBER", "your_template_name", nil)
Send a plain text message
Sending plain text message to a phone number that has messaged your WhatsApp Business account in the past 24 hours.
res, err := wa.SendText("RECEIVER_PHONE_NUMBER", "your_message")
Check more usage example in example/example.go
Getting the Whatsapp Cloud API Access
Official documentation:
FAQ
Tutorial for Myself!
Releasing new version
$ git commit -m "hello: changes for v1.0.0"
$ git tag v1.0.0
$ git push origin v1.0.0