npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chat-adapter-twilio

v0.1.0

Published

Twilio SMS adapter for the Vercel Chat SDK.

Downloads

112

Readme

chat-adapter-twilio

Twilio adapter for the Vercel Chat SDK — write your bot logic once and run it on SMS via Twilio.

Community adapter. The @chat-adapter/ npm scope is reserved for official Vercel adapters.

Install

pnpm add chat github:delphi-ai/chat-adapter-twilio twilio

You'll also need a state adapter (see chat-sdk.dev/state):

pnpm add @chat-adapter/state-memory       # dev
# or
pnpm add @chat-adapter/state-redis        # prod

Quick start

import { Chat } from "chat";
import { createTwilioAdapter } from "chat-adapter-twilio";
import { createMemoryState } from "@chat-adapter/state-memory";

const bot = new Chat({
  userName: "my-bot",
  adapters: { twilio: createTwilioAdapter() },
  state: createMemoryState(),
});

bot.onDirectMessage(async (thread, message) => {
  await thread.subscribe();
  await thread.post(`You said: ${message.text}`);
});

bot.onSubscribedMessage(async (thread, message) => {
  await thread.post({ markdown: `**Echo:** ${message.text}` });
});

Wire the webhook to whatever HTTP framework you use:

// app/api/twilio/route.ts (Next.js App Router)
export async function POST(request: Request) {
  return bot.webhooks.twilio(request);
}

Then in the Twilio Console, point your phone number's A MESSAGE COMES IN webhook to https://yourapp.com/api/twilio (POST, application/x-www-form-urlencoded).

Configuration

| Env var | Purpose | | --- | --- | | TWILIO_ACCOUNT_SID (req) | Twilio account SID (AC...) | | TWILIO_AUTH_TOKEN (req) | Auth token — used for both REST and webhook signature verification | | TWILIO_FROM_NUMBER | SMS sender (E.164 like +15551234567, or MG... Messaging Service SID) | | TWILIO_API_KEY_SID / TWILIO_API_KEY_SECRET | Recommended for production REST auth | | TWILIO_WEBHOOK_URL | Pin the URL used for signature verification (defaults to request.url) | | TWILIO_SKIP_VALIDATION | Set to 1 for local development only | | TWILIO_BOT_USERNAME | Bot display name (default twilio-bot) |

TWILIO_FROM_NUMBER must be set.

Channels

The Twilio adapter handles SMS messages:

  • SMS — bare E.164 numbers, plain-text bodies, formatting stripped

Feature matrix

| Feature | SMS | | --- | --- | | Post text | ✓ | | Markdown rendering | stripped to plain text | | Edit message | ✗ (Twilio doesn't support) | | Delete message | ✗ | | Reactions | ✗ (not supported by Programmable Messaging) | | Typing indicators | ✗ | | Streaming | buffered, single send | | Webhook signature verification | ✓ HMAC-SHA1 via validateRequest | | Status callbacks ignored | ✓ |

Security

Inbound webhooks are verified using the official twilio.validateRequest (HMAC-SHA1 over the URL + alphabetically-sorted form params, constant-time compared). If your platform terminates TLS or rewrites the URL, set TWILIO_WEBHOOK_URL (or pass webhookUrl in config) to the URL Twilio originally called.

Tests

pnpm test         # vitest run, 45 tests
pnpm typecheck    # tsc --noEmit
pnpm build        # tsup → dist/

License

MIT