Description
A simple library for making bots for Facebook's Messenger Platform.
fbot alternatives and similar packages
Based on the "Third-party APIs" category.
Alternatively, view fbot alternatives based on common mentions on social networks and blogs.
-
goamz
Popular fork of goamz which adds some missing API calls to certain packages. -
webhooks
:fishing_pole_and_fish: Webhook receiver for GitHub, Bitbucket, GitLab, Gogs -
githubql
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). -
twitter-scraper
Scrape the Twitter Frontend API without authentication with Golang. -
gostorm
GoStorm is a Go library that implements the communications protocol required to write Storm spouts and Bolts in Go that communicate with the Storm shells. -
hipchat (xmpp)
A golang package to communicate with HipChat over XMPP -
clarifai
DEPRECATED: please use https://github.com/Clarifai/clarifai-go-grpc -
go-trending
Go library for accessing trending repositories and developers at Github. -
go-lark
An easy-to-use SDK for Feishu and Lark Open Platform (Messaging API only) -
go-tgbot
Golang telegram bot API wrapper, session-based router and middleware -
simples3
Simple no frills AWS S3 Golang Library using REST with V4 Signing (without AWS Go SDK) -
go-postman-collection
Go module to work with Postman Collections -
ynab
Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.
Build time-series-based applications quickly and at scale.
Do you think we are missing an alternative of fbot or a related project?
Popular Comparisons
README
fbot
Bots for Facebook Messenger.
Description
A simple library for making bots for the Messenger Platform.
Installation
$ go get github.com/frodsan/fbot
Usage
package main
import (
"fmt"
"net/http"
"os"
"github.com/frodsan/fbot"
)
func main() {
bot := fbot.NewBot(fbot.Config{
AccessToken: os.Getenv("ACCESS_TOKEN"),
AppSecret: os.Getenv("APP_SECRET"),
VerifyToken: os.Getenv("VERIFY_TOKEN"),
})
bot.On(fbot.EventMessage, func(event *fbot.Event) {
fmt.Println(event.Message.Text)
bot.Deliver(fbot.DeliverParams{
Recipient: event.Sender,
Message: &fbot.Message{
Text: event.Message.Text,
},
})
})
http.Handle("/bot", fbot.Handler(bot))
http.ListenAndServe(":4567", nil)
}
API
fbot.NewBot(c Config)
NewBot creates a new instance of a bot with the application's access token, app secret, and verify token.
bot := fbot.NewBot(fbot.Config{
AccessToken: os.Getenv("ACCESS_TOKEN"),
AppSecret: os.Getenv("APP_SECRET"),
VerifyToken: os.Getenv("VERIFY_TOKEN"),
})
fbot.Handler(bot *fb.Bot)
Returns the http.Handler
that receives the request sent by the Messenger platform.
http.Handle("/bot", fbot.Handler(bot))
(*fbot.Bot) On(eventName string, callback func(*Event))
Registers a callback
for the given eventName
.
bot.On(fbot.EventMessage, func(event *fbot.Event) {
event.Sender.ID // => 1234567890
event.Recipient.ID // => 0987654321
event.Timestamp // => 1462966178037
event.Message.Mid // => "mid.1234567890:41d102a3e1ae206a38"
event.Message.Seq // => 41
event.Message.Text // => "Hello World!"
event.Message.Attachments[0].Type // => "image"
event.Message.Attachments[0].Payload.URL // => https://scontent.xx.fbcdn.net/v/t34.0-12/...
})
bot.On(fbot.EventDelivery, func(event *fbot.Event) {
event.Delivery.Mids[0] // => "mid.1458668856218:ed81099e15d3f4f233"
event.Delivery.Watermark // => 1458668856253
event.Delivery.Seq // => 37
})
bot.On(fbot.EventPostback, func(event *fbot.Event) {
event.Postback.Payload // => "{foo:'foo',bar:'bar'}"
})
(fbot.Bot) Deliver(params fbot.DeliverParams) error
Sent messages through the Messenger Platform.
bot.Deliver(fbot.DeliverParams{
Recipient: &fbot.User{
ID: 1234567890
},
Message: &fbot.Message{
Text: "Hey!",
},
})
Configuration
Follow the Messenger Platform quickstart guide for set up the needed Facebook page and development app.
Development
To test the bot locally, use ngrok.
Design
The API is heavily inspired by hyperoslo/facebook-messenger.
License
fbot is released under the MIT License.
*Note that all licence references and agreements mentioned in the fbot README section above
are relevant to that project's source code only.