DCtheTall / twilly

A library which provides an abstract syntax for designing Twilio SMS interactions. Designed for use with Node.js and Express
MIT License
52 stars 3 forks source link

Add `triggerFlow` to the library, fixes #3 #7

Open DCtheTall opened 5 years ago

DCtheTall commented 5 years ago

Add triggerFlow to the exported interface of the library.

Usage:

const { Flow, Reply, triggerFlow } = require('./twilly');
const app = require('express')();

// App setup...

// Example request, accepts a POST request with a JSON body with a single field:
// "toNumber", a string field with the phone number you wish to send a message
// to.
app.post('/message', (req, res) => {
    const toNumber = req.body.toNumber;
    triggerFlow(
        toNumber,
        new Flow('messageUser').addAction('reply', new Reply('Hello world!')),
    );
    res.status(200).end();
});

// Rest of app...

Also I got a head start on #6.

Still needs unit tests before ready for release