Twilio engine for the Axion conversation framework.
Supports both SMS and WhatsApp-via-Twilio from a single engine.
ObjConversationWhatsapp uses Channel360 as its API provider and has its
own class structure (WhatsAppConversationHandler). This module uses
Twilio as the provider and follows the standard
ConversationInterface/ConversationBroker pattern.
The _EMOJI_MAP and _EMOJI_RE are imported directly from
ObjConversationWhatsapp — there is no duplication of the emoji system.
Sends messages via the Twilio REST Messages API using HTTP Basic
authentication (account_sid / auth_token).
Inherits from ObjConversationEngine.ConversationInterface.
Config section: twilio
| Key | Description |
|---|---|
account_sid |
Twilio Account SID |
auth_token |
Twilio Auth Token |
from_number |
Sender number — plain (+15551234567) for SMS or whatsapp:+14155238886 for WhatsApp |
Methods:
_init_client() — loads credentials from configtransmit_message(message, to_number="") — POSTs to the Twilio Messages API; applies emoji substitution; truncates at 1 600 charsdisplay_context(opts) — sends plain-text conversation/contact/page summarydisplay_options(opts) — numbered list (SMS-friendly); emoji placeholders resolved; returns (first_key, first_prompt)Handles the Twilio inbound webhook lifecycle.
Methods:
verify_signature(url, params, signature) — validates X-Twilio-Signature header using HMAC-SHA1 + base64 encodinghandle_webhook(form_data) — reads From and Body from the Twilio POST payload and routes to ObjConversation.read_conversation() with engine "TWILIO"run() — logs a deployment reminder; Twilio is always webhook-drivenThe only difference between SMS and WhatsApp-via-Twilio is the from_number:
| Mode | from_number |
|---|---|
| SMS | +15551234567 |
whatsapp:+14155238886 |
The to_number follows the same convention — prefix whatsapp: for WhatsApp
recipients.
config.yaml:twilio:
account_sid: ""
auth_token: ""
from_number: ""
broker.verify_signature(url, form_data, sig_header)broker.handle_webhook(form_data)Twilio signs every inbound request with X-Twilio-Signature. The algorithm:
key+value pairThis is implemented in verify_signature() and should be called before
handle_webhook() in production.