Releases: commune-dev/commune-js
Releases · commune-dev/commune-js
v0.2.0 — Structured extraction, webhook factory, and SMS
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
First public release of commune-ai — the TypeScript/Node.js SDK for email and SMS in AI agents.
What's included
CommuneClientwith full TypeScript typesclient.inboxes.create(),client.messages.send(),client.threads.list()client.searchConversations()— semantic search with typed resultscreateWebhookHandler()— Express/Fastify webhook handler factoryverifyCommuneWebhook()— HMAC-SHA256 signature verification- Attachment upload/download with temporary URLs
- Structured extraction per inbox
Install
npm install commune-aiimport { 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.emailWorks 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.