go-messenger-bot
go-messenger-bot copied to clipboard
Can this bot be used as part of an existing web app with its own routing?
I have an eccomerce platform, and would like to build a facebook bot to interact with the platform. I;m currently using julienschmidt/httprouter for routing. How can i attach the webhook to the router?
I had to copy over SetWebhook implementation since I had only 1 http port available.
@tonyalaribe Success in the challenge ... 😄
Lmao... @kelonye seems i'm not the only one in the challenge. Thanks for the headsup.
Most http frameworks seem to have a way to use a http.Handler to handle specific paths.
If you pass the mux
of callbacks, mux := bot.SetWebhook("/webhook")
into it, it should just work.
For my app (using gin) I had to do:
router.GET("/webhook", gin.WrapH(mux))
router.POST("/webhook", gin.WrapH(mux))
For julienschmidt/httprouter it looks like this method will do what you want, but I've not tried it: https://godoc.org/github.com/julienschmidt/httprouter#Router.Handler