@wireland/sms

0.1.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @wireland/sms

Weekly Downloads

0

Version

0.1.0

License

UNLICENSED

Unpacked Size

7.17 kB

Total Files

7

Last publish

Collaborators

  • ashwinp
  • elmasse
  • richburdon
  • tinchoz49