
Twilio Functions – Public Beta - tcsf
https://www.twilio.com/blog/2017/05/introducing-twilio-functions.html
======
revicon
It's definitely using AWS Lamba, I spun up a trial account and texted myself
the output of JSON.stringify(process.env)...

Edit: adding linebreaks...

2nd edit: Realized there were AWS access tokens in there. It's probably not a
good idea for those to be exposed to the environment they're running this user
generated code in. They should probably be wrapping these in
vm.runInNewContext()

    
    
      {
      "PATH":"/var/lang/bin:/usr/local/bin:/usr/bin/:/bin",
      "LANG":"en_US.UTF-8",
      "TZ":":/etc/localtime",
      "LD_LIBRARY_PATH":"/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib",
      "LAMBDA_TASK_ROOT":"/var/task",
      "LAMBDA_RUNTIME_DIR":"/var/runtime",
      "AWS_REGION":"us-east-1",
      "AWS_DEFAULT_REGION":"us-east-1",
      "AWS_LAMBDA_LOG_GROUP_NAME":"/aws/lambda/ZDfb2ab7cd7ac1734d9a1a06a018a1c522",
      "AWS_LAMBDA_LOG_STREAM_NAME":"2017/05/25/[$LATEST]2d7b70d5a6914e3980f081ba96c9d4ab",
      "AWS_LAMBDA_FUNCTION_NAME":"ZDfb2ab7cd7ac1734d9a1a06a018a1c522",
      "AWS_LAMBDA_FUNCTION_MEMORY_SIZE":"512",
      "AWS_LAMBDA_FUNCTION_VERSION":"$LATEST", 
      "_AWS_XRAY_DAEMON_ADDRESS":"169.254.79.2",
      "_AWS_XRAY_DAEMON_PORT":"2000",
      "AWS_XRAY_DAEMON_ADDRESS":"169.254.79.2:2000",
      "AWS_XRAY_CONTEXT_MISSING":"LOG_ERROR",
      "_X_AMZN_TRACE_ID":"Root=1-59274f44-71756c3273bfaf4895cd5610;Parent=4126596e259f5d9f;Sampled=0",
      "AWS_EXECUTION_ENV":"AWS_Lambda_nodejs6.10",
      "_HANDLER":"enigma.handler",
      "NODE_PATH":"/var/runtime:/var/task:/var/runtime/node_modules",
      "AWS_ACCESS_KEY_ID":"REMOVINGTHIS",
      "AWS_SECRET_ACCESS_KEY":"ALSOREMOVINGTHIS",
      "AWS_SESSION_TOKEN":"REMOVINGTHISTOO"
      }

~~~
kentonv
... Are those actually Twilio's keys, or are they creating a new Lambda
instance (with its own private access keys) for each customer?

Maybe they actually intend for people to be able to use all the functionality
of Lambda, some of which (I guess) requires using the AWS access key?

Or are people naively assuming their own Lambda container is a reasonable
sandbox for third-party code? If so, yikes.

~~~
idbehold
It's likely using an IAM role with no permissions other than writing logs to
CloudWatch.

~~~
kentonv
OK, so they're effectively reselling Lambda, and creating a new Lambda account
for each Twilio customer under the hood?

~~~
philsnow
> they're effectively reselling Lambda

Another take on this is that they're creating value for customers by shifting
the reliability requirements from the customers themselves to AWS / lambda

... which I think is brilliant.

~~~
rajangdavis
I hacked together a quick demo using Ruby, Sinatra, and Heroku with Twilio
this last weekend and the whole time I was thinking "Heroku makes this easy,
but having to host a server makes this harder to debug".

I feel like this new feature will make it super easy to work with Twilio. It's
almost a no brainer.

~~~
kondro
Or you can keep the Ruby stack and just use ngrok in dev. :-)

~~~
rajangdavis
Trust me, I love Ruby and ngrok works well, but I think a serverless setup is
a lot simpler (at least in my mind). I was actually using Twilio to test a
Ruby library of mine and set up a text service for product registrations for a
CRM. It works freakishly well.

But despite all that, I feel like setting everything up in one place would be
a lot simpler.

Now if Twilio had a way to deploy serverless functions via git... that would
be a clincher.

------
keithwhor
Awesome play by Twilio. We've been working on StdLib [1] and an open
specification for FaaS execution [2] for a while now, and demos with Twilio
(sending text messages after automatically validating parameters, hooking into
other functions in our ecosystem) have really helped developers grok what's
possible. (We have a built-in SMS utility that actually uses Twilio behind the
scenes [3]).

Happy to see we've come to the same conclusions about utility independently
:).

[1] [https://stdlib.com/](https://stdlib.com/)

[2]
[https://github.com/faaslang/faaslang/](https://github.com/faaslang/faaslang/)

[3] [https://stdlib.com/utils/sms](https://stdlib.com/utils/sms)

~~~
gregorymichael
Just checked out stdlib.com. Looks awesome. Much appreciate you using Twilio
to demo it. Would you drop me an email at gb@twilio.com? Would love to send
you something.

~~~
keithwhor
Gladly. We're big fans!

------
rockmeamedee
Interesting. Thinking out loud here, are Functions a new opening for Saas
businesses? (tldr no).

If you have a big enough user base/set of use cases, the next step after
opening an API to your service might be adding a Baas/Faas, so people with
small use cases or prototypes can get started easily without using a server.

But it's not like Linkedin or Zenefits users would get more value out of
"Linkedin Functions". It probably makes more sense if you can "eat" what would
have been a separate (micro)service.

The one thing I don't see though, is if somebody is sold enough on Faas, why
would they use your siloed Twilio Faas instead of AWS Lambda/whatever where
you can interact with Twilio _and_ eg Shopify, Instagram, other APIs...

Maybe then an interesting idea for the big FaaS providers duking it out for
market share right now might be an ability for SaaS providers to build
"$YOUR_SAAS Functions" on top of their offering. The end-user would see
Lambda/Function/whatever templates pre-filled with the right API calls an a UI
for choosing the different API-related triggers. This could be like the AWS
marketplace, but for Faas.

So I guess the answer to my clickbait-ey question at the top is mostly likely
no, but maybe, let's see it play out. It definitely feels like a good way to
sell more API usage.

~~~
keithwhor
;) The answer to your "clickbait-y" question is definitely "we'll see," and
it's already playing out.

------
rsync
I am a (happy) twilio customer and I do not understand this:

"Today, we’re excited to announce Twilio Functions, a serverless environment
to build and run Twilio applications so you can get to production faster."

I did just that ... I signed up for twilio, wrote a simple twiML[1] inside
their web editor, and attached it to a phone number.

No servers were involved (I am not sure how I _could_ involve a server) and I
"got to production" very fast.

What would I do differently now ?

[1] "Ring Forever"

~~~
PKop
Is there not functionality that can't be expressed in a twiML?

Like communicating to separate service or database within a given request from
an SMS or Voice callback, etc... functionality that until today would have
required web-hooks running on some other server (or cloud function)?

~~~
jjeaff
Yes, we pull data from our database to make dynamic responses. But I'm not
sure if this services model helps that. You would have to create an API to
interface with your own DB.

------
bryanh
This is very similar to what we've done to bootstrap the Zapier CLI and
developer platform -- especially relative to repurposing AWS Lambda.

Wrote a bit of behind the scenes just the other day
[https://zapier.com/engineering/behind-the-
cli/](https://zapier.com/engineering/behind-the-cli/) if this sort of stuff
tickles your fancy.

------
foolfoolz
good amount of comments here missing how hard it is for "normal" people to use
twilio. the article is clear: twilio's many interface to your code is a
callback URL. think about what it takes to have a callback URL you can input
to the twilio website.

could they really set up an AWS account, lambda function, IAM role, API
gateway, with cloud watch logs? ive done this in AWS. you have to use 5+ AWS
services that have funny names and look nothing alike, and make them all work
together.

or lets say you wanted to buy a domain, hosting for it, and put your code on
there for twilio to hit with a callback URL. thats hard too.

if you are going to do either of the 2 approaches above, how many hours are
you going to spend getting the callback URL foundation set up (and working)
before you even get to use a twilio product?

~~~
Mister_Snuggles
Can the callback URL use an IP address, or does it need to be a proper DNS
name? Can it have a self-signed certificate? Does it even need to be secured?

If the callback URL can use an IP address and doesn't require https, you could
set up a Digital Ocean droplet for it in a couple of minutes. Or you could set
up a port-forward on your router and run an HTTP server on your machine, but I
think the Digital Ocean route might be quicker.

~~~
foolfoolz
who are you expecting to understand this? there's tons of people out there who
have no idea what these terms mean. DNS? Self Signed? IP address maybe...
droplet? they are going to say "too hard, close tab"

~~~
Mister_Snuggles
At a quick glance, it seems like anything beyond a fire-and-forget SMS/fax
done with Twilio requires a callback. My guess is that Twilio is expecting
their customers to be able to write a callback and is willing to accept the
associated barriers for entry.

------
CJKinni
I've loved being able to hack away on projects with Twilio for a while now.
They're relatively easy to get started with, and this is going to make it even
easier. 10,000 invocations free, with subsequent invocations priced at
10,000/$1 seems like a great model. No idea about how this scales financially,
compared to other similar services. But as someone making relatively limited
use tools, most without a business model, their pricing certainly keeps me
feeling great about using them.

~~~
keithwhor
Well, to be honest, compute is becoming a commodity very quickly. We offer
100,000 invocations free and offer 50,000 per $1 [1] with a paid account.
There are some pretty smart people who have talked at length about startups
historically underpricing, but I think we're making a bet on the raw value of
compute trending to zero. (This is a weird thing to say outright, our goal,
generally, is to change the way people think about service composition and
building things on the internet.)

Twilio is interesting because they're offering this as a _business-specific
offering_ i.e., integrate with Twilio directly (SMS, voice), which on its face
is actually _more valuable_ than, say, a "generalized compute platform" (which
we've referred to ourselves as, at times). I think it'll be really interesting
to see how Twilio markets + plays with this model --- theoretically if it
sells their other services they could get away with this being a loss-leader,
which is an intriguing concept.

[1] [https://stdlib.com/pricing/](https://stdlib.com/pricing/)

~~~
skynode
> _I think we 're making a bet on the raw value of compute trending to zero._

I'm thinking you mean the COST of compute here. If that's the case, I actually
disagree on cost trend direction. I think the raw cost of compute will slowly
increase. Long story but most of it borders on the economics of cloud
computing.

------
hacknat
I was already doing this with their API on Lambda. If anybody is interested:
[https://github.com/nathanjsweet/narthan](https://github.com/nathanjsweet/narthan)

Good on them for integrating it.

------
fpgaminer
Is there some way to create an SMS based service using Twilio, and charge
users? Like, the user gets charged on their phone bill and I, the service
owner, get paid by Twilio or something.

Or is that just not a thing and it has to be done OOB?

~~~
Roedou
It depends on the country. In the UK it's very common, and relatively easy to
do the 'premium sms' that you describe.

It's not at all common in the US, and Twilio doesn't seem to support it
anywhere.

------
pw
I wonder if this is an independent effort or if it's built on top of AWS
Lambda.

Also, anyone know why all these serverless environments that are coming out
focus on Node.js?

~~~
keithwhor
Fastest growing runtime, largest module ecosystem. That's it. The goal is to
encourage adoption and validate a product quickly, so you ride the biggest
wave.

AWS has the resources to grow teams around different languages / runtimes,
smaller players (or recent IPOs) do not in the same capacity. Targeting
anything other than Node would be "the largest" disservice to your customer
base in the case of Twilio, and would artificially slow any other player.

~~~
PKop
In addition, Node seems to have beneficial performance characteristics when it
comes to cold startup time, compared to say Java, which probably helps when it
comes to pay-only-for-requests functions as a service that aren't always
running.

[https://forums.aws.amazon.com/thread.jspa?messageID=679050](https://forums.aws.amazon.com/thread.jspa?messageID=679050)

------
sparrish
Other providers like Tropo have had this hosted scripting for years. Nice to
see Twilio catching up.

~~~
sciurus
I'm not sure why this comment was downvoted.

I worked for Tropo four years ago. You could write your code in JavaScript,
PHP, Ruby, Python, or Groovy; upload it to our servers; and we'd run it on
your behalf. It was literally zero infrastructure on your part and one line of
code to answer a phone call.

Tropo certainly lacked some things compared to Twilio while I was there, but
this is undoubtedly an area where Twilio is playing catch up.

[https://www.tropo.com/docs/scripting/overview](https://www.tropo.com/docs/scripting/overview)

~~~
kevinburke
Pointing out "Company X already does this" when someone launches something new
is a pretty douchey move...

~~~
thesimon
Why? It's certainly useful to see what other companies are offering and what
the differences between these offerings are. If just mentioning a competitor
is bad then maybe the product is bad.

~~~
kevinburke
Whether it's a company launching a product or a developer showing off
something they built in their spare time, it's really depressing to launch
something you've been working on for months or years and to get back "well, X
already does this."

I'd add that "X already does this" comments like this are a _routine_ feature
of Twilio HN threads, as long as the company's been alive.
[https://kev.inburke.com/kevin/six-years-of-hacker-news-
comme...](https://kev.inburke.com/kevin/six-years-of-hacker-news-comments-
about-twilio/)

------
fiatjaf
Who are these people writing SMS apps? Why is Twilio so proeminent when no one
uses SMS anymore?

~~~
chadwittman
Our customers at Dolly love receiving SMS. Also helps with low data
connectivity locations. Not sure "no one uses SMS anymore" is accurate.

------
sagivo
I love the new popularity of lambda/functions as a service. each provider can
now give you a custom code to do whatever you like, stripping away the needs
for servers and that what i can really see as a full "micro-service"

------
ryanar
I wish Twilio had free offerings for their other services. I didnt even dare
playing around testing Twilio because I would be getting charged 2 cents per
SMS sent

~~~
keithwhor
The truth of the matter is if you have a hard time paying 2 cents to send a
text message for a few beta / trial runs, you're probably not contributing to
Twilio's bottom line in any reasonable fashion, and unfortunately, they don't
care. Not because they don't want to, but because they can't afford to.

If every engineer with a six-figure salary decided they would pay the couple
bucks it costs to test drive a product, the customer long-tail for dev
products would add up to something appreciable and as a result you might
actually see a lot more innovation around dev tools. As it stands, one of the
best developer products of our generation, Heroku, even had a hard time
pricing / selling to their long tail and we saw shutdowns of great products
like Parse.

Twilio actually has a very reasonable model. $20 deposit, non-recurring, is
way less than you'd spend on a Thursday night date, for example, and you get
to build something with it. Hell, speaking of building, you've probably spent
more on a Lego set. (I have. As an adult... for myself.)

(What actually ends up happening is developer companies go full OSS, give
everything away for free for massive adoption, then AWS figures out how to
productize it and sell to Enterprise. You can trace the points from Docker's
inception to AWS Lambda processing trillions of trades per day.)

~~~
sjtgraham
Over 95% of Twilio's users don't meaningfully contribute to their bottom-line.
Their revenue is a fat long-tail dominated by outliers. I'd say Twilio does
care about every developer because they have no idea which customers will
become outliers.

------
jknoepfler
The success of this product is dependent on torpedoing aws lambda from a
usability and reliability perspective imo (not hard). After using twilio to
build the sms side off of an app I've been quietly rooting for them (and
betting on them actively)

If they built this ON lambda then I'd bet against it very strongly, but I
can't imagine smart engineers doing that in 2017 (ha...)

~~~
stale2002
You are thinking about this wrong.

Serverless functions on Twilio (or any other platform for that matter) is not
competing with Lambda.

The point of serverless functions is to take your Twilio app that you were
already creating and to completely eliminate the back-end.

Now you can make a fully functioning Twilio app without messing around with
heroku.

~~~
jknoepfler
That's like suggesting that heroku isn't competing with aws on things like
database management. It is.

~~~
stale2002
Does the mattress industry compete with the hotel industry?

In a vague roundabout way both industries are used for sleeping.

But the connection is so remote that the answer is no.

So Lambda and Twilio functions are similarly "competing". But in reality there
is less than 1% of situations where someone would seriously be deciding
between the two.

