Messenger is a Facebook Messenger target for fsm.
When using this target, you must set two environment variables:
MESSENGER_VERIFY_TOKEN=""
MESSENGER_ACCESS_TOKEN=""
Note: The environment variables above are assumed to be set in this example code:
package main
import (
"net/http"
"github.com/fsm/fsm"
"github.com/fsm/messenger"
"github.com/julienschmidt/httprouter"
)
func main() {
router := &httprouter.Router{
RedirectTrailingSlash: true,
RedirectFixedPath: true,
HandleMethodNotAllowed: true,
}
router.HandlerFunc(http.MethodGet, "/facebook", messenger.SetupWebhook)
router.HandlerFunc(http.MethodPost, "/facebook", messenger.GetMessageReceivedWebhook(getStateMachine(), getStore()))
http.ListenAndServe(":5000", router)
}
func getStateMachine() fsm.StateMachine {
// ...
}
func getStore() fsm.Store {
// ...
}