Git Product home page Git Product logo

twilio-f's Introduction

Twilio-f

stdlib.com service

This service helps you forward calls or SMS that you receive on a Twilio Number to any phone number that you'd like.

It's a micro-service built using stdlib that you can use as a Twilio Number web-hook.

Usage

SMS & Call Forwarding

This service is already available to be used on stdlib here, or you can fork it and launch your version of it on stdlib.

The main function is called forward and it accepts two parameters (other than the ones that come from Twilio):

  • type - the type of forwarding to do: call or SMS.
  • ForwardTo - the phone number to forward the call or SMS to.

So to construct a webhook that forwards all calls to 415-xxx-xxxx, all you have to do is:

https://f.stdlib.com/nemo/twilio/forward?ForwardTo=+1415xxxxxxx&type=call

And to do the same for SMS:

https://f.stdlib.com/nemo/twilio/forward?ForwardTo=+1415xxxxxxx&type=SMS

You can use these URLs as the web-hooks in Twilio's Voice and SMS web-hooks.

Enjoy forwarding!

Sending Messages

Twilio provides a great API for sending messages. However, after building a few chat-bots and SMS products, you learn a thing or two. This service makes it easier to deliver messages and provide a better experience for the receiver. It's also a great and scalable way to wrap your messaging service.

The main features are that it handles multiple mediaUrls, automatically truncates long messages and attempts to control delivery order using timeouts.

You have to set the following enviornment variables to make the function work (which means you have to fork this repo and submit your own stdlib function!):

  • TWILIO_ACCOUNT_SID - Twilio Account SID
  • TWILIO_ACCOUNT_AUTH - Twilio Account Auth

After you've set those, you can call the function (built on top of twilio's node sdk):

var f = require('f');

f("<stdlib-username>/twilio/sendMessage")({
    to: "+1415xxxxxxx",
    from: "+1415xxxxxxx",
    body: "Body goes here",
    mediaUrls: ["path-to-url"],
    splitLength: 160, // optional, set to 0 if you want to disable splitting
    MessagingServiceSid: '<MessagingServiceSid>', // optional
    StatusCallback: '<StatusCallback>', // optional
    ApplicationSid: '<ApplicationSid>', // optional
    MaxPrice: "<MaxPrice>", // optional
    ProvideFeedback: "<ProvideFeedback>", // optional
    otherParameter: "Other params accepted by Twilio's node sdk"
});

The result will be an array with a status set to ok or failure, message set to the payload that was sent, and result or error being the response from Twilio.

Functions

/twilio/forward

function spec | source

This function responds with Twiml that forwards a phone call or SMS to another number.

/twilio/sendMessage

function spec | source

This function sends a message using Twilio's messages.create API. It handles cases were the message body is too long, only a media Url is provided or multiple mediaUrls are being sent.

LICENSE

MIT

twilio-f's People

Contributors

nemo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.