@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..
My app runs extensive Podcast Alexa app. The hardest part is the lack of an easy workflow.
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
Hopefully reading this will enlighten me: https://clojurescript.org/guides/javascript-modules
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..
I will put together a GIST real quick...
Give this a gander https://gist.github.com/jreighley/b6d394d0efa743292bf32d776be97682
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..
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 thanks for that! I'll give it a go a little later today.
@fingertoe thanks that works great. Much nicer not having to deal with a layer of JavaScript in between. Just work with data in ClojureScript.
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
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..
This cljs seems better but clj has better tools thing seems a theme on lambda 😃
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..
@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.
Yeah, Clojurescript is partially my thing so I don't have to keep up with the 5 changes a week js ecosystem
hi guys. just out of curiosity, why clojurescript? why not clojure?
mainly startup time?
for ask, i mean.
Cool — boot-ask eh? Haven’t played with that.
That looks Very cool! thanks!
see https://github.com/migae/boot-ask. warning: not battle-tested. you'd be a beta tester. feedback warmly welcomed. also, clojure, not clojurescript.
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'.
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.
@mobileink That runs java, not Node, right? You have to poke it to evade the warm up time?
startuptime is horrrrrrrible mobileink in lambda
you have to keepalive the instances
AWS gateway used to have a 10 sec timeout
which was too short for startup
ok. we do not speak of that around here. 😉
@fingertoe: because i am a pedant, I'll quote the great Knuth: premature optimization is the root of all evil. :simple_smile:
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?)
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.
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.
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.
@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.
even "native " alexa cmds often require repetition.
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.
thx. hey, if you want to help make it go with clojurescript fire away!
fwiw i am not anti-clojurescript, just do not have much experience with it. and node etc. give me the heebie-jeebies.
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
quibble: not a framework! just another lib. 😉
ok, cljs-lambda is on my list. next time i have time to work on boot-ask i'll take axlong look. thanks
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..
cljs-lambda looks interesting.
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.
Sadly, i've gotten to the point where i don't even look at projects that start out with leiningen.
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 .;-)
@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.