Login to follow
Twilio Messaging

Twilio Messaging (ODC)

Stable version 0.1.1 (Compatible with ODC)
Uploaded on 04 October 2025 by Ndilokelwa Luis
Twilio Messaging

Twilio Messaging (ODC)

Documentation
0.1.1

Setup

  1. Prereqs: Twilio account with either a Messaging Service or a sender number/WhatsApp sender. Templates (ContentSid) must be approved/linked.

  2. Secrets (Application Settings):

    • TWILIO_AccountSID (Text)

    • TWILIO_AuthToken (Secret)

    • TWILIO_MessagingServiceSID (Text)

  3. 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)

  • To (Text, required, E.164: +351…)

  • MediaUrl (Text, optional)

  • ContentSid (Text, optional)

  • ContentVariables (Text, optional JSON, e.g. {"1":"Ndilokelwa","2":"3pm"})

  • IsText (Bool, required)

  • IsUrl (Bool, required)

  • IsTemplate (Bool, required)

  • IsWhatsApp (Bool, required) → if True, prefixes whatsapp: to To.
    Rule: Exactly one of IsText, IsUrl, IsTemplate must be True (others False).

  • If IsText=TrueBody required.

  • If IsUrl=TrueMediaUrl required.

  • If IsTemplate=TrueContentSid required (optional ContentVariables).

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.

Outputs (both actions)

  • MessageSid (Text), Status (Text), ProviderCode (Integer), ProviderMessage (Text), RawResponse (Text).

Quick Examples

  • SMS text via Messaging Service:
    To="+244936036206", Body="Hello!", IsText=True, others False, IsWhatsApp=False.

  • MMS via Phone Number:
    From="+15551234567", To="+244936036206", MediaUrl="https://…/img.png", IsUrl=True, others False.

  • WhatsApp template via Messaging Service:
    To="+351911148523", ContentSid="HX…" , ContentVariables='{"1":"12/1","2":"3pm"}', IsTemplate=True, IsWhatsApp=True.

  • WhatsApp text via Phone Number (sandbox):
    From="+14155238886", To="+351911148523", Body="Olá!", IsText=True, IsWhatsApp=True.

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.