PHPackages                             bootdesk/chat-sdk-adapter-twilio - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. bootdesk/chat-sdk-adapter-twilio

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bootdesk/chat-sdk-adapter-twilio
================================

Twilio adapter for bootdesk/chat-sdk-core — SMS and MMS via Twilio Messaging API

0.4.45(2w ago)0202↑116.7%MITPHPPHP &gt;=8.2

Since Jun 14Pushed 2w agoCompare

[ Source](https://github.com/bootdesk/chat-sdk-adapter-twilio)[ Packagist](https://packagist.org/packages/bootdesk/chat-sdk-adapter-twilio)[ RSS](/packages/bootdesk-chat-sdk-adapter-twilio/feed)WikiDiscussions main Synced 1w ago

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

Twilio Adapter for Chat SDK
===========================

[](#twilio-adapter-for-chat-sdk)

SMS and MMS adapter for [bootdesk/chat-sdk-core](https://github.com/bootdesk/chat-sdk). Build SMS and MMS bots with Twilio Messaging webhooks and the Messages API.

Installation
------------

[](#installation)

```
composer require bootdesk/chat-sdk-adapter-twilio
```

Usage
-----

[](#usage)

```
use BootDesk\ChatSDK\Twilio\TwilioAdapter;
use BootDesk\ChatSDK\Core\Chat;
use Nyholm\Psr7\Factory\Psr17Factory;
use Http\Discovery\Psr18Client;

$httpClient = Psr18Client::create();
$psrFactory = new Psr17Factory;

$bot = new Chat([
    'adapters' => [
        'twilio' => new TwilioAdapter(
            accountSid: getenv('TWILIO_ACCOUNT_SID'),
            authToken: getenv('TWILIO_AUTH_TOKEN'),
            httpClient: $httpClient,
            phoneNumber: getenv('TWILIO_PHONE_NUMBER'),
            psrFactory: $psrFactory,
        ),
    ],
]);

$bot->onDirectMessage(fn ($thread, $message) => {
    $thread->post("You said: {$message->text}");
});
```

Configuration
-------------

[](#configuration)

ParameterDescription`accountSid`Twilio Account SID`authToken`Twilio Auth Token`phoneNumber`Sender phone number (e.g., `+15551234567`)`messagingServiceSid`Messaging Service SID (starts with `MG`)`webhookUrl`Public webhook URL (for signature verification)`statusCallbackUrl`URL for delivery status callbacks`apiUrl`Twilio API base URL (default: `https://api.twilio.com`)Use `phoneNumber` for a single Twilio number, or `messagingServiceSid` when sending through a Twilio Messaging Service.

Webhook
-------

[](#webhook)

Point your Twilio Messaging webhook to a route that calls the Chat:

```
$response = $bot->handleWebhook('twilio', $request);
```

The adapter verifies the `x-twilio-signature` header using HMAC-SHA1 and your auth token.

Media
-----

[](#media)

Inbound MMS media is exposed as attachments. Each attachment carries `fetchData: [$adapter, 'fetchMedia']` — a callable that returns a PSR-7 `StreamInterface` with HTTP Basic auth. Use `$attachment->read(): ?StreamInterface` to access the body.

### Serialization &amp; Queue Jobs

[](#serialization--queue-jobs)

`Attachment::__serialize()` strips `fetchData` (not serializable). After deserialization in a queue job, `Chat::dispatchIncomingMessage()` auto-rehydrates attachments via the `MustRehydrateAttachments` interface — calls `$adapter->rehydrateAttachment($attachment)` to restore the authenticated callable.

For manual rehydration outside the Chat flow:

```
$rehydrated = $adapter->rehydrateAttachment($attachment);
$stream = $rehydrated->read();
$body = (string) $stream;
```

Outbound MMS supports attachments with public `url` values.

Thread IDs
----------

[](#thread-ids)

Format: `twilio:{sender}:{recipient}` — both components are URI-encoded.

```
$threadId = $adapter->encodeThreadId([
    'sender' => '+15551234567',   // bot's number
    'recipient' => '+15557654321', // user's number
]);
// "twilio:%2B15551234567:%2B15557654321"
```

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance97

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

27

Last Release

15d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3874705?v=4)[Vin](/maintainers/tryvin)[@tryvin](https://github.com/tryvin)

---

Top Contributors

[![tryvin](https://avatars.githubusercontent.com/u/3874705?v=4)](https://github.com/tryvin "tryvin (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bootdesk-chat-sdk-adapter-twilio/health.svg)

```
[![Health](https://phpackages.com/badges/bootdesk-chat-sdk-adapter-twilio/health.svg)](https://phpackages.com/packages/bootdesk-chat-sdk-adapter-twilio)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k17](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M426](/packages/drupal-core-recommended)[laudis/neo4j-php-client

Neo4j-PHP-Client is the most advanced PHP Client for Neo4j

185702.8k44](/packages/laudis-neo4j-php-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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