Resources
Examples
Code examples and templates for Sendable integration.
GitHub Examples
Next.js Full-Stack App
Complete Next.js application with Sendable integration, webhooks, and dashboard
Express REST API
REST API server with Express and Sendable webhook handling
Notification Service
Standalone notification microservice with retry logic and queue
Code Snippets
Send Notification
Simple notification sender with the SDK:
import { Sendable } from '@sendable-dev/sdk'
const sendable = new Sendable({
apiKey: process.env.SENDABLE_API_KEY!,
apiKeyScope: 'session',
})
async function sendNotification(chatId: string, message: string) {
return sendable.messages.send({
chatId,
text: { content: message },
})
}
// Usage
await sendNotification('[email protected]', 'Your order is ready!')Webhook Handler
Basic webhook receiver:
import express from 'express'
import { Sendable } from '@sendable-dev/sdk'
const sendable = new Sendable({
apiKey: process.env.SENDABLE_API_KEY!,
apiKeyScope: 'session',
webhookSecret: process.env.SENDABLE_WEBHOOK_SECRET,
})
app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
const payload = req.body.toString()
try {
const event = await sendable.webhooks.verifyAndParse(payload, req.headers)
console.log(event.type, event.data)
return res.sendStatus(200)
} catch {
return res.status(401).send('Invalid signature')
}
})Message Templates
Order Confirmation
const orderConfirmation = (order) => ({
chatId: `${order.customerPhone}@s.whatsapp.net`,
text: {
content: `Hi ${order.customerName}! Your order #${order.id} for ${order.total} has been confirmed.`,
},
})Shipping Update
const shippingUpdate = (order) => ({
chatId: `${order.customerPhone}@s.whatsapp.net`,
text: {
content: `Great news! Your order #${order.id} has shipped. Track: ${order.trackingUrl}`,
},
})Appointment Reminder
const appointmentReminder = (appt) => ({
chatId: `${appt.patientPhone}@s.whatsapp.net`,
text: {
content: `Reminder: Appointment with ${appt.doctorName} on ${appt.date} at ${appt.time}.`,
},
})Quick Start
See Quick Start for framework-specific examples.