0.1.0 • Published 6 years ago

@wireland/sms v0.1.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
6 years ago

Send SMS service

Simple wrapper for Twilio that will send an SMS message to a mobile number.

Usage

First make sure we have examples monorepo initialized. Run yarn from the examples repo root.

Deploy the SMS stack service

Run the follwing commands from the examples/sms

  1. wire build
  2. wire service register --domain example.com
  3. wire stack deploy

Wireline Sandbox

  1. Create a new project using the service-template.
  2. Update stack.yml to add a reference to the SMS service:

    stack:
      sms:
        reference:
          endpointUrl: "wrn::example.com/sms/sms"
  3. Modify handler.js to import the SMS API

    import { Wireline } from '@wirelineio/sdk';
    
    import SMS from '@wireland/sms';
    
    module.exports = {
      test: Wireline.exec(async (event, context) => {
        const { phone, msg = 'Hello there!' } = event.queryStringParameters || {};
        await new SMS(context).send(phone, msg);
      })
    };

If there is an error sending the message the error will be thrown by the .send method so its recommended that you use a try/catch block to handle any errors.