PHPackages                             shudhuiami/messenger-commerce-bot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shudhuiami/messenger-commerce-bot

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shudhuiami/messenger-commerce-bot
=================================

Facebook Messenger auto-reply, product Q&amp;A, and order-taking bot for Laravel e-commerce apps. Schema-agnostic via host-implemented contracts.

v1.0.1(1mo ago)010↓50%MITPHPPHP ^8.3

Since Jun 23Pushed 1mo agoCompare

[ Source](https://github.com/shudhuiami/messenger-commerce-bot)[ Packagist](https://packagist.org/packages/shudhuiami/messenger-commerce-bot)[ Docs](https://github.com/shudhuiami/messenger-commerce-bot)[ RSS](/packages/shudhuiami-messenger-commerce-bot/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

Messenger Commerce Bot
======================

[](#messenger-commerce-bot)

Facebook Messenger auto-reply, product Q&amp;A, and order-taking bot for Laravel e-commerce apps. Schema-agnostic: the package never queries your database directly — you implement three small contracts that map onto whatever your `Product`/`Order`/`Settings` tables actually look like.

What it does
------------

[](#what-it-does)

- Verifies and receives the official Messenger webhook (`GET`/`POST /messenger/webhook`).
- Rule-based product Q&amp;A: search by name/brand/category/description, "latest products", "cheapest X", numbered multi-match selection — all deterministic, no AI involved.
- A guided order flow entirely in chat: product → quantity → name (first order only) → delivery address → phone → confirmation summary → YES/CANCEL. Order creation always goes through **your** `OrderCreator` implementation — the package never computes prices or writes order rows itself.
- Optional free Groq AI fallback (, no card required) for anything the rule-based matching can't parse — including a multilingual intent classifier so non-English customers asking "show me everything" or about a specific product still get the real product list / real product data, not just a conversational guess. AI is **never** used for order creation or pricing.
- Admin-friendly: conversations and messages are stored in their own tables (`messenger_customers`, `messenger_conversations`, `messenger_messages`, `messenger_sessions`) so you can build your own admin UI on top.

Install (in a new project, via Packagist)
-----------------------------------------

[](#install-in-a-new-project-via-packagist)

```
composer require shudhuiami/messenger-commerce-bot
php artisan vendor:publish --tag=messenger-bot-config
```

Then implement the three contracts (see below) and point `config/messenger-bot.php`'s `bindings` array at your classes.

Install (within this monorepo, as a local path package)
-------------------------------------------------------

[](#install-within-this-monorepo-as-a-local-path-package)

This is how GachGachra itself uses it — already wired into the root `composer.json` as a path repository, so it stays editable in lockstep with the app instead of requiring a tag/publish cycle for every change. Run:

```
composer install
```

If you want to develop the package itself this way in another project (instead of pulling the published version), copy the `packages/messenger-commerce-bot` directory in and add:

```
"repositories": [
    { "type": "path", "url": "packages/messenger-commerce-bot", "options": { "symlink": true } }
],
"require": {
    "shudhuiami/messenger-commerce-bot": "@dev"
}
```

then `composer update`, `php artisan vendor:publish --tag=messenger-bot-config`, implement the three contracts, point `config/messenger-bot.php`'s `bindings` array at your classes. 6. Add to `.env`:

```
MESSENGER_VERIFY_TOKEN=
MESSENGER_PAGE_ACCESS_TOKEN=
MESSENGER_GRAPH_VERSION=v19.0
MESSENGER_PAGE_USERNAME=
GROQ_API_KEY=
GROQ_MODEL=llama-3.3-70b-versatile

```

7. Exempt the webhook from CSRF in `bootstrap/app.php`: ```
    $middleware->validateCsrfTokens(except: ['messenger/webhook']);
    ```
8. `php artisan migrate`

The three contracts you implement
---------------------------------

[](#the-three-contracts-you-implement)

### `ProductRepository`

[](#productrepository)

Maps the bot's product search/listing onto your actual `Product` (or equivalent) model/table. Every method returns `ProductData` DTOs, never your Eloquent models directly — translate your model's fields into the DTO in your adapter.

```
class EloquentProductRepository implements ProductRepository
{
    public function find(int $id): ?ProductData { /* ... */ }
    public function searchByTitle(string $query, int $limit): array { /* ... */ }
    public function searchByBrand(string $query, int $limit): array { /* ... */ }
    public function searchByCategory(string $query, int $limit): array { /* ... */ }
    public function searchByDescription(string $query, int $limit): array { /* ... */ }
    public function latest(int $limit): array { /* ... */ }
    public function bestSelling(int $limit): array { /* ... */ }
    public function cheapestInCategory(string $categoryName, int $limit): array { /* ... */ }
}
```

Only return active/published/in-stock products per your own conventions — the bot does not filter further.

### `OrderCreator`

[](#ordercreator)

Creates a real order using **your** order system. The bot calls `create()` exactly once per confirmed order (it already guards against double-calling for the same conversation) and `find()` to redisplay an existing order's details if a duplicate confirmation slips through.

```
class EloquentOrderCreator implements OrderCreator
{
    public function create(CustomerData $customer, OrderRequestData $request): ?OrderResult { /* ... */ }
    public function find(int|string $orderId): ?OrderResult { /* ... */ }
}
```

Return `null` from `create()` if the order can't be placed (out of stock, product inactive, etc.) — the bot tells the customer gracefully instead of pretending it worked.

### `StoreInfoResolver`

[](#storeinforesolver)

Grounds the AI fallback's free-text replies in real store facts so it can't invent a category, brand, or contact detail.

```
class SettingsStoreInfoResolver implements StoreInfoResolver
{
    public function siteName(): string { /* ... */ }
    public function contactPhone(): ?string { /* ... */ }
    public function address(): ?string { /* ... */ }
    public function activeCategoryNames(): array { /* ... */ }
    public function activeBrandNames(): array { /* ... */ }
}
```

Safety notes
------------

[](#safety-notes)

- Order creation, pricing, and stock checks always go through your own `OrderCreator`/`ProductRepository` implementations — the AI fallback (Groq) is only ever used to generate the *text* of an answer to an open-ended question, or to classify a non-English message into one of three known intents that then dispatch into the same deterministic handlers as English. It never writes to your database or computes a price.
- Without `GROQ_API_KEY` configured, the bot still works — it just falls back to a canned "could not find that product" message for anything outside its rule-based patterns instead of an AI-generated reply.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

44d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/98706?v=4)[Zobayer Hasan](/maintainers/zobayer)[@zobayer](https://github.com/zobayer)

---

Tags

laravelfacebooke-commerceMessengerchatbotgroq

### Embed Badge

![Health badge](/badges/shudhuiami-messenger-commerce-bot/health.svg)

```
[![Health](https://phpackages.com/badges/shudhuiami-messenger-commerce-bot/health.svg)](https://phpackages.com/packages/shudhuiami-messenger-commerce-bot)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M353](/packages/psalm-plugin-laravel)[laravel/scout

Laravel Scout provides a driver based solution to searching your Eloquent models.

1.7k57.2M664](/packages/laravel-scout)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k16.3M146](/packages/laravel-pulse)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[api-platform/laravel

API Platform support for Laravel

58174.6k18](/packages/api-platform-laravel)[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2115.6k](/packages/alajusticia-laravel-logins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
