botsframework

package module
v0.77.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

README ΒΆ

πŸ‹οΈ Strongo Bots Go Framework

A Go language framework to develop bots for messengers.

Developed & shared by Sneat-co & Strongo teams.

Reasons to use:

  • Same code can work across different messenger (Telegram, Facebook Messenger, Viber, Skype, Line, Kik, WeChat, etc.)
  • You can tune your code to a specific messenger's UX.
  • i18n & l10n support (multilingual)
  • Can be hosted in cloud or just as a standard Go HTTP server. Supports AppEngine standard environment.
  • It's fast

Our approach to development

We build with our own tooling:

  • SpecScore β€” specify requirements as SpecScore.md artifacts
  • SpecStudio β€” author & manage specs across their lifecycle
  • inGitDB β€” store structured data in Git where applicable
  • cover100.dev β€” drive toward 100% test coverage
  • DataTug β€” query & explore data

β™Ί Continuous Integration

Build and Test Go Report Card GoDoc Coverage Status - help with code coverage needed.

🍿 Usage

func InitBot(httpRouter HttpRouter, botHost bots.BotHost, appContext common.DebtsTrackerAppContext) {

	driver := bots.NewBotDriver( // Orchestrate requests to appropriate handlers
		bots.AnalyticsSettings{GaTrackingID: common.GA_TRACKING_ID}, // TODO: Refactor to list of analytics providers
		appContext,                                       // Holds User entity kind name, translator, etc.
		botHost,                                          // Defines how to create context.Context, HttpClient, DB, etc...
		"Please report any issues to @DebtsTrackerGroup", // Is it wrong place? Router has similar.
	)

	driver.RegisterWebhookHandlers(httpRouter, "/bot",
		telegram.NewTelegramWebhookHandler(
			telegramBotsWithRouter, // Maps of bots by code, language, token, etc...
			newTranslator, // Creates translator that gets a context.Context (for logging purpose)
		),
		viber.NewViberWebhookHandler(
			viber.Bots,
			newTranslator,
		),
		fbm.NewFbmWebhookHandler(
			fbm.Bots,
			newTranslator,
		),
	)
}
Published command ordering

Bot profiles can preserve their declared command order, sort all commands alphabetically, or pin important commands above an alphabetical remainder:

translations := botsfw.BotTranslations{
	Commands: []botsfw.BotCommand{
		{Command: "find", Description: "Find something"},
		{Command: "sports", Description: "Open sports"},
		{Command: "main", Description: "Open the main menu"},
	},
}
profile := botsfw.NewBotProfile(
	"profile_id",
	router,
	newBotChatData,
	newBotUserData,
	defaultLocale,
	supportedLocales,
	translations,
	botsfw.WithPublishedCommandOrder(
		botsfw.BotCommandOrderPinnedThenAlphabetical,
		"main",
		"sports",
	),
)

Pinned command codes are required configuration: every pinned code must occur exactly once in Commands. Invalid profile configuration fails fast instead of silently publishing a missing or duplicated command.

πŸ€– Sample bots built with Strongo Bots Framework

The best way to learn is to see examples of usage. Here is few:

We would be happy to place a link to your example / bot that is implemented using this framework.

πŸ“¦ Go API libraries used by the framework to talk to messengers

You can use any Bot API library by implementing couple of simple interface but the framework comes with few buildins:

πŸ“¦ Other Go libraries used by the bot framework

  • strongo/gamp - Golang buffered client for Google Analytics (GA) Measurement Protocol

Can I use β€” features cross-table for bot messenger APIs

We are building a cross-table of features supported by different bot APIs.

Persistence

bots-fw is persistence-neutral. Inject a botsfwstore.StateStore into each BotSettings; DALgo applications should use the optional bots-fw-store-dalgo adapter. The full architecture and code migration guide are in PERSISTENCE.md.

πŸ«‚ Contributors

πŸ“° Press

There are no articles about the Strongo Bots Framework just yet. Send us a link if you find such.

πŸ“œ License

Licensed under Apache 2.0 license

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
Package botplan defines the neutral message-plan model and the capability descriptor that per-platform renderers consult (the "capability-driven rendering" seam, layer 5 of the ToGethered conversation architecture).
Package botplan defines the neutral message-plan model and the capability descriptor that per-platform renderers consult (the "capability-driven rendering" seam, layer 5 of the ToGethered conversation architecture).
Package botsfwtest provides a fake in-memory WebhookContext implementation for testing bot command handlers without network, database, or platform dependencies.
Package botsfwtest provides a fake in-memory WebhookContext implementation for testing bot command handlers without network, database, or platform dependencies.
Package botstoken implements a compact, URL-safe token codec for (verb string, subject string, args map[string]string) triples.
Package botstoken implements a compact, URL-safe token codec for (verb string, subject string, args map[string]string) triples.
Package botswizard is a thin declarative wrapper over the framework's built-in wizard-param machinery (ChatData's AwaitingReplyTo plus AddWizardParam/GetWizardParam, where params ride in the AwaitingReplyTo query string and self-clear when it is reset).
Package botswizard is a thin declarative wrapper over the framework's built-in wizard-param machinery (ChatData's AwaitingReplyTo plus AddWizardParam/GetWizardParam, where params ride in the AwaitingReplyTo query string and self-clear when it is reset).
mocks
mock_botinput
Package mock_botinput is a generated GoMock package.
Package mock_botinput is a generated GoMock package.
mock_botmsg
Package mock_botmsg is a generated GoMock package.
Package mock_botmsg is a generated GoMock package.
mock_botsfw
Package mock_botsfw is a generated GoMock package.
Package mock_botsfw is a generated GoMock package.
mock_botsfwmodels
Package mock_botsfwmodels is a generated GoMock package.
Package mock_botsfwmodels is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL