What is it?
The Twilio MODX Extra is an integration between MODX CMS and the Twilio API.
Why?
Capture a phone number on a form, and send an SMS message to the form submitter with an optional callback link. The callback can perform additional functions like create a MODX User record with the verified phone number.
You can also call the Snippets from Admin-only pages to give certain users the ability to send SMS messages programmatically. Requires a Twilio account and API credentials.
Usage Examples
Form to capture phone number
[[!FormIt?
&hooks=`twilio.send`
&twilio.callbackUrl=`[[~2]]`
&twilio.callbackFields=`number, country`
&twilio.callbackTpl=`my_callback_tpl`
]]
[[!+fi.error.twilio]]
[[!+twilio_output]]
<form method="POST">
<label for="name">Name</label>
<input type="text" name="name" id="name" value="">
<label for="number">Number</label>
<input type="text" name="number" id="number" value="">
<label for="country">Country</label>
<select name="country" id="country">
<option value="US" selected>United States</option>
<option value="UK">United Kingdom</option>
<option value="CA">Canada</option>
</select>
<button>Subscribe</button>
</form>
With the properties above you could render the my_callback_tpl
Chunk by calling the Snippet [[!twilio.getCallback]]
on Resource ID 2. Your Chunk might have something like:
Welcome [[+name]],
You've signed up to receive SMS messages at the number: [[+number]].
To cancel, reply to any message with "STOP".
Twilio supports opt-out keywords out-of-the-box, unless you have a custom short-code configured in your Twilio account.
Happy MODX-ing :)