Twilio SMS
Send SMS text messages through Twilio from your Spala flows.
Twilio SMS
The Twilio SMS addon lets you send text messages from your Spala flows using Twilio's messaging API. Use it for order confirmations, two-factor authentication codes, appointment reminders, and any other SMS notifications.
Installation
1. Enable the Twilio SMS addon from the Addons panel 2. Enter your Twilio credentials in the addon configuration
Configuration
Available Steps
Send SMS
Sends a text message to a phone number.
The step returns the Twilio message object:
{
sid: "SM...",
status: "queued",
to: "+1234567890",
from: "+0987654321",
body: "Your order has shipped!",
dateCreated: "2025-01-15T10:30:00Z"
}
Example: Order Notification
// Database trigger on insert for the "orders" table
// Step 1: Database Query - Get customer phone // SELECT phone FROM customers WHERE id = trigger.newRow.customer_id
// Step 2: Send SMS (Twilio addon) // to: vars.customer.phone // message: 'Your order #' + trigger.newRow.id + ' has been placed! Total:
Example: Two-Factor Authentication
// POST /api/auth/send-code
// Step 1: Set Variable - Generate code // vars.code = Math.floor(100000 + Math.random() * 900000).toString()
// Step 2: Database Query - Store the code // INSERT INTO verification_codes (user_id, code, expires_at) // VALUES (input.userId, vars.code, NOW() + INTERVAL '5 minutes')
// Step 3: Send SMS (Twilio addon) // to: vars.user.phone // message: 'Your verification code is: ' + vars.code + '. It expires in 5 minutes.'
// Step 4: Response
// { message: "Verification code sent" }
Phone numbers must be in E.164 format, which includes the country code prefix (e.g., +1 for US/Canada). Store phone numbers in this format in your database to avoid formatting issues.
Twilio charges per message sent. Use test credentials during development to avoid charges. Test credentials use the Account SID and Auth Token from the Twilio test environment.
Your Twilio Account SID from the Twilio Console dashboard. Your Twilio Auth Token from the Twilio Console dashboard. The Twilio phone number to send messages from (e.g., +1234567890). Recipient phone number in E.164 format (e.g., '+1234567890'). The text message input. Maximum 1,600 characters. Addons Overview /addons Browse available addons Installing Addons /addons/installing Enable and configure addons in your project + trigger.newRow.total.toFixed(2)
Example: Two-Factor Authentication
// POST /api/auth/send-code
// Step 1: Set Variable - Generate code // vars.code = Math.floor(100000 + Math.random() * 900000).toString()
// Step 2: Database Query - Store the code // INSERT INTO verification_codes (user_id, code, expires_at) // VALUES (input.userId, vars.code, NOW() + INTERVAL '5 minutes')
// Step 3: Send SMS (Twilio addon) // to: vars.user.phone // message: 'Your verification code is: ' + vars.code + '. It expires in 5 minutes.'
// Step 4: Response
// { message: "Verification code sent" }
Phone numbers must be in E.164 format, which includes the country code prefix (e.g., +1 for US/Canada). Store phone numbers in this format in your database to avoid formatting issues.
Twilio charges per message sent. Use test credentials during development to avoid charges. Test credentials use the Account SID and Auth Token from the Twilio test environment.
Your Twilio Account SID from the Twilio Console dashboard. Your Twilio Auth Token from the Twilio Console dashboard. The Twilio phone number to send messages from (e.g., +1234567890). Recipient phone number in E.164 format (e.g., '+1234567890'). The text message input. Maximum 1,600 characters. Addons Overview /addons Browse available addons Installing Addons /addons/installing Enable and configure addons in your project