aws-lambda

fingertoe 2017-02-21T00:23:51.000079Z

@andre.richards I have built an Alexa Skill on Node.. It isn’t too hard. I started with https://github.com/nervous-systems/cljs-lambda and just gutted it to return the appropriate JSON..

fingertoe 2017-02-21T00:25:12.000081Z

My app runs extensive Podcast Alexa app. The hardest part is the lack of an easy workflow.

2017-02-21T01:27:40.000084Z

I also started with cljs-lambda, and got a basic Lambda function deployed on Amazon - but I don't know how to call the Alexa code, as I'm brand new to ClojureScript

2017-02-21T01:35:02.000085Z

Hopefully reading this will enlighten me: https://clojurescript.org/guides/javascript-modules

fingertoe 2017-02-21T01:48:38.000086Z

I didn’t use any of the SDK stuff. Alexa sends you JSON. You parse it and return JSON, it works like a charm. If you want to host it yourself on your own server the SDK has some security libraries that would be handy - but if you are using Lambda they don’t require all that..

fingertoe 2017-02-21T02:00:16.000087Z

I will put together a GIST real quick...

fingertoe 2017-02-21T02:16:59.000088Z

Give this a gander https://gist.github.com/jreighley/b6d394d0efa743292bf32d776be97682

1👍
fingertoe 2017-02-21T03:11:04.000091Z

Troubleshooting the lambda alexa apps is a bit tricky. The cloudwatch logs usually give you more detail than the Skills kit test app does- Printing to the console log is helpful. those show up in cloudwatch.. The workflow just stinks - because there isn’t much escaping the need to compile/upload/test..

2017-02-21T20:57:04.000118Z

fingertoe: fwiw, with boot-ask you can test your speechlet locally using gae devserver. once everything is copacetic, you can switch to aws-lambda without changing your code.

2017-02-21T11:02:29.000095Z

@fingertoe thanks for that! I'll give it a go a little later today.

2017-02-21T19:12:41.000105Z

@fingertoe thanks that works great. Much nicer not having to deal with a layer of JavaScript in between. Just work with data in ClojureScript.

2017-02-21T19:15:22.000106Z

Regarding troubleshooting - yep is a bit of a pain, but once the basic thing works, it is possible to test locally to check that certain input returns the correct output at least

fingertoe 2017-02-21T19:57:06.000109Z

Good deal! I would like to set up a lein template or something for that — I am a pretty new developer, and have never done something like that - but I think it might be time..

mj_langford 2017-02-21T19:57:32.000110Z

This cljs seems better but clj has better tools thing seems a theme on lambda 😃

fingertoe 2017-02-21T19:59:17.000111Z

The “Listen for this and say that” troubleshooting is pretty easy in your REPL it’s the “listen for this, Poke and prod a foreign API and reply with the results” gets a little hairy. What works on the REPL doesn’t aways work the same on Lambda..

fingertoe 2017-02-21T20:15:19.000112Z

@mj_langford I find the need to use a lot more interop on ClojureScript.. Since I never was a JavaScript Developer to start with, that is un-fun. It does get the job done though.

mj_langford 2017-02-21T20:16:02.000113Z

Yeah, Clojurescript is partially my thing so I don't have to keep up with the 5 changes a week js ecosystem

2017-02-21T20:46:14.000115Z

hi guys. just out of curiosity, why clojurescript? why not clojure?

2017-02-21T20:48:53.000116Z

mainly startup time?

2017-02-21T20:49:34.000117Z

for ask, i mean.

2017-02-21T20:57:04.000118Z

fingertoe: fwiw, with boot-ask you can test your speechlet locally using gae devserver. once everything is copacetic, you can switch to aws-lambda without changing your code.

fingertoe 2017-02-21T20:57:43.000121Z

Cool — boot-ask eh? Haven’t played with that.

fingertoe 2017-02-21T20:58:43.000122Z

That looks Very cool! thanks!

2017-02-21T21:00:35.000123Z

see https://github.com/migae/boot-ask. warning: not battle-tested. you'd be a beta tester. feedback warmly welcomed. also, clojure, not clojurescript.

2017-02-21T21:06:49.000125Z

one thing i need to document for noobs: in the examples at https://github.com/migae/boot-ask-examples, notice`gae.boot` and lambda.boot. copy the one you want to 'build.boot'.

2017-02-21T21:12:04.000127Z

i use gae.boot for local testing (using upload.sh, suitably edited), and then cp lambda.boot to build.boot when i'm ready to upload and test on aws lambda.

fingertoe 2017-02-21T21:23:47.000133Z

@mobileink That runs java, not Node, right? You have to poke it to evade the warm up time?

mj_langford 2017-02-21T21:23:51.000134Z

startuptime is horrrrrrrible mobileink in lambda

mj_langford 2017-02-21T21:23:56.000135Z

you have to keepalive the instances

mj_langford 2017-02-21T21:24:23.000137Z

AWS gateway used to have a 10 sec timeout

mj_langford 2017-02-21T21:24:29.000138Z

which was too short for startup

2017-02-21T21:24:43.000139Z

ok. we do not speak of that around here. 😉

2017-02-21T21:27:50.000140Z

@fingertoe: because i am a pedant, I'll quote the great Knuth: premature optimization is the root of all evil. :simple_smile:

2017-02-21T21:30:31.000141Z

so fwiw, a goal of boot-ask is to optimize programming. on the theory that stuff like startup times can always be dealt with later. it's an orthogonal consideration. (of course, i do not have any sites up that need fast startup, but who's counting?)

2017-02-21T21:37:07.000142Z

anyway, there are always tradeoffs. startup time is just one consideration. once you're started, i'm guessing, java is much faster. but that's just a guess.

fingertoe 2017-02-21T21:39:49.000143Z

I think running Alexa skills on your own server with Java would be the ideal setup — Nodejs on Lambda is plenty fast for most things you would use Alexa for.. I did my app with NodeJS to evade startup time issues.. Haven’t tried it the other way - but that was my worry.

2017-02-21T21:41:34.000145Z

simple example: you can always present a fast static splash page while your servlets are starting up. by the time your user clicks, the stuff is up and ready. point being there are many optimization techniques, but they should not be allowed to leak into code.

2017-02-21T21:46:02.000147Z

@fingertoe : yeah. if you run your own speechlet server you are totally in control. fwiw when i have run speechlets on gae the first time thru is a problem. but then you just say "Alexa... " again and all is fine. and this is with no optimizations at all.

2017-02-21T21:47:05.000148Z

even "native " alexa cmds often require repetition.

fingertoe 2017-02-21T21:49:08.000149Z

I am pretty happy with how the my Clojurescript Alexa app turned out— It responds immediately the first time every time. I would prefer to have a framework like the boot-ask though - that looks mighty cool.

2017-02-21T21:52:14.000150Z

thx. hey, if you want to help make it go with clojurescript fire away!

2017-02-21T21:53:30.000151Z

fwiw i am not anti-clojurescript, just do not have much experience with it. and node etc. give me the heebie-jeebies.

fingertoe 2017-02-21T21:54:08.000152Z

I will take a look. I put together a gist last night https://gist.github.com/jreighley/b6d394d0efa743292bf32d776be97682— Mine works using https://github.com/nervous-systems/cljs-lambda

2017-02-21T21:54:17.000157Z

quibble: not a framework! just another lib. 😉

2017-02-21T21:57:28.000158Z

ok, cljs-lambda is on my list. next time i have time to work on boot-ask i'll take axlong look. thanks

fingertoe 2017-02-21T21:57:33.000159Z

There was plenty of pain — I have never done and Node or JS… Mostly just annoyances though.. cljs-http didn’t work on node, so I had to do all my stuff with js interop etc..

2017-02-21T21:59:18.000160Z

cljs-lambda looks interesting.

2017-02-21T22:01:47.000161Z

but my unsolicited advice is to spend some serious time looking into boot. i love leinengen, but it must be said that boot is in an entirely different league.

2017-02-21T22:03:30.000162Z

Sadly, i've gotten to the point where i don't even look at projects that start out with leiningen.

fingertoe 2017-02-21T22:05:33.000163Z

I have quite tempted by boot for quite some time. The truth is that I don’t really have a good grasp on either, but lein is what I have already used, and usually I am more focused on my problem than my tools.. I am sure I will make the jump soon enough .;-)

2017-02-21T22:39:37.000166Z

@mobileink I read an article recently about JVM vs Node startup times and memory usage on Amazon Lambda - unsurprisingly JVM had slower startup, and required much more memory, but once running was faster (can't find the article now, will have another look). Thing is, I was doing the Alexa thing as a hobby project, something I might use from time to time, but not a professional project I expected many to use . The infrequent hits, would definitely make startup time more critical, and also JVM at suggested RAM of 512 makes it more expensive. So that was really my motivation for wanting to use ClojureScript - even though I'm unfamiliar with ClojureScript & JS & Node.