Setup
Prereqs: Twilio account with either a Messaging Service or a sender number/WhatsApp sender. Templates (ContentSid) must be approved/linked.
Secrets (Application Settings):
TWILIO_AccountSID (Text)
TWILIO_AccountSID
TWILIO_AuthToken (Secret)
TWILIO_AuthToken
TWILIO_MessagingServiceSID (Text)
TWILIO_MessagingServiceSID
Authentication (ODC Portal → Integrations → Twilio REST):
Basic Auth → Username = TWILIO_AccountSID, Password = TWILIO_AuthToken.
Body format is application/x-www-form-urlencoded (already set in the library).
Server Actions
1) SendViaMessagingService
Uses TWILIO_MessagingServiceSID as sender.Inputs:
Body (Text, optional)
Body
To (Text, required, E.164: +351…)
To
+351…
MediaUrl (Text, optional)
MediaUrl
ContentSid (Text, optional)
ContentSid
ContentVariables (Text, optional JSON, e.g. {"1":"Ndilokelwa","2":"3pm"})
ContentVariables
{"1":"Ndilokelwa","2":"3pm"}
IsText (Bool, required)
IsText
IsUrl (Bool, required)
IsUrl
IsTemplate (Bool, required)
IsTemplate
IsWhatsApp (Bool, required) → if True, prefixes whatsapp: to To.Rule: Exactly one of IsText, IsUrl, IsTemplate must be True (others False).
IsWhatsApp
whatsapp:
If IsText=True → Body required.
IsText=True
If IsUrl=True → MediaUrl required.
IsUrl=True
If IsTemplate=True → ContentSid required (optional ContentVariables).
IsTemplate=True
2) SendFromPhoneNumber
Sends from an explicit number/sender.Inputs: Same as above plus From (Text, required, E.164: +351…).IsWhatsApp=True prefixes whatsapp: to both To and From.
From
IsWhatsApp=True
Outputs (both actions)
MessageSid (Text), Status (Text), ProviderCode (Integer), ProviderMessage (Text), RawResponse (Text).
MessageSid
Status
ProviderCode
ProviderMessage
RawResponse
Quick Examples
SMS text via Messaging Service:To="+244936036206", Body="Hello!", IsText=True, others False, IsWhatsApp=False.
To="+244936036206"
Body="Hello!"
IsWhatsApp=False
MMS via Phone Number:From="+15551234567", To="+244936036206", MediaUrl="https://…/img.png", IsUrl=True, others False.
From="+15551234567"
MediaUrl="https://…/img.png"
WhatsApp template via Messaging Service:To="+351911148523", ContentSid="HX…" , ContentVariables='{"1":"12/1","2":"3pm"}', IsTemplate=True, IsWhatsApp=True.
To="+351911148523"
ContentSid="HX…"
ContentVariables='{"1":"12/1","2":"3pm"}'
WhatsApp text via Phone Number (sandbox):From="+14155238886", To="+351911148523", Body="Olá!", IsText=True, IsWhatsApp=True.
From="+14155238886"
Body="Olá!"
Tips & Troubleshooting
Use E.164 with leading +. With IsWhatsApp=True, the library adds whatsapp: automatically.
+
Don’t mix modes (Text/URL/Template) in one call; the flags enforce this.
Templates fail if not approved/linked or variables don’t match.
On errors, check ProviderCode/ProviderMessage and RawResponse for the exact Twilio reason.
ProviderCode/ProviderMessage