定制 bootdesk/chat-sdk-adapter-messenger 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bootdesk/chat-sdk-adapter-messenger

Composer 安装命令:

composer require bootdesk/chat-sdk-adapter-messenger

包简介

Facebook Messenger adapter for bootdesk/chat-sdk-core

README 文档

README

Facebook Messenger adapter for the laravel-bootdesk multi-platform messaging framework.

Install

composer require bootdesk/chat-sdk-adapter-messenger

Requires a PSR-18 HTTP client (guzzlehttp/guzzle, symfony/http-client, etc.) and a PSR-17 factory (nyholm/psr7 bundled).

Configuration

Variable Description Example
page_access_token Facebook Page Access Token EAAx...
http_client PSR-18 HTTP client instance new GuzzleHttp\Client
app_secret Facebook App Secret abc123...
verify_token Webhook Verify Token my-verify-token
use BootDesk\ChatSDK\Messenger\MessengerAdapter;

$adapter = new MessengerAdapter(
    pageAccessToken: env('MESSENGER_PAGE_ACCESS_TOKEN'),
    httpClient: new \GuzzleHttp\Client,
    appSecret: env('MESSENGER_APP_SECRET'),
    verifyToken: env('MESSENGER_VERIFY_TOKEN'),
);

Laravel

The ChatServiceProvider auto-binds Psr\Http\Client\ClientInterface to GuzzleHttp\Client. Add to config/chat.php:

'messenger' => [
    'page_access_token' => env('MESSENGER_PAGE_ACCESS_TOKEN'),
    'app_secret'        => env('MESSENGER_APP_SECRET'),
    'verify_token'      => env('MESSENGER_VERIFY_TOKEN'),
],

Quick Example

// Send a message to a user
$adapter->postMessage('messenger:1234567890', 'Hello from laravel-bootdesk!');

Text Formatting

Messenger supports *bold*, _italic_, ~strikethrough~, `monospace`, and code blocks syntax. The SDK's MessengerFormatConverter automatically converts standard markdown (**bold**, ~~strike~~) to Messenger format when sending, and converts Messenger syntax back to standard markdown when receiving.

Message Templates

Messenger supports rich message templates via PostableMessage::template() with MessengerTemplate:

use BootDesk\ChatSDK\Messenger\MessengerTemplate;

// Button template
$adapter->postMessage('messenger:1234567890', PostableMessage::template(
    MessengerTemplate::create('options')
        ->buttonTemplate('Choose an option', [
            ['type' => 'postback', 'title' => 'Yes', 'payload' => 'YES'],
            ['type' => 'postback', 'title' => 'No', 'payload' => 'NO'],
        ])
));

// Generic template (carousel)
$adapter->postMessage('messenger:1234567890', PostableMessage::template(
    MessengerTemplate::create('catalog')
        ->genericTemplate([
            [
                'title' => 'Product A',
                'subtitle' => 'Best seller',
                'image_url' => 'https://example.com/a.jpg',
                'default_action' => ['type' => 'web_url', 'url' => 'https://example.com/a'],
                'buttons' => [['type' => 'web_url', 'title' => 'Buy', 'url' => 'https://example.com/a/buy']],
            ],
        ])
));

// Media template
$adapter->postMessage('messenger:1234567890', PostableMessage::template(
    MessengerTemplate::create('intro')
        ->mediaTemplate('https://example.com/video.mp4', 'video', [
            'type' => 'web_url', 'title' => 'Learn More', 'url' => 'https://example.com',
        ])
));

All Template Types

Method Template Type
buttonTemplate(string $text, array $buttons) Button — text with up to 3 buttons
genericTemplate(array $elements) Generic — cards with title, subtitle, image, buttons
mediaTemplate(string $url, string $mediaType, ?array $button) Media — image/video with optional button
receiptTemplate(recipientName, orderNumber, currency, ...) Receipt — order confirmation
productTemplate(string $productId) Product — catalog product card
couponTemplate(title, code, ...) Coupon — promotional offer
customerFeedbackTemplate(title, businessAddress, ratingOptions, ...) Customer Feedback — native survey

Cards from the SDK Card class (title, sections, images, buttons) are automatically rendered as button or generic templates.

Thread ID Format

Format Description
messenger:{senderId} One thread per sender

Webhook

Facebook sends webhook events to your endpoint. Verify requests using HMAC signature verification with the app secret (X-Hub-Signature-256 header).

Feature Matrix

Feature Supported
Post messages
Edit messages
Delete messages
Reactions
Slash commands
Typing indicator
Fetch messages
Fetch thread info
Fetch channel info
Get user
Open DM
Stream

Notes

Facebook Messenger Platform. Supports quick replies, persistent menu, and get started button. Rich templates available via MessengerTemplate (button, generic, media, receipt, product, coupon, customer feedback).

Documentationn

Full API documentation: https://bootdesk.github.io/chat-sdk

License

MIT

bootdesk/chat-sdk-adapter-messenger 适用场景与选型建议

bootdesk/chat-sdk-adapter-messenger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 191 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 bootdesk/chat-sdk-adapter-messenger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bootdesk/chat-sdk-adapter-messenger 我们能提供哪些服务?
定制开发 / 二次开发

基于 bootdesk/chat-sdk-adapter-messenger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 191
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-18