Messages
Send text messages
Send WhatsApp text messages through wakit.
In wakit, sending a message is done by inserting a row into the messages table. A database trigger automatically picks it up and sends it via the WhatsApp Cloud API.
Prerequisites
- The contact must have messaged you within the last 24 hours (WhatsApp service window)
- If the window is closed, you must send a template message first
Via Supabase client
const { data, error } = await supabase
.from('messages')
.insert({
organization_id: 'your-org-id',
organization_address: 'phone-number-id', // your WhatsApp phone number ID
contact_address: '5215588392274', // recipient phone number
service: 'whatsapp',
direction: 'outgoing',
content: {
type: 'text',
text: { body: 'Hello from wakit!' }
}
});Via REST API
curl -X POST "https://{PROJECT_ID}.supabase.co/rest/v1/messages" \
-H "apikey: {ANON_KEY}" \
-H "Authorization: Bearer {USER_JWT}" \
-H "Content-Type: application/json" \
-d '{
"organization_id": "your-org-id",
"organization_address": "phone-number-id",
"contact_address": "5215588392274",
"service": "whatsapp",
"direction": "outgoing",
"content": {
"type": "text",
"text": { "body": "Hello from wakit!" }
}
}'Via MCP
If using the MCP server (e.g., from Claude Desktop):
Send "Hello from wakit!" to +5215588392274The MCP send_message tool handles service window validation automatically.
What happens after insert
- The
handle_outgoing_message_to_dispatchertrigger fires - The
whatsapp-dispatcherEdge Function picks up the message - The dispatcher calls the WhatsApp Cloud API to deliver it
- Status updates flow back:
sent→delivered→read
Content format
{
type: "text",
text: {
body: string, // message text (max 4096 chars)
preview_url?: boolean // enable URL preview
}
}