Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

moleculer-twilio

v1.0.10arrow_drop_down
v1.0.10
STATUS
Passing
DOWNLOADS
0
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
N/A
Send a message using the Twilio API. https://www.twilio.com
1 contributor
Install moleculer-twilio as a package?
Copied
npm i @bit/moleculerjs.moleculer-addons.moleculer-twilio
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
chevron_left
chevron_right

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.
Chat on Slack