Tendkit

Search documentation

Find a docs page

Get Started

Twilio

SMS and WhatsApp through a Twilio number or Messaging Service.

Install

Terminal
npx shadcn@latest add @tendkit/channel-twilio

It lands in lib/support/channels/. Import twilioChannel from there.

Set up

  1. Get a number

    Buy a number, or connect a WhatsApp sender, in the Twilio Console.

  2. Point incoming messages at your webhook

    Under "A message comes in", set the channel's webhook URL with POST, and pass the exact same URL as webhookUrl: Twilio signs it character for character.

  3. Create an API key

    Account → API keys. Pass it as apiKeySid and apiKeySecret; keep authToken for webhook signatures.

Configure

lib/support/index.ts
twilioChannel({
  id: "whatsapp",
  accountSid: process.env.TWILIO_ACCOUNT_SID!,
  authToken: process.env.TWILIO_AUTH_TOKEN!,
  apiKeySid: process.env.TWILIO_API_KEY_SID!,
  apiKeySecret: process.env.TWILIO_API_KEY_SECRET!,
  from: "whatsapp:+14155550133", // or "+14155550133" for SMS
  webhookUrl: "https://acme.com/api/webhooks/support/whatsapp",
})

Options

NameTypeDescription
id*stringStable channel id, stored on every ticket and used in the webhook URL. Never change it.
accountSid*string"AC…".
authToken*stringThe primary Auth Token. Twilio signs webhooks with it.
apiKeySid / apiKeySecretstringAn API key for REST calls; recommended over the Auth Token.
from*stringThe number: "+14155550133" for SMS, "whatsapp:+14155550133" for WhatsApp.
messagingServiceSidstringSend through a Messaging Service instead of from.
webhookUrl*stringThe exact public URL configured in Twilio.
statusCallbackUrlstringWhere delivery updates go. Defaults to webhookUrl.
addressstringShown to agents. Defaults to from without the whatsapp: prefix.

Behaviour

  • SMS: no attachments, 1,600 characters, billed per segment. Two-way SMS isn't available in every country; check Twilio's guidelines for yours.
  • WhatsApp: replies are allowed for 24 hours after the customer's last message. After that the composer explains why it can't send.