Live Coding of a Simple Amazon Echo (Alexa) Node.js Skill [w/ subs]



00:00:00 – that alright so we're going to build an
00:00:02 – ods kill that is called Paris isn't the
00:00:05 – repeat dumb stuff for us a little
00:00:07 – deployed and all that stuff so the first
00:00:09 – thing to do is substitute to note app
00:00:12 – we're going to write a package.json just
00:00:18 – stick a bunch of stuff in it has a name
00:00:20 – and version description some kind of
00:00:23 – entry and a couple of dependences so
00:00:26 – we're going to use this alexa app
00:00:29 – dependency what you don't need express
00:00:31 – and no place without so let's add node
00:00:41 – module students and npm install oh and
00:00:45 – we should use and vm like 71
00:00:54 – perform yeah
00:00:57 – translate them ok so we've got ourselves
00:01:01 – a bunch of NPM we're going to use this
00:01:04 – library called alexa app so the at the
00:01:09 – very simple skill implementation is
00:01:12 – going to call this parrot
00:01:15 – yes require the electric app library
00:01:21 – create a new instance of the app we
00:01:23 – should call this parents and there is
00:01:28 – the launch sequence which is what
00:01:29 – happens when the app start because most
00:01:32 – of these apps on these devices you have
00:01:34 – to invoke it somehow the first time he
00:01:37 – was the user invoke it for yourself when
00:01:39 – your device it launches so it's going to
00:01:41 – be it's going to say a thing when it
00:01:43 – launches in this case will say i am a
00:01:45 – parent so of course we like we like test
00:01:50 – so we're not going to go ahead without
00:01:54 – deaths and let's get ourselves some
00:01:58 – Walker so and then let's write the test
00:02:06 – and see what this thing is I want
00:02:12 – fold itself and test parrot is okay and
00:02:20 – the our test is pretty rudimentary this
00:02:25 – is just going to boot and express server
00:02:29 – when the mount our parent application
00:02:32 – inside that expresar so this is justin
00:02:34 – OGS function app and we just mounted
00:02:38 – inside an express server it doesn't have
00:02:40 – to
00:02:40 – once we deployed the landing doesn't
00:02:42 – actually have an express waiver for
00:02:43 – example and we have a list of the port
00:02:46 – and this is our test so we should be
00:02:48 – able to write it works and i would see
00:02:55 – the stuff nothing
00:02:58 – test ok here's our our test so lets you
00:03:04 – fill out the test we're just going to
00:03:06 – write that in response to valid data so
00:03:09 – I its express server that mount our appt
00:03:11 – i'm just going to send it i do opposed
00:03:16 – to our appt parents and i'm going to
00:03:19 – send it an empty body and I'm expecting
00:03:21 – some responses going to say something to
00:03:24 – give me some out book which is actually
00:03:26 – SML which is the speech simple speech
00:03:30 – markup language something like that so
00:03:32 – you have it says literally speaks
00:03:34 – aeronautical is request so that's the
00:03:37 – way this this Apple only succeed unless
00:03:39 – something unexpected happens and say
00:03:41 – like I'm sorry I couldn't do it because
00:03:42 – we want the device not to fail what the
00:03:44 – device to say the errors so let's see if
00:03:47 – this actually works
00:03:49 – who we got our reset the garbage we got
00:03:54 – back in error not a valid request
00:03:56 – cool alright let's check out launch
00:04:01 – request so this is a this request is a
00:04:04 – certain type this is what the alexa
00:04:05 – platforms sense when a user opens a nap
00:04:09 – or a skill and we're sending this
00:04:12 – request of states launched request that
00:04:14 – there's more field third but analysis is
00:04:16 – as simple as that
00:04:17 – so it's going to report respond with
00:04:19 – what we coded in our parajets here which
00:04:23 – was an apparent
00:04:24 – and so let's see if this actually
00:04:28 – happens what I the parent can you could
00:04:34 – curl it it's just an HTTP server and all
00:04:37 – that jobs
00:04:38 – alright so we want to deploy us to
00:04:42 – lambda so there might in many ways to
00:04:45 – deploy is that the basic skill that just
00:04:48 – says I'm a parent when it starts the one
00:04:52 – is you can put an entire web app with
00:04:54 – like with express and then think they're
00:04:57 – also something like that or you can use
00:04:59 – AWS lambda because there's only 1m 3.12
00:05:02 – function lambda works really well and
00:05:04 – you don't need the whole infrastructure
00:05:05 – so we're going to deploy this lambda now
00:05:08 – lambda is a little bit particular when
00:05:10 – you use an app called apex it's a tool
00:05:13 – to deploy the lambda and it once things
00:05:16 – in the certain direct set of directors
00:05:18 – i'm going to move some things around and
00:05:20 – create function spirit remove my side
00:05:24 – and we can get the method for lunch
00:05:26 – going to move my parents jets into into
00:05:33 – that functions parents and move my
00:05:35 – packages on there I'm just moving the
00:05:37 – entire app into function started
00:05:40 – director directing so when you look at
00:05:43 – it now I just have my word on email
00:05:45 – myself here anyone I just have my
00:05:48 – functions parents with the desk packages
00:05:52 – on parish it just moved into subfolder
00:05:54 – not nothing else
00:05:56 – alright so next we're going to go to our
00:05:59 – AWS console so i'm logged in as a cheese
00:06:04 – so you can you can see this without me
00:06:07 – and on lambda i am going to create the
00:06:12 – new lab the function creates lambda
00:06:16 – function i am going to use no cheers and
00:06:21 – i'm going to just do a blank function
00:06:25 – you need trigger so this is going to be
00:06:29 – a election skills kit has assigned a
00:06:33 – bunch of permissions rolls another craft
00:06:35 – to it it's like a resource policy so
00:06:40 – it's callable from actual election from
00:06:42 – the election platform the call this I
00:06:45 – think we're calling this parents are
00:06:48 – going to call this election parents this
00:06:52 – is apparent now just the code we don't
00:06:55 – care we have that we can leave the
00:06:59 – default this is the entry point so index
00:07:01 – handler here going to choose a to create
00:07:05 – the new role
00:07:07 – we're going to call the roll because I'm
00:07:11 – saying
00:07:12 – alexa parents and then I think that's it
00:07:20 – now
00:07:24 – alright so here's our like the parent
00:07:27 – function it has some code which is just
00:07:29 – the dummy for now as a configuration
00:07:31 – triggers you know stuff like that
00:07:34 – monitoring for logs
00:07:36 – alright next we are going to use I apex
00:07:43 – of everything is installed with from
00:07:46 – from github i already have it
00:07:48 – you also need to have a wsdl I so they
00:07:51 – can push things to the ws and then you
00:07:53 – have to configure it with AWS configure
00:07:54 – the first time if you've never used it
00:07:56 – already logged it ok with the entry
00:07:59 – point to not be our is our parent
00:08:03 – function in Paris yes because that that
00:08:06 – doesn't export anything other than the
00:08:08 – actual ax app so we'll just going to
00:08:10 – create index GS here
00:08:15 – and that one is going to say require our
00:08:18 – app and then select the app has a
00:08:21 – functional lambda that exposes the
00:08:22 – central point to lambda so experts
00:08:25 – handle which is what a text configured
00:08:27 – by default is Paris lambda and that's
00:08:30 – how it knows what to call so apex wants
00:08:34 – a project json at the very top so X is
00:08:38 – deploying multiple functions at the time
00:08:40 – usually so that's why this folder
00:08:42 – structures their packages the project
00:08:46 – and so this is called the name is Alexa
00:08:51 – this is going to create for each
00:08:54 – function alexa underscore something so
00:08:57 – you remember created elected Herot going
00:08:59 – to create electronic or parents are left
00:09:00 – with whatever the function i have their
00:09:02 – or other work and then I'm a parent and
00:09:06 – the this role it comes from my i am here
00:09:09 – so let's check that it's actually
00:09:11 – correct
00:09:18 – so i created the role for my parent
00:09:23 – thing here there's and here's the URL
00:09:25 – into that role
00:09:27 – it's crying because I've done this
00:09:29 – before and I think they get unique
00:09:31 – numbers this is our I am user so they
00:09:34 – don't change here
00:09:35 – ok so this this is a the deployment
00:09:39 – story so let's go back to lambda with
00:09:44 – you
00:09:45 – so we still haven't pushed any code to
00:09:47 – lambda would still have our like default
00:09:49 – code that's here so i think we're
00:09:53 – basically done and we can just do a path
00:09:55 – to deploy and they go now next once we
00:09:59 – have a hour our code we actually need
00:10:03 – our intent to do something you can't
00:10:06 – test and a an amazon killed without any
00:10:10 – intent you launching that is just not
00:10:12 – enough they have something in the u.s.
00:10:14 – it doesn't let you do it so well let's
00:10:15 – write the natural indent just goes in
00:10:20 – our parents yes and the intent is going
00:10:23 – to be called repeat intense it takes a
00:10:25 – parameter which called slot the keys for
00:10:28 – that it's value we're going to expect
00:10:30 – the number this is a very rigid set of
00:10:32 – things that can accept you can't accept
00:10:34 – star whatever you can say like except
00:10:37 – the word you have to accept one of
00:10:39 – amazon.com something or you have to
00:10:40 – provide a list of custom slot so for
00:10:43 – artsy is about and that's why she
00:10:45 – provided a list of artists examines the
00:10:47 – largest doesn't have anything around
00:10:49 – visual artists and then use the
00:10:51 – utterances I examples of what you're
00:10:53 – trying to say
00:10:54 – so typically at what I wanted to do i
00:10:56 – want to say alexa ask parents to repeat
00:10:59 – three and i wanted to repeat something
00:11:02 – three times taken up so this is repeat
00:11:05 – the value value requests lot value with
00:11:08 – him default it to you know to and it
00:11:11 – will say you said something and that
00:11:14 – that number of times will say I repeat
00:11:16 – you said something very smart skill
00:11:20 – okay of course we can do it without
00:11:22 – tears because you know
00:11:24 – how their we have not tried in code
00:11:28 – without deaths so here's the little
00:11:31 – death that response to repeated events
00:11:32 – we post the parents and this time you
00:11:34 – can see the request has a diaper that
00:11:36 – request the name of the intent being
00:11:38 – invoked and the value of the time
00:11:40 – passing it
00:11:41 – this is the last platform will do that
00:11:43 – so when I say alexa aspera 3p2 it parses
00:11:47 – my what I said that packages this is
00:11:49 – identifies the intent from the schema
00:11:50 – and then sends the mind to my skills and
00:11:53 – get whatever i'm saying back and spit as
00:11:55 – way for him to the device and so I
00:11:58 – expected to say you set to I repeat step
00:12:00 – two I repeat set to make sure the
00:12:03 – section works install i'm sorry i'm not
00:12:09 – using yarn shame on me
00:12:13 – ok it's my favorite look at work
00:12:21 – great so now we can push this to push
00:12:25 – this up and it's going to affect deploy
00:12:27 – is a new version so interestingly when
00:12:31 – you deploy two lamb they're all your
00:12:32 – environment is blown off and it's like a
00:12:35 – full version of a nap so something to to
00:12:38 – understand lambda is a it's not a
00:12:40 – infrastructure where you have setting
00:12:42 – that persist across version so every
00:12:45 – time i go back to the place like a new
00:12:46 – world so the new function actually have
00:12:48 – access to functions and with all the
00:12:50 – versions as well if you want to land it
00:12:52 – is that there's things like that we
00:12:53 – don't use any environment here but
00:12:55 – that's something that you you see
00:12:56 – otherwise ok so we we have a lambda
00:12:59 – functions we still need to turn it into
00:13:01 – a skill so we go to developer amazon the
00:13:03 – come with sign and click of accident and
00:13:07 – it's very confusing have to click on
00:13:09 – Alexis kill skip right as a new skills
00:13:13 – are going to call the parents invocation
00:13:15 – name is Garrett next the intense FEMA
00:13:21 – and the sample sample of differences is
00:13:23 – something with in january so let's write
00:13:26 – write a little bit of code to do that
00:13:31 – we'll call this skill Jeff and it just
00:13:38 – we require a pair adopt and we show the
00:13:40 – schema and the other something that the
00:13:42 – library that we use that no yes
00:13:49 – ok so here's our intern schema and
00:13:52 – that's basically what we put in this in
00:13:54 – the code and here is our other answers
00:13:59 – so here it just as repeat value and next
00:14:06 – so it's going to generate it's going to
00:14:08 – learn from this interaction model into
00:14:11 – smart things and the sign we want to go
00:14:14 – lambda North America we need the lambda
00:14:17 – functions krn which is here
00:14:27 – and then we can test this from here so
00:14:30 – we can say you know ask parents to
00:14:34 – repeat to and you can see this is the
00:14:39 – xml response that came back it says you
00:14:42 – said to you that I repeat step 2 and so
00:14:44 – on and so forth axis we don't care about
00:14:47 – this property information is for
00:14:49 – submission and stuff like that but we
00:14:52 – basically have a skill now and if you
00:14:54 – have a collector that's configured on
00:14:58 – the on your taxable account that you're
00:15:01 – using here and actually started talking
00:15:03 – so i have an actual you might hear well
00:15:06 – i left the open parents i like to ask
00:15:11 – parents repeats to ok so pretty cool so
00:15:16 – we've got ourselves a parent skills to
00:15:17 – go to your electorate amazon.com which
00:15:21 – is like the consumer side of this which
00:15:23 – has your apps your skills that's what
00:15:26 – you install the skills here and there
00:15:29 – your skills you have a right now a bunch
00:15:33 – of cool skills one of them is this
00:15:34 – parrot skills you can see the ws is the
00:15:37 – tests killers automatically gets
00:15:38 – published to your available to your
00:15:40 – lecture from there are you you can give
00:15:43 – somebody else in a bit of a death skill
00:15:45 – you have to register this way
00:15:48 – yeah so we have we have other skills
00:15:50 – here so this is this is a very simple
00:15:52 – test that you don't actually need to
00:15:53 – publish your skills unless you want
00:15:54 – something that somebody else to use it
00:15:56 – you can do it all there so that it's for
00:16:00 – our skills so that's the presentation so
00:16:07 – these are the code is on your device
00:16:09 – apparent if you want to look at it has
00:16:11 – the walkthrough and all the jazz and
00:16:15 – then a few other things that interesting
00:16:18 – about the Alexis if there's a framework
00:16:22 – you know Jess framework for building
00:16:23 – these skills call X app so this does not
00:16:26 – use the Amazon that the KMS on this case
00:16:28 – fine but it lacks like usability
00:16:32 – and and friends in it so it's a look
00:16:36 – very very rough on the edges so we
00:16:39 – there's a whole group of people that
00:16:41 – have built a few other things like that
00:16:42 – happens what I used here the demo
00:16:44 – electric appserver is a server that
00:16:47 – allows you to mount these in investment
00:16:53 – and development so if you want to you
00:16:54 – know curl to your local thing you don't
00:16:56 – actually need to write all that of logic
00:16:59 – just drop alex app server in the root
00:17:01 – under where where you have these
00:17:02 – functions skilled and then its mouth
00:17:05 – them automatically and has a debugger
00:17:07 – and has a bunch of other tools that come
00:17:09 – with it and it's easier to write tests
00:17:12 – and stuff like that it's those libraries
00:17:14 – like Alexa utterances that generate
00:17:16 – these others as many more others there's
00:17:18 – other types of things here something I
00:17:21 – didn't mention that the the the code if
00:17:27 – you going to host this yourself so not
00:17:30 – lambda where it is like I am permissions
00:17:32 – of invocation you have to you have to
00:17:36 – verify that the request came from the
00:17:39 – election platform for that there's some
00:17:41 – certificates for educational access
00:17:42 – service and more all that stuff so in
00:17:45 – this code somewhere i wrote like check
00:17:47 – search faults that means that i want my
00:17:49 – skill to not care about that kind of
00:17:51 – stuff but if you're doing the story all
00:17:54 – you need to verify that the requested
00:17:56 – just that somebody is not bombarding
00:17:58 – your functions with legitimate request
00:18:02 – so there's infrastructure for that
00:18:04 – didn't figure it out for you write the
00:18:07 – selection and our kids skill is open
00:18:10 – source and it can answer some awesome
00:18:13 – questions it has a new feature which can
00:18:15 – talk about podcast so Alexa asked RT for
00:18:20 – summary of the latest podcast our
00:18:22 – podcast
00:18:24 – for while this week we discussed the
00:18:28 – router ideological cetera
00:18:30 – electro stops alexa a scar to play the
00:18:34 – latest podcast show no that's like so I
00:18:45 – like to have the capability of playing
00:18:47 – audio streams you just give us an mp3 so
00:18:50 – the elderfield r-tx killed world of pull
00:18:54 – the RSS feeds from SoundCloud that we
00:18:56 – publish to iTunes and then just use that
00:18:58 – just catch the latest mp3 stream and
00:19:01 – just like spit it out
00:19:02 – so three easy to stand audio to alexa
00:19:05 – that is not your own words but you can
00:19:07 – take this to you can do text to speech
00:19:10 – or you can just send files for audio so
00:19:13 – you can create some interesting
00:19:13 – experiences as well it's like audio
00:19:16 – player function out you have to enable
00:19:18 – it actually you I that's all I have
00:19:21 – thank you


Video Url:
http://youtu.be/pzM4jv7k7Rg

Comments

comments