Skip to main content

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

ParameterTypeRequiredDescription
toStringYesRecipient phone number
textStringNoSMS message content
fromStringNoSender phone number (defaults to TWILIO_SMS_FROM)

Additional Twilio API parameters can be passed and will be forwarded to the API.

Environment Variables

VariableDescription
TWILIO_ACCOUNT_SIDYour Twilio Account SID
TWILIO_AUTH_TOKENYour Twilio Auth Token
TWILIO_SMS_FROMDefault sender phone number (must be a Twilio number)

Adapter Details

PropertyValue
Keyshop.unchained.worker-plugin.twilio
TypeTWILIO
Sourceworker/twilio.ts

External Resources