Coder Social home page Coder Social logo

yagizzcann / whatsapp-api-go Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 5.0 27 KB

Unofficial Whatsapp API Helper for Golang

Home Page: https://pkg.go.dev/github.com/yagizzcann/[email protected]

License: MIT License

Go 100.00%
go-whatsapp whatsapp-api go-whatsapp-official whatsapp-official

whatsapp-api-go's Introduction

whatsapp

A Whatsapp's Official API helper for Golang

Disclaimers

  1. Whatsapp's Official API is now generally available. To get started, you can follow this steps.

Set up

First, you need a Facebook app with the Whatsapp API activated. You can create your first app following this steps. Get the API token, either a temporal or a permanent one.

In your server you can install the module using :

go get github.com/yagizzcann/whatsapp-api-go

Now you can write code like this:

import (
"github.com/yagizzcann/whatsapp-api-go"
)

Token := "YOUR_TOKEN";

api := whatsapp.API{
URI:     whatsapp.DefaultURI,
Version: whatsapp.DefaultVersion,
Token:   Token,
WebHookVerification:"custom webhook verify token ",
}

t := api.NewText("MESSAGE_CONTENT", false)
res, err := t.Send("YOUR_PHONE_ID", "TO_PHONE_NUMBER")

m := api.NewMediaLink("https://img_url", "image")
res, err := m.Send("YOUR_PHONE_ID", "TO_PHONE_NUMBER")

To recieve the post requests on message, you must setup the webhook at your Facebook app. While setting up, you will be asked a Verify Token. This can be any string you want.

The app also has a GET wizard for the webhook authentication:

cq := make(chan whatsapp.WebhookMessage, 100)
r := mux.NewRouter()
r.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) { whatsapp.WebhookVerificationHandler(w, r, cq) }).Methods("GET")
r.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) { whatsapp.WebhookEventHandler(w, r, cq) }).Methods("POST")

And that's it! Now you have a functioning Whatsapp Bot connected to your server.

whatsapp-api-go's People

Contributors

yagizzcann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

whatsapp-api-go's Issues

Exit status 2

goroutine 1 [running]:
main.main()
d:/Project/WebAPI/wago/main.go:23 +0x1f2
exit status 2

[Done] exited with code=1 in 3.931 seconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.