1.0.14 • Published 2 years ago

moleculer-twilio v1.0.14

Weekly downloads
85
License
MIT
Repository
github
Last release
2 years ago

Moleculer logo

moleculer-twilio NPM version

Send SMS using Twilio API.

Install

$ npm install moleculer-twilio --save

Usage

Before use please set the TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN and TWILIO_PHONE_NUMBER environment variables.

let { ServiceBroker }     = require("moleculer");
let SmsService             = require("../../index");

// Create broker
let broker = new ServiceBroker({ logger: console });

// Load my service
broker.createService({
    name: "twilio",
    mixins: [SmsService],
    settings: {
        phoneNumber: "+15005550006"
    }
});

// Start server
broker.start().then(() => {

    broker
        .call("twilio.send", { to: "+14108675309", message: "Hello Twilio!" })
        .then(sms => console.log("SMS sent. Sid:", sms.sid))
        .catch(console.error);

});

Settings

PropertyTypeDefaultDescription
accountSidStringrequiredTwilio account Sid. Visit your Twilio dashboard's main page. Click "Show API Credentials", then copy and paste your "ACCOUNT SID" here or set TWILIO_ACCOUNT_SID env var.
authTokenStringrequiredTwilio auth token. Visit your Twilio dashboard's main page. Click "Show API Credentials", then copy and paste your "AUTH TOKEN" here or set TWILIO_AUTH_TOKEN env var.
phoneNumberStringrequiredThis is the 'From' phone number you'd like to use to send the SMS. This phone number is assigned to you by Twilio.

Actions

send

Send an SMS

Parameters

PropertyTypeDefaultDescription
toStringrequiredTarget phone number
messageStringrequiredMessage text
mediaUrlString-Media URL

Results

Type: String

Methods

sendSMS

Send an SMS

Parameters

PropertyTypeDefaultDescription
toStringrequiredTarget phone number
bodyString"\"\""Body of SMS
mediaUrlString-Media URL

Results

Type: String

Test

$ npm test

In development with watching

$ npm run ci

License

The project is available under the MIT license.

Contact

Copyright (c) 2016-2019 MoleculerJS

@moleculerjs @MoleculerJS

1.0.14

2 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

5 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago