bootdesk/chat-sdk-adapter-web
Composer 安装命令:
composer require bootdesk/chat-sdk-adapter-web
包简介
Web adapter for bootdesk/chat-sdk-core — browser chat UI via JSON request/response
README 文档
README
Generic web/REST adapter for the laravel-bootdesk multi-platform messaging framework.
Install
composer require bootdesk/chat-sdk-adapter-web
Configuration
use BootDesk\ChatSDK\Web\WebAdapter; use BootDesk\ChatSDK\Web\WebAdapterConfig; use BootDesk\ChatSDK\Core\Contracts\BroadcastAdapter; use Psr\Http\Message\ServerRequestInterface; class MyAppWebConfig extends WebAdapterConfig { public function getUser(ServerRequestInterface $request): ?array { return auth()->user() ? ['id' => (string) auth()->id(), 'name' => auth()->user()?->name] : null; } public function verifySignature(ServerRequestInterface $request): bool|string { $signature = $request->getHeaderLine('X-Signature'); $payload = (string) $request->getBody(); $expected = 'sha256=' . hash_hmac('sha256', $payload, config('app.webhook_secret')); return hash_equals($expected, $signature) ? true : 'Invalid signature'; } } $adapter = new WebAdapter( userName: env('WEB_USER_NAME', 'Bot'), config: new MyAppWebConfig, broadcaster: $broadcaster, // Optional: BroadcastAdapter instance asyncMode: true, // Optional: Enable async broadcasting );
Laravel config (config/chat.php):
'web' => [ 'user_name' => env('BOT_USERNAME', 'Bot'), 'config' => App\Chat\WebAdapterConfig::class, // extends BootDesk\ChatSDK\Web\WebAdapterConfig 'broadcaster' => fn () => app(BroadcastAdapter::class), 'async_mode' => env('CHAT_WEB_ASYNC_MODE', false), ],
The verifySignature() method receives the PSR-7 request and must return true for valid, or an error message string for invalid. Called before user auth.
Quick Example
// Post a message in a web session $adapter->postMessage('web:session-abc123', 'Hello from laravel-bootdesk!'); // Handle incoming webhook // POST body: {"text": "Hi", "userId": "user-1", "sessionId": "session-abc123"}
Thread ID Format
| Format | Description |
|---|---|
web:{userId}:{conversationId} |
User-conversation threading |
Webhook
Accepts POST requests with a JSON body:
{
"id": "optional-conversation-id",
"messages": [
{
"role": "user",
"id": "msg-1",
"text": "Hello",
"attachments": [
{"url": "https://example.com/file.pdf", "name": "Document", "type": "file"}
]
}
]
}
Authentication via $getUser closure — receives PSR-7 ServerRequestInterface, must return ['id' => string, 'name' => ?string] or null for 401.
Feature Matrix
| Feature | Supported |
|---|---|
| Post messages | ✓ |
| Edit messages | ✓ |
| Delete messages | ✓ |
| Reactions | ✓ |
| Typing indicator | ✓ |
| Fetch messages | ✓ |
| Fetch thread info | ✓ |
| Fetch channel info | ✗ |
| Get user | ✗ |
| Open DM | ✓ |
| Stream | ✓ |
| Broadcasting | ✓ |
Broadcasting
WebAdapter supports real-time event broadcasting via BroadcastAdapter:
use BootDesk\ChatSDK\Core\Contracts\BroadcastAdapter; $broadcaster = app(BroadcastAdapter::class); $adapter = new WebAdapter( userName: 'Bot', config: new MyAppWebConfig, broadcaster: $broadcaster, asyncMode: true, // Broadcast immediately; sync mode accumulates events );
Broadcast events: MessagePostedEvent, MessageEditedEvent, MessageDeletedEvent, ReactionAddedEvent, ReactionRemovedEvent, TypingStartedEvent, StreamingChunkEvent, DirectMessageRequestedEvent.
User-specific broadcasts (DMs, typing in DMs, streaming) use broadcastToUser() with PrivateChannel. Thread events use broadcast() with public Channel.
Notes
Generic adapter for web/REST integrations. Responses returned via createResponse() as JSON: {id, role: "assistant", text, events: []}.
Documentation
Full API documentation: https://bootdesk.github.io/chat-sdk
License
MIT
bootdesk/chat-sdk-adapter-web 适用场景与选型建议
bootdesk/chat-sdk-adapter-web 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 189 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bootdesk/chat-sdk-adapter-web 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bootdesk/chat-sdk-adapter-web 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 189
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-18