Twilio SMS Worker
Send SMS messages through the Twilio messaging service.
Installation
import '@unchainedshop/plugins/worker/twilio';
Usage
You can send SMS with arbitrary providers through Unchained's work system. To add a new SMS to the system, you can use the addWork mutation:
mutation SendSMS {
addWork(type: "TWILIO", input: {
to: "+1234567890",
text: "Your order has shipped!",
from: "+0987654321" # Optional, defaults to TWILIO_SMS_FROM env var
}) {
_id
}
}
The Twilio worker plugin automatically picks up any work items with type TWILIO and sends them for you.
Input Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
to | String | Yes | Recipient phone number |
text | String | No | SMS message content |
from | String | No | Sender phone number (defaults to TWILIO_SMS_FROM) |
Additional Twilio API parameters can be passed and will be forwarded to the API.
Environment Variables
| Variable | Description |
|---|---|
TWILIO_ACCOUNT_SID | Your Twilio Account SID |
TWILIO_AUTH_TOKEN | Your Twilio Auth Token |
TWILIO_SMS_FROM | Default sender phone number (must be a Twilio number) |
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.worker-plugin.twilio |
| Type | TWILIO |
| Source | worker/twilio.ts |