Download the PHP package torgodly/messenger-bot without Composer

On this page you can find all versions of the php package torgodly/messenger-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package messenger-bot

torgodly/messenger-bot

Facebook Messenger webhooks for Laravel (messages, postbacks, quick replies, feed comments). BotMan-style API (hears, payload, onComment) without BotMan.

PHP 8.3+ · Laravel 12 or 13 · Composer ^2.2


Quick start

Single Facebook Page (default)

Register handlers in AppServiceProvider::boot(). No tenant config.

Multi-tenant (many Pages)

Set in .env (no quotes around the FQCN):

Your model must extend Eloquent Model and implement MessengerBot\Contracts\MessengerConnectable (trait InteractsWithMessengerConnection is recommended). Wrong model class fails fast in local / testing.

Business rules (enforced by your app via ValidatesMessengerPageLink):


Meta Developer checklist

Step What to do
App Messenger product + Facebook Login; add your Page.
OAuth redirect Exact match: https://YOUR-DOMAIN/messenger-bot/oauth/facebook/callback (or MESSENGER_BOT_OAUTH_REDIRECT_URI). Production needs HTTPS; APP_URL must match.
Webhook Callback https://YOUR-DOMAIN/webhook/messenger, verify token = MESSENGER_BOT_VERIFY_TOKEN.
Fields Enable fields in config webhook_fields — include feed for Page comments. messenger-bot:install / sync-page can subscribe via Graph.
Tokens Production: MESSENGER_BOT_PAGE_TOKEN_CACHE_STORE and/or MESSENGER_BOT_CONNECTION_TOKEN_CACHE_STORE = redis or database.

Routes register outside the web middleware group (avoids CSRF 419 on Meta POSTs).


Handlers

Optional host config comment_handlers.queue — infrastructure only; the package does not ship DB comment rules. See README-EXTERNAL-RULES.md.


Multi-tenant

Config / env Purpose
tenancy.connection_model / MESSENGER_BOT_TENANCY_CONNECTION_MODEL Eloquent class implementing MessengerConnectable
tenancy.connection_page_id_column / MESSENGER_BOT_TENANCY_PAGE_ID_COLUMN Column matched to Meta Page ID (default facebook_page_id; many apps use page_id)
Model messengerFacebookPageIdColumn() Override column name on the model

OAuth redirect:

Multi-Page OAuth flow (no package UI)

Facebook may return 0, 1, or many managed Pages.

Count Behaviour
0 Error 400
1 CompleteOAuthPageLink stores token → redirect success
2+ Not an error. No token stored. All Pages cached → redirect MESSENGER_BOT_OAUTH_PENDING_PAGES_URL?token=<opaque>

Your app shows a Page picker (Filament, Livewire, etc.). After the user chooses:

ValidatesMessengerPageLink — implement in your app:

On rejection, OAuth redirect uses session flash key messenger_bot_oauth_error.

Optional: MESSENGER_BOT_OAUTH_PREFERRED_PAGE_ID — when exactly one Page in the list matches, link immediately (skip pending redirect).

Env Purpose
MESSENGER_BOT_OAUTH_PENDING_PAGES_URL Required when tenancy enabled
MESSENGER_BOT_OAUTH_PENDING_PAGES_TTL Cache minutes (default 10)
MESSENGER_BOT_OAUTH_PENDING_PAGES_CACHE_PREFIX Default messenger_bot:oauth_pages:
MESSENGER_BOT_VALIDATES_PAGE_LINK FQCN for validator (required when tenancy enabled)

Webhook context:

Resolver behaviour: looks up the model by Page ID column; if missing, falls back to the connection token page index and fires ConnectablePageIdSynced so your app can persist page_id on the row.

Advanced: MESSENGER_BOT_TENANCY_RESOLVER for a custom TenantResolver; optional EloquentMessengerTenantResolver subclass (see stubs/eloquent_messenger_tenant_resolver.php.stub).


After OAuth automation

When multi-tenant OAuth stores a token, ConnectionTokenStored runs. Enable automatic webhook subscribe + persistent menu sync:

Config block: messenger-bot.after_connection_token_stored. Replaces most host wrappers around ConnectionTokenRepository::put().

On failure, the package logs and may queue SyncPageProfileAfterOAuthJob when queue_retry_on_failure is true.


Events

Event When
WebhookReceived Raw webhook payload
MessageReceived Incoming message
PostbackReceived Postback
CommentCreated Top-level feed comment
ConnectionTokenStored After ConnectionTokenRepository::put()
ConnectablePageIdSynced Tenant resolved from token index (DB page_id empty)
PostsSynced, PostsCacheHit, PostsCacheMiss Posts sync
Outgoing OutgoingMessage* Send pipeline

DB-driven rules (your app)

The package does not store tenant rules. Load rules from your database inside handlers or a small engine — no optimize:clear needed.

Guide: README-EXTERNAL-RULES.md

Reference implementation: Matager

Matager (not included in this package) shows a production pattern:

Use Matager as a reference; copy patterns, not the package.


Page posts, Artisan, troubleshooting

Posts: SyncsFacebookPagePosts, PostsSyncRequest::forConnectable(), RefreshPostsCacheJob::forConnectable() — see previous examples in CHANGELOG / v2.0 notes.

Artisan: messenger-bot:install, install --tenant --model=, sync-page, token-status, clear-page-token.

Troubleshooting

Symptom Check
Comments ignored / tenant_unresolved feed subscribed; MESSENGER_BOT_TENANCY_CONNECTION_MODEL + MESSENGER_BOT_TENANCY_PAGE_ID_COLUMN; Page linked via OAuth; token cache has page index
Webhook 403 MESSENGER_BOT_APP_SECRET matches Meta
OAuth / webhook 419 Routes must not use web CSRF; package registers outside web by default
Invalid tenancy model Exception in local/testing; production logs critical and disables configurable resolver

Upgrade 2.12.2

  1. composer require torgodly/messenger-bot:^2.2
  2. Set MESSENGER_BOT_OAUTH_PENDING_PAGES_URL and MESSENGER_BOT_VALIDATES_PAGE_LINK when tenancy is on
  3. Implement ValidatesMessengerPageLink for Page/tenant uniqueness
  4. Build a Page picker route that reads ?token=, calls PendingOAuthPages::pull(), then CompleteOAuthPageLink::complete()
  5. Breaking: multiple Pages from OAuth are no longer auto-linked to the first Page

Upgrade 2.02.1

  1. composer require torgodly/messenger-bot:^2.1
  2. Publish / merge config for after_connection_token_stored and comment_handlers
  3. Replace host put() wrappers with MESSENGER_BOT_AUTO_SUBSCRIBE_AFTER_OAUTH / MESSENGER_BOT_AUTO_SYNC_MENU_AFTER_OAUTH
  4. Listen to ConnectionTokenStored for DB hydration (page_id) instead of wrapping the repository
  5. Remove custom resolvers that only duplicated token page-index lookup — use package fallback + ConnectablePageIdSynced

References


All versions of messenger-bot with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
illuminate/support Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/events Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/cache Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/bus Version ^12.0|^13.0
illuminate/queue Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package torgodly/messenger-bot contains the following files

Loading the files please wait ...