Common use cases: two-factor authentication, order confirmations, delivery notifications, abandoned cart recovery, appointment reminders, on-call paging.
Step 1: Set Up Twilio
1
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.
2
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.
3
Find your credentials
On the Console homepage, find your Account SID and Auth Token. Copy both.
4
Store in Hiveku
In your project, go to Settings > Environment Variables and add:
TWILIO_ACCOUNT_SIDTWILIO_AUTH_TOKENTWILIO_FROM_NUMBER— the number you bought, in E.164 format like+15551234567
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
1
User enters phone number
On signup or login, capture the user’s phone in E.164 format.
2
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
3
Send the SMS
4
Verify on entry
When the user enters the code, query the table: match phone + code, not expired, not used. If valid, mark used = true and mark the user’s phone as verified.
Receiving SMS (Webhooks)
When users reply to your SMS, Twilio can POST the message to your site:1
Create the webhook endpoint
api/sms-webhook.ts:2
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.3
Respond with TwiML for auto-reply (optional)
Cost Notes
Twilio charges per message:- US outbound: ~$0.0079/SMS
- Inbound: free
- International: varies widely by country
Verify It Worked
1
Hit your endpoint from the terminal
to with your own phone number.2
Check your phone
The SMS should arrive within a few seconds.
3
Check the Twilio logs
In the Twilio Console, Monitor > Logs > Messaging shows every send attempt, status, and any error codes.
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