I built an open-source adapter that connects Telnyx to Chat SDK, so you can build bots that send and receive SMS and MMS messages.
The adapter supports group MMS, scheduled messages, media attachments, and delivery receipts. It also verifies incoming Telnyx webhooks using Ed25519 signatures.
Getting started
Install the adapter alongside Chat SDK and a state adapter:
npm install chat-adapter-telnyx chat @chat-adapter/state-memory
Then configure it with your Telnyx API key, phone number, and public key:
import { createMemoryState } from "@chat-adapter/state-memory";
import { Chat } from "chat";
import { createTelnyxAdapter } from "chat-adapter-telnyx";
export const bot = new Chat({
userName: "mybot",
adapters: {
telnyx: createTelnyxAdapter({
apiKey: process.env.TELNYX_API_KEY!,
phoneNumber: process.env.TELNYX_PHONE_NUMBER!,
publicKey: process.env.TELNYX_PUBLIC_KEY!,
}),
},
state: createMemoryState(),
});
bot.onDirectMessage(async (thread, message) => {
await thread.post(`You said: ${message.text}`);
});
You’ll also need to route incoming Telnyx webhooks to bot.webhooks.telnyx. The README includes a Next.js example and setup details.
Why I built it
Chat SDK provides a common interface for building chat bots across platforms. I wanted to use that same approach for SMS and MMS through Telnyx.
The adapter is open source and available on GitHub and npm. Feedback, issues, and contributions are welcome.
Top comments (0)