Send a message when a particular journey outcome requires a customer notification, such as an account-change alert. Darwinium supplies the destination and message, calls Twilio, and maps the immediate API response into the event.
This package sends an SMS. It does not implement an OTP challenge, verify ownership of the destination number or wait for delivery confirmation.
Prepare the sender and destination
Install Twilio – Send SMS, then copy twilio.snippet to a customer-specific filename and rename its twilio_sms template before adapting it. You need a Twilio Account SID, its authentication token, and an SMS-capable sender authorized for your account and destination.
Use a controlled test recipient for the first send. If the destination comes from the event, the default source is:
identity['ACCOUNT'].telephone['MOBILE'].e164_number
Map the complete international-format number to that attribute. An account alert should use the intended customer's trusted contact details; a newly submitted number is not automatically a verified contact.
Configure the template arguments
| Argument | Value |
|---|---|
account_sid |
Your Twilio Account SID |
from_phone |
The configured sender number |
dest_phone |
The destination attribute path, not a literal phone number |
message_body |
The text to send, for example Your account details were changed. Contact support if this was not you. |
The request POSTs to /2010-04-01/Accounts/{AccountSid}/Messages.json. It builds form fields Body, From and To; To reads the selected attribute at runtime.
Resolve the token before building Basic authentication
Map the token as twilio_auth_token using Secret Management. In your copied template, replace the packaged Authorization header with:
- name: Authorization
template: "Basic {{ ('{{account_sid}}:' ~ secret(twilio_auth_token)) | b64encode }}"
Here the snippet argument supplies the Account SID, and the runtime expression resolves the token before encoding the pair. Remove the unused auth_token argument from your custom template. Do not paste a secret expression into the original quoted username/token expression: that can encode the expression as text instead of the credential value.
Import the custom file and add the template to the selected step. Add a dependency on the operation that establishes the notification decision, then condition the send on that result. If the phone comes from the request, ensure its mapping has also completed.
Read the immediate response
The package maps:
| Attribute | Meaning |
|---|---|
integrations.twilio.sms.status |
Message status returned by the create request |
integrations.twilio.sms.error_code |
Error code when supplied |
integrations.twilio.sms.error_message |
Error description when supplied |
For provider-side tracing, add this response JSONPath mapping in your custom copy:
- name: $.sid
extract_to_attribute: custom.general_purpose['twilio_message_sid']
An accepted or queued message is not proof of delivery. If you need delivery outcomes, implement and correlate Twilio's status callbacks separately. See the Twilio Message resource.
Verify one send and the condition that controls it
Deploy with test credentials and a controlled recipient. Trigger the intended outcome once, inspect the mapped status and message SID, and check the corresponding message in Twilio. Then trigger an ordinary event and confirm the send condition remains false.
Test a missing phone and a rejected destination. Decide how repeat events and retries are deduplicated before enabling broad traffic; the supplied snippet does not prevent duplicate messages. Keep delivery tracking separate from the immediate API result in your decision strategy.