Skip to content

Releases: commune-dev/commune-js

v0.2.0 — Structured extraction, webhook factory, and SMS

01 Mar 05:27

Choose a tag to compare

Webhook handler factory, structured extraction per inbox, and full SMS support.

New in v0.2.0

Webhook handler factory

import { createWebhookHandler, verifyCommuneWebhook } from 'commune-ai';

const handler = createWebhookHandler({
  verify: ({ rawBody, headers }) => verifyCommuneWebhook({
    rawBody,
    timestamp: headers["x-commune-timestamp"] as string,
    signature: headers["x-commune-signature"] as string,
    secret: process.env.COMMUNE_WEBHOOK_SECRET!,
  }),
  onEvent: async (message, context) => {
    // message is typed UnifiedMessage
    // context.payload has inboxId, domainId, extractedData
    const reply = await agent.process(message.content);
    await client.messages.send({ to: sender, text: reply, thread_id: message.thread_id, inboxId: context.payload.inboxId });
  },
});

Structured extraction in webhook payload

When you've set a schema on an inbox, the extractedData field is populated in the webhook context:

onEvent: async (message, context) => {
  const { issueType, urgency, orderId } = context.payload.extractedData ?? {};
  // Route without an extra LLM call
}

SMS

const phone = await client.phoneNumbers.provision();
await client.sms.send({ to: "+14155551234", body: "Shipped!", phoneNumberId: phone.id });

v0.1.0 — Initial release: TypeScript SDK for agent email

01 Mar 05:27

Choose a tag to compare

First public release of commune-ai — the TypeScript/Node.js SDK for email and SMS in AI agents.

What's included

  • CommuneClient with full TypeScript types
  • client.inboxes.create(), client.messages.send(), client.threads.list()
  • client.searchConversations() — semantic search with typed results
  • createWebhookHandler() — Express/Fastify webhook handler factory
  • verifyCommuneWebhook() — HMAC-SHA256 signature verification
  • Attachment upload/download with temporary URLs
  • Structured extraction per inbox

Install

npm install commune-ai
import { CommuneClient } from 'commune-ai';

const client = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY! });
const inbox = await client.inboxes.create({ localPart: 'support' });
// → support@agents.commune.email

Works with any Node.js agent framework

LangChain.js, Vercel AI SDK, OpenAI Node SDK, or vanilla TypeScript. Full async/await, typed responses, zero dependencies beyond commune-ai.