Common use cases: two-factor authentication, order confirmations, delivery notifications, abandoned cart recovery, appointment reminders, on-call paging.
Step 1: Set Up Twilio
Sign up for Twilio
Go to twilio.com and create an account. The free trial includes credit for testing, but you’ll only be able to send to numbers you’ve manually verified until you upgrade.
Buy a phone number
In the Twilio Console, go to Phone Numbers > Buy a Number. Pick one with SMS capabilities. US local numbers run about $1/month.
Step 2: Install the SDK
From your project’s code editor or terminal:Step 3: Create the Send Endpoint
Createapi/send-sms.ts:
https://yoursite.hiveku.com/api/send-sms.
Step 4: Call It from a Workflow
From any workflow, add an HTTP Request action pointing at your endpoint:Two-Factor Authentication Pattern
Generate a one-time code
Create a 6-digit numeric code. Store it in a
sms_codes table with:phone— the numbercode— the 6-digit stringexpires_at— now + 10 minutesused— false
Receiving SMS (Webhooks)
When users reply to your SMS, Twilio can POST the message to your site:Configure in Twilio
Console > Phone Numbers > click your number > Messaging section > set the Webhook to
https://yoursite.hiveku.com/api/sms-webhook and set method to HTTP POST.Cost Notes
Twilio charges per message:- US outbound: ~$0.0079/SMS
- Inbound: free
- International: varies widely by country
Verify It Worked
Troubleshooting
Trial account: can only send to verified numbers
Trial account: can only send to verified numbers
Until you upgrade to a paid account, Twilio restricts sends to numbers you’ve manually verified. Verify recipient numbers in Console > Phone Numbers > Verified Caller IDs, or upgrade to unlock unrestricted sending.
'Invalid From number' error
'Invalid From number' error
Use E.164 format with country code:
+15551234567, not (555) 123-4567 or 5551234567. Also confirm you’ve actually bought a number — the TWILIO_FROM_NUMBER must match an owned number in your Twilio account.Messages show 'delivered' but never arrive
Messages show 'delivered' but never arrive
Most often an A2P 10DLC registration issue — carriers silently drop unregistered A2P traffic. Complete registration in Twilio Console > Messaging > Regulatory Compliance > A2P 10DLC.
Webhook not firing on inbound SMS
Webhook not firing on inbound SMS
Check that the webhook URL in Twilio matches your live endpoint exactly (including protocol). Also check the request method is POST. Visit the endpoint directly in a browser — if you get a 404, the route isn’t deployed.
Costs adding up faster than expected
Costs adding up faster than expected
Switch marketing SMS to cheaper alternatives (email where possible, or push notifications for app users). Keep SMS for high-value use cases: 2FA, transactional confirmations, urgent alerts. Bulk marketing SMS gets expensive fast.
What’s Next?
Workflows
Trigger SMS from any workflow event
Environment Variables
Manage API keys and secrets safely