We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Inventing Friends: ActionCable + AVS = < 3

00:00

Formal Metadata

Title
Inventing Friends: ActionCable + AVS = < 3
Title of Series
Part Number
41
Number of Parts
86
Author
License
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Chatbots, ActionCable, A.I. and you. And many more buzzwords will enthral you in this talk. We'll learn how to create a simple chatroom in Rails using ActionCable, then how to talk to your colleagues in the office or remote locations using text to speech and Amazon Voice Service. Using the power of ActionCable we will explore how its possible to create an MMMOC: massively multiplayer online chatroom, that you can use TODAY to see your; Travis Build status, or deploy code to your favourite PAAS, let you know when the latest release of Rails is out. Using nothing but your voice and ActionCable.
Multiplication signMoment (mathematics)Slide ruleComputer animation
Multiplication signInternetworkingWeb 2.0WebsiteGraph coloringProcess (computing)Computer animationPanel painting
Game theoryHand fanComputer animation
CASE <Informatik>Hand fan
Open sourceProjective planePoint cloud1 (number)Client (computing)Product (business)Figurate numberCartesian coordinate systemMereologyInformationSet (mathematics)Service (economics)Web pageBitType theoryWordMusical ensembleSampling (statistics)Integrated development environmentCodeUltraviolet photoelectron spectroscopyDot productSupremumData structureRainforestNormal (geometry)InternetworkingComputer fileSlide ruleComputing platformVideoconferencingComputer configurationNumbering schemeView (database)Multiplication signElectronic mailing listVariety (linguistics)Data miningLatent heatPresentation of a groupSoftware development kitImage resolutionWeb 2.0Electronic visual displayLaptopVideo gameElectric generatorAdditionForestMoment (mathematics)TrailControl flowQuicksortService-oriented architectureCoefficient of determinationTensorStudent's t-test3 (number)Scaling (geometry)Ferry CorstenSpacetimeRight anglePoint (geometry)Programmer (hardware)CASE <Informatik>User-generated contentMathematicsFile formatRadical (chemistry)Game theoryFood energySoftware developerXMLComputer animation
Demo (music)Video gameCartesian coordinate systemWeb pageType theoryElectronic mailing listMultiplication signData typeString (computer science)Sampling (statistics)CASE <Informatik>QuicksortSeries (mathematics)Sign (mathematics)1 (number)CodeBit rateGroup actionUniform resource locatorDifferent (Kate Ryan album)Mobile appXMLSource code
Service (economics)Demo (music)PhysicalismInteractive televisionNeuroinformatikFigurate numberFrequencyDirection (geometry)Disk read-and-write headComputer animation
Message passingService (economics)Real numberBitProduct (business)
Revision controlGreatest elementLine (geometry)Term (mathematics)Multiplication signService (economics)Scripting languageMereologySpeech synthesisGoodness of fitCodeFinite-state machineMobile appInternet forum
Error messageStrategy gameRight angleInformationGradient descentRevision controlWeb pageHeat transferMetadataService (economics)Scripting languageMultilaterationXML
Service (economics)MP3Computer fileDependent and independent variablesTranslation (relic)CuboidServer (computing)Bit rateType theoryReal numberSpeech synthesisGroup actionBuildingFormal languageKey (cryptography)CAN busProduct (business)Different (Kate Ryan album)Multiplication signWeb pageFront and back endsDebuggerParameter (computer programming)NeuroinformatikRight angleModal logicWaveLatent heatFunction (mathematics)Point (geometry)Direction (geometry)Instance (computer science)Video gameScaling (geometry)Control flowSpacetimeComputer animation
Enterprise architectureGroup actionCASE <Informatik>Server (computing)Basis <Mathematik>Message passingUniform boundedness principleFigurate numberRight angleXMLUML
AnalogyDependent and independent variablesRight angleMultiplication signDispersion (chemistry)BitPay televisionDifferent (Kate Ryan album)CodeReduction of orderWeb browserSpeech synthesisConnected spaceGroup actionWordExterior algebraCellular automatonSynchronizationFamilyRule of inferenceBroadcasting (networking)Point (geometry)SoftwareSlide ruleMetropolitan area networkMessage passingCASE <Informatik>SurfaceMultiplicationCartesian coordinate systemRevision controlServer (computing)Shooting methodConnectivity (graph theory)Mountain passSineClosed setDebuggerNetwork socketComputer fileWeb 2.0NeuroinformatikFront and back ends
Computer wormDependent and independent variablesService (economics)CodeComputer fileCartesian coordinate systemGenderCone penetration testComputer animationXML
String (computer science)Type theoryDemo (music)Instance (computer science)PlastikkarteStatement (computer science)Dependent and independent variablesMusical ensembleMassArmDifferent (Kate Ryan album)InferenceGame controller
Demo (music)Multiplication signMobile appPlastikkarteRoboticsDemoscene
Multiplication signGroup actionField (computer science)CASE <Informatik>Real numberKernel (computing)CuboidDemoscenePoint (geometry)Query languageDatabaseCodeRow (database)MeasurementProjective planeComputer fileCartesian coordinate systemComa BerenicesService (economics)Video gameKeyboard shortcutSoftware testingInformationBuildingSpacetimeError messageDemo (music)MathematicsNeuroinformatikScheduling (computing)Right angleWordReplication (computing)Directory serviceClient (computing)Software developerForm (programming)Context awarenessHookingMobile appInformation securityPerturbation theoryConnected spaceRoundness (object)Computer animation
TouchscreenPhysical systemComputer fileWebsiteVirtual machineSeries (mathematics)Pattern recognitionInternet der DingeMessage passingComputer animation
PasswordMP3Group actionSoftware bugNeuroinformatikAxiom of choicePower (physics)Right angleLoginComputer fileGoodness of fitTouchscreenWeb browserMessage passingVolume (thermodynamics)Element (mathematics)QuicksortLink (knot theory)Multiplication signOpen setProgrammer (hardware)Demo (music)Perfect groupSpacetimeQuery languageGastropod shellBit rateEinbettung <Mathematik>Context awarenessTable (information)Online chatType theoryComputer animation
Formal languageMultiplication signAdditionVideoconferencingLink (knot theory)Code1 (number)Online chatXML
SpacetimeComputer animation
Transcript: English(auto-generated)
Hi, I'm Jonan. I should have warned our friend in the back that I speak especially loud
all of the time. How about I actually put the slides up? Or do you want to view it like this? Is that, should we play? Let's just play. It's easier that way. I'm here to talk to you about inventing some friends. I'm a friend. Hi, friend. Should I go through my whole intro and then you want to go? You want to just tell people who you are? If we don't want to let this mystery settle for a moment? His name is Julian. He's from Australia. G'day. I'm Jonan and I'm from Portland, which is much like Australia,
except not. It rains more. I'm the Jonan Show on the internet. I work at a company called Heroku. You may have heard of us. We invented the color purple. It's fantastic. If you're wearing purple today, you're welcome. If you have any questions about Heroku or our color,
hit me up. A long time ago, I used to make websites to sell Diablo II in-game items, until they made a patch update and made my whole company illegal. And then I had to find a new job. And then I made this. This is my daughter. She doesn't suck on her toes anymore, but it's by far the cutest picture I have of her. This is my son hogging all the ice cream at a Costco. He's adorable. I used to sell cars then after I stopped selling
Diablo II game items. And then I was a poker dealer. And that is a brief history of Jonan. And the reason I am telling you all of these things is simply so you have something to ask me about in the hallway, because I'm leaving a lot of questions unanswered. So come talk to me. Hi. So I'm Julian. I'm a big fan of Tweed. I live in the World Heritage Site of Bath in the UK.
So just in case you're confused, I don't actually live in London. Just want to make sure that you know that I don't live in London. I do actually live in Bath. And as you can see, it's called Bath because we basically have lots and lots of baths. But if you do ever come and visit, the good news is I've heard from friends that stayed in some of the local hotels that we do
now have showers. So if you aren't a fan of bathing, you can now shower. So I work at a small open source company called Red Hat. We also sell hats, which is pretty neat. I work on a project called Manage IQ, which manages clouds. But you know, here in the desert,
there aren't any clouds to manage. So I'm not sure really what I'm going to do. And I'd like to introduce Amazon Alexa, which would help if I got my laptop back to join in quick. Just track them. Did I just break the resolution of the display when I did that? I went to presenter
view so we could see the next slide. This is going to be on the video for all you watching at home. The play by play. Are we ready? Okay, go ahead. Ask Rosie to give her talk introduction. Come on internet. You can do it. I think I can. I think I can. Oh my. If you could all stop.
The requested skill took too long to respond. Okay, let's try again. Seriously, everyone turn off your phones and everything. Delete. You can go to the next hall and ask
Rosie to give her talk introduction. Sup. I'm Alexa. This is my first trails conference. How are you enjoying it? It's so hot here in Phoenix. You'd think I'd be used to that being from the Amazon. I love DHH. He writes the best codes and runs so well about start ups.
I also really like tender love, but I can beat his puns any day. Come at me, bro. Just joking, tender love. Here is some advice. Don't give up on your dreams. Keep sleeping. Alexa. Not yet. You're shush. We can't say that one word that rhymes with shmexa or this
one wakes up automagically. It's terrible. Shall we talk about it? So the thing is we came here under a bit of a guise. We told you we were coming to talk to you about one thing. What we're going to talk to you about is actually our start up. Surprise. Julian
and I are starting a company. We'd like you all to be a part of it. Today is our product announcement. This is your first opportunity to get it on the ground floor. Friendster Bookspace. It is by far the most innovative application that has ever existed. I would give you some more details than that, but just know that it will improve every facet of your life.
Anything you can think of, your car, your phone, your dog, it will make all of those things better. This is literally the future of everything, this application that we've built, and I'm excited for you to try it today. But before we get into the details on that, Julian's going to talk to us a little bit about this other thing, our third friend here. Alexa. Actually, you're going to talk afterwards. I am. So yeah, so obviously as we're in the
future now, as William Gibson said, everyone is in the future. Something like that. We decided to use the Amazon Alexa's because we're forward thinking, and so we have a variety of them here. We have the Amazon Tap, which is the small pink one. We have
the big old just normal Amazon Alexa. I can't even lift that one. That's too heavy. And it's so small, I've lost it. And the tiny little that you can even just carry around in your hand, Amazon Dot. So those are the Amazons, and there's the Rainforest edition. If you go shopping later, the important feature of these two is that they have audio out,
so you can connect them up to all of the speakers in your home or your stereo. This one does not, but you can pair it as a Bluetooth speaker to play music back through it and all of them. Over to me. To the Alexa skills kit. This is the magic that we are doing. When we talk to Alexa, we tell Alexa to do a thing. So what Julian
just did with his Alexa is he gave it a text prompt, and that was transformed into a bit of text that we sent up to the Amazon Alexa service. The Alexa skills kit is a way for you to make Alexa say whatever you want it to say. And I'm going to walk you through how to create one of these skills in the Alexa platform. I wish that we were going to do this in a terminal. We're going to do it in a GUI, because this is
how you set up the Alexa skills kit. There is not actually another option for this. But all of the things that I'm going to show you, I'll show you an easy way to do. So this is the page when you log in here. This is your skills information page. You have to go to this page to create a skill if you want to add something to Alexa. There's nothing on this page that is really important except for your application ID.
This is something you're going to have to ship up with your information from your application, because you're going to build a back-end service to send data to the Alexa skills kit, or to take a question from Alexa skills and give it back the answer. So you've got this application ID. In my example, I wrote an
Alexa skill called HAL. And the invocation name for HAL is HAL. So if I talk to my Alexa and I tell HAL, I tell Alexa to tell HAL to do a thing, then that will be sent to this particular skill. And you can have as many of these as you would like, right? So this skill here has an intent schema. And the intents are what people will do with your thing. So my skill, HAL, deploys things, deploys applications on Heroku specifically.
So you can tell HAL to deploy Steve to production, and that will work. In fact, maybe now is a good time to try it. Well, I'll show you in a moment, actually. But this intent scheme I want to walk through real quick. This isn't a JSON format, okay?
It's not just a JSON file that you can submit up or post to an API and create. But you have to go and log into the UI and paste in your JSON. And there are Ruby gems that generate this JSON structure. If you know basically what you're trying to create, you can use those gems to generate it, or you can just look at some of these examples online, fill in the intents. They have these custom slot types. These are types that are referenced in the schema.
These are the things people will say. You have chunk one, chunk thing. Deploy Steve to production, right? And that allows Alexa to extract those two pieces from my intent and just send me those. So all my application has to deal with is Steve production. And I think we can all figure out where to go from there, right? But the piece of going from tell HAL to deploy Steve to production,
just to Steve production, is harder, right? And that's where Alexa comes in. So then you set up a couple of custom types. These are the types for mine. I have an application list and an environment list. I have my names of my applications, Steve, Hal, and Heaven, and my environments in there. And then you give it some sample utterances to train it up. So I say deploy, this deploy thing in the beginning is a little bit deceptive
because that's actually the name of this skill. So I'm telling Alexa to, like, basically that first part is going to be Alexa, okay? Just pretend that deploy says Alexa for the purposes of this. Is there a tell, or I'm sorry, a Hal. Tell Hal to deploy Steve to production. And I give it different ways to say it, right? You can also say to ship Steve to production.
It happens to be that deploy is the easiest one for it to recognize. So do that. And then you set up your endpoint, and this is an important step. Set up the endpoint that you want to be able to talk to, and when Alexa hears from you this particular phrase, it will post to that endpoint with some data. And then this is where my HAL production application lives,
and Julian is going to walk you through one of these generators and how to create these things. So being an Amazon web service, you know, it likes you to create artisanal JSON, but as we're all programmers, after seeing Jonan's talk last year on Alexa, I got very excited, and I found that someone's actually written an Alexa generator that will generate
these utterances for you and that JSON. So here's just a quick example. This is actually on the Amazon page. There's an example of creating a horoscope application. So this is just creating that. So as you can see, we've got the different horoscopes, star signs, and then some different days.
So you would sort of say, you know, Alexa, tell me my star sign for tomorrow. I'm in the queries, or something like that. And that will then generate all of the data for you. Unfortunately, this gem currently only has a few built-in data types. As you can see, there's like Alexa generator slot type literal. That is just a literal string. That could just be anything in the world,
and the date type is a type of date. So using these slot types, it helps Alexa kind of recognize the string that you are passing to it. So as I was saying, this gem currently doesn't support many, but I do have a pull request in the works to send, because Amazon has a lot of custom types. It has all of these ones, and all of these ones,
and these ones. So just a few, and they cover everything from like TV serieses, to video games, to weather conditions, so you can kind of create all sorts of things. So back to our code. Once you've run this code, that will then create you this JSON. So this is actually the JSON that I'm using today
for my demo. So we've got things like dates and times, and talk types, and a list of speakers and locations. And then here are some of the sample utterances that we're gonna show a demo of afterwards of the things that you can say to my Alexa app.
The Alexa voice service. Has anyone used the Alexa voice service? I'm just curious. By a show of hands, anyone try to interact with this API? We have a couple. Yes. So the issue here, in particular for me, is that it's an HTTP2 API. And I am not smart enough to use HTTP2 APIs.
I actually am, but when I started, I was wrong, and I thought I was smarter than I was. I think given six or nine years, I could probably get a handle on how to handle this interaction. I'm not going to demonstrate for you today how an HTTP2 API works. I want to explain to you, though, first, why I want to use the Alexa voice service and what it is.
So an Alexa skill is I say a thing to Alexa, and Alexa says a thing back. And that thing back, I get to customize, right? But if I am going to have the Alexa be another device, for example, my computer, or a Raspberry Pi with a microphone and a speaker on it, or anything that is not a physical Alexa device, I'm gonna be using the Alexa voice service
to accomplish those interactions. So I want to give you a little demo of my HAL skill real quick. Alexa, tell HAL to deploy Steve to production. HAL has deployed Steve to production, hypothetically. I'm not actually able to give you information
about whether or not the deployer was successful because I can't deliver messages to you unprompted. That would actually be a terrible feature. Imagine if LinkedIn could send voice messages to your living room. You'd never stop hearing about how you're getting noticed. Which is fundamentally the problem for me,
in that that's exactly what I want. I want to be able to turn on my Alexa without any prompting. And there is no such thing as a push notification for the Alexa. But there is a bit of a fancy work around. And we have found a way to do that. But it is the Alexa voice service itself
that I want to demo for you today. So let's talk about that. I went over here to the Alexa voice service thing. And I'm reading through the HTTP API and I was like, oh there's a gem for it. Ilya wrote it, he is so smart. And I am so not smart. And I would love to be able to just whip this up. Every time I find a good gem I'm excited. I'm sure it's very easy to use.
I'm sure lots of you have used it. And I would love it if you would come up to me after this and teach me how to do that thing. That'd be great, thanks so much. But what I used instead is this thing that I found. There's a script, right? This is like a bash script I found online in a forum post after a long time of digging. Kind of when I had almost given up hope on being able to accomplish this piece of this talk.
And something stuck out to me and it was right here at the bottom. And it was a very important part at the bottom. It says v1 a lot. It says v1 right on it. The HTTP2 API is a v2 version of this app. It's the version two API for the Alexa voice service. And guess what the first version does not use?
Is HTTP2. So that was a lot easier for me to figure out how to do that thing because I can post for days. I am really good at posting. By good is a relative term, please don't read my code. Next, this is the actual speech recognizer that we're talking about here. There's a menacing looking warning on the top. This is an API you'll find on like
the sixth or seventh page of Google if you Google version one, an Amazon Alexa voice service API documentation. That's about as specific as I could get. It's buried. But if you find it or you want a link, hit me up. You'll also find bass scripts floating around. So I basically like took this and I ported this API into like a Ruby thing. And so I can post this thing.
Things like the OmniAuth strategy for Amazon don't work here. Because when you're interacting with the API you have to send scopes that it's not prepared to send. Or other information that's not prepared. Most notably also like metadata in the transfer around like a scope data tag and things. If you're particularly good at writing OmniAuth strategies maybe we could sit down and pair on one later. I would love to write one for this
or make a pull request I guess. So I have this other thing here I wanna talk about which is Polly, right? Imagine that you say a thing, right? You say some text to me. I'm going to send that text up to Polly, right? And that text, I'm gonna get it there by sending it this way.
Polly is, real quick, an Amazon API if you're unfamiliar that they announced I think last year that does translation or text to speech. Have people heard of Polly? I guess I kind of assumed some knowledge that that was unfair. Polly is an API that does text to speech translation using deep learning. And it's brilliant. It's very, very good at it. So when you say like I live in New York
or Saturday Night Live, live and live are spelled the same way. And there is no reason why a computer should be able to tell the difference. But Polly can. And it can speak in I think 16 different languages which is awesome. So you should play with that API. It's very well documented and easy to use. So there's Polly. We're gonna send some stuff to Polly. And how we're gonna do that is we're gonna put the text into action cable, okay?
This is where the action cable keys comes in. So what Friendster Bookspace, aside from changing the entire world, allows you to do is to type some text into a box and to send that text through action cable into the backend. And that is then going to be posted over to Polly, to the Polly service. And that Polly service is going to give us back
an MP3 response of what we just said, right? So I can tell Alexa to say anything I want, right? And then Alexa, I will take that text and I will send it up to Polly. Polly will turn it into speech. Okay, now I've got speech. And I take it and I put it in S3. We're gonna need it. And I don't immediately put it into S3 because it turns out that the Alexa voice service,
which is next, wants a WAV file with some very specific parameters. So what you do instead is you use FFmpeg in the middle. And you install a custom build pack to accomplish that. And then it breaks and then you install a different custom build pack to accomplish that. And that also breaks. But eventually it works. And what I'm doing here is I'm taking that MP3 file
and I am taking it back to FFmpeg, like just back ticks out, and translate it into a WAV file with like some specific bit rates. And then I send it up to S3, right? And then I use that S3 to read the file back and post it to the Alexa voice service, right? And the Alexa voice service sends me back an MP3,
which is the response from Alexa to arbitrary text that I just sent it, right? I can send arbitrary text to Alexa. So the thing that I was explaining a moment ago that you can use this to accomplish is that what you could do theoretically is create a skill that does nothing.
Just say, trigger my skill. Trigger Jonan's rad skill, right? And then between the time that Alexa talks to the endpoint it's going to talk to and the time that you tell it to talk to it, you get some text over there magically, right? You could be connected to your production instance, whatever it is. You can modify the response text back to Alexa.
And so you can have triggers on a server have Alexa say things unprompted, which is kind of magic. And it's not actually what I'm demonstrating here because it seems terribly dangerous to just let a crowd loose on that dream. But I've got an equally dangerous dream for you, I promise. This is what happens at the end. We take this MP3 and we actually put a chunk of stuff
back in through Action Cable to the front end to include it in the page. And then we play another thing, right? So let's talk about Action Cable real quick, right? I think you probably came to talk about Action Cable. It is enterprise ready, in case anyone was curious. This is an example of an enterprise ready commit with some seed users from our benevolent leader, DHH.
The notorious B-I-G is forever immortalized here in the enterprise ready Action Cable example application, which is actually really useful if you're trying to figure this out from the beginning. But I'm gonna walk you through it as simply as I can think to, okay? Action Cable, people have used PubSub. Are you familiar with PubSub, right? We have used that thing, right?
Or I can publish messages and other people can eat those messages, right? On something. It doesn't really matter what that is, right? This is kind of like the fundamental basis for what we're about to create. So normally when I ask a server for a thing, right? My browser is like sin, right? This is the first thing that they send, this little packet, right? So let's try it. Does anyone know what the next packet back is?
If I said sin, what would you say? ACK, okay, close. It's sin ACK. I didn't know that either. I thought it was ACK too. But ACK is what I'm supposed to say to the ACK. If you're a networking engineer and you think I'm wrong, please tell me why I just made bad slides because I am very interested to have found that thing. But anyway, that's how a typical response goes, right? I'm like, hey, synchronize.
You see me? And the computer's like, I see you, right? And then we're good. And then I send a file. But that's it. That's the end of our interaction, right? So a web socket is an alternative to that style of connection where I do a little dance and throw something is a little bit more like this where we're just screaming at each other all the time. It's just more screaming, okay? I scream and they scream
and we're all screaming all the time. It's a very peaceful arrangement. All right. So there are four major components to setting up an action cable thing, right? The first is the connection, which is gonna be inside your Rails application on the server side. The next one is the channel. This is so that you can have different ways, right? Anybody remember these TVs? When I was a kid, we had like five channels.
Y'all are spoiled. You had so many channels, you like gave up on channels altogether. And you're like, Netflix, man. I don't even use channels. Anyway, channel is just like a channel on your television, right? You got one, two, three, four, five, right? So I send things over one and I can have people listen to one or two or three, right? Not everyone's watching the same TV show all the time. Look at me, I'm a broadcaster. Then you have a consumer, okay?
The consumer's a little piece that sits in your browser and it consumes a thing, right? It eats up all of the stuff on all of the channels, right? And you can create subscriptions to specific channels. You can turn your TV to the notch you want. You can actually turn your TV to a lot of notches. It's like the little picture in picture feature. The analogy's breaking down, but you can do a lot of channels at the same time,
as many subscriptions as you want. So I'm gonna show you some code to do that real quick, okay? This is how you're creating a subscription. In this case, I'm creating a subscription to the deployment channel, right? When a message comes over this deployment channel, sending me some text, I'm gonna perform this action, this deploy action over here with that text.
And that deploy action is defined here in my channel, right? This is my action deploy. It gets some text. I log it, and then I take the text, and I put it into a deployment, right? To respond to it. And that's gonna kick off my whole backend. But it's a way, fundamentally, of taking these two components on this side, and these two on this side, and shooting things over the wire
between the browser and the server, right? The front end and the backend. So then, when I wanna send things back out here, I'm broadcasting to the server on a particular channel. This is the deployment responses channel. I said you could have multiples. This is a different one, right? And I put the text onto the deployment responses channel, which is the text you heard earlier from Alexa. She had that big diatribe. Alexa heard me say, deploy Hal to Steve to production,
and it sent that to my backend, and the backend generated the text response using that little action cable there, and sent it back out, okay? And then we're streaming from the deployment responses. So, the application that we are here to show you today is a little bit different than this particular version. This is what happens when you receive the data
on the deployment response, and then in the front end JavaScript, you can do speech synthesis on that kind of thing. You can actually use that skill that I just wrote in a browser, which is the point of using action cable for this thing. For doing the thing where you talk to Alexa, you don't need anything like that, right? But I wanted to have people be able to talk to their web browser and get it to do things, and that's what the Hal stuff does. So, that was a lot of words, and I apologize,
but Julian's gonna talk to you about something different so you can start hearing again, not just my droning. All right. All right, now back to some code. Right, so this is RailsConf, obviously, so for that, we've made Alexa on Rails. So, following on from the other gem earlier that would generate the utterances and the JSON file,
when your service actually receives the payload from the Alexa, you need to be able to handle that and then give a response back, and again, it's lots and lots of artisanal JSON. So, there's another gem that you should all go and download called Alexa RubyKit, and this is super, super simple. So, just in your Rails controller,
you just create a new instance of Alexa RubyKit response, and then you just need to generate the string. As you can see, my method that I call here is which demo am I calling, and in that, I pass in the Alexa variable, which contains all of those keywords from the utterances,
like the talk, the speaker, the day, and then I've just basically got a massive if statement that kind of works out, like, if this text was this, then I must reply with this. So, then you get all of that, and then you go down to the Alexa type. So, this was just an intent request, as in a user was asking for something,
and then you have the session end, which Alexa sends itself automatically. It's like, okay, I've finished now with the request. There are other Alexa types you can use, like you can say, Alexa, stop. No, Alexa, stop. Alexa, stop! If any of you have ever used Alexa to maybe play some music or set an alarm, normally you have to shout stop quite a lot to it. That's where you would put that in this Alexa type.
That would handle that response, so then you could reply with something back, like, oh, sorry, my bad. As well as generating that, this also creates the title card. So, in the Alexa app, you can see what the request was that you sent, and so you can see here, so this is in the Amazon Alexa app. It's got the title card of Alexa on Rails at RailsConf,
and Alexa heard me ask Rosie, who is speaking at 11 a.m. today, and then you can actually re-listen to your voice again, which is super fun, just to make sure, and then you can tell Amazon's like, no, Alexa somehow burnt the toast. I wanted to know what time it was. So, as you can see, my robot for Alexa is called Rosie,
aptly named after one of my favorite robots, which is Rosie from the Jetsons. Cool, right, so now you've heard about Action Cable, you've heard about Alexa. I think maybe it's time for some demos. Ship it. Ship it. Do you want to load up? Oh, I don't want them to know about that yet.
Oh no, you didn't see anything. So, are you going to talk to your thing, and you show them the fields? We've got 15 minutes, actually, maybe we'll go. What do you want to do? Do some demos? Yeah, do this one, let's go. Right, so I took the schedule from the conference, and I put that into a Rails app. That's running on the cloud,
and so when I talk to Alexa, it can then go query the Rails database, and hopefully come back with an answer. So let's see. Ask Rosie which room is tomorrow keynote. Sorry, couldn't find a thing. Let's try that again.
She really hates Australians, is the thing. But we'll try again. So that was, so one thing you have to do in your code is actually handle errors and things, otherwise Alexa doesn't really know what to say. So that was it, not being able to find anything in the database. Let's try another query. Ask Rosie who is speaking at 11.40 today.
Ask Rosie who is speaking at 11.40 a.m. today. Well, we have Krista Nelson and Certain Times,
Securing Rails Apps and User Data, Polly Shandorf, Tyrion Kosik, Sean Marcia, Sarah May, Panel, Developer Happiness Through Getting Involved, Jake Worth, Observing Change, A Gold Master Test in Practice, Justin Weiss, A Deep Dive Into Sessions, By Daily Joshy, Goldilocks, and The Three Code Reviews.
Overall a pretty decent lineup. I think you should see Polly Shandorf, Tyrion Kosik, Sean Marcia, Sarah May's talk. Rosie will even recommend things to you. I want a round of applause for Julian, because that is really hard to do, that thing,
that just happened. It's not actually that simple. Ask Rosie, give details of Aaron talk. Sorry, couldn't find a thing. Let's try that again. Any of you thinking about being speakers in the future, no live, don't do the live demos, okay? This is a terrible time. Ask Rosie, give details of Aaron talk.
Sorry, couldn't find a thing. Shall I try it? Is it still set to American, is that why? No, it's set to British. Oh, it is set to British. Ask Rosie, give details of Aaron's talk. Sorry, couldn't find a thing.
Let's try that again. I have been judged and found wanting, apparently not British enough. We'll try that one one more time. So the only annoying thing is I can't work out how to do apostrophes with the Alexa service, so it's like that's why it's Aaron and not Aaron's, but let's try it one more time. Ask Rosie, give details of Aaron talk.
Sorry, couldn't find a thing. Okay. I surrender. However, ask Rosie, who is speaking at 12.20 p.m. today in exhibit hall? It is, it's quit us. Okay, let's try last time.
Ask Rosie, who is speaking at 12.20 p.m. today in exhibit hall? Oh, such excite. Looks like it's time for lunch. So as well as like talking to the conference schedule to find out, you can actually do some useful things
for work, so you can hook it up to like any API that you like. Ask Rosie, what is Rails build status? They call me mellow yellow. The build is still building. So there are practical applications for this,
and with a decent Wi-Fi connection that is not me tethering from inside a concrete box, and you know, a little more robust handling, there's maybe not like a demo version, but something like you can actually use this to do things. I have used this to deploy applications. L gray T, hot.
The replicators on this vessel are not yet operational. Alexa's really good at jokes. We got it? We good? I'm gonna show mine? We are good. Ours? This one? I would like to walk you all to the future. There is a application here for your viewing enjoyment
called Friendsterbookspace.herokuapp.com, and as you're heading here, I would like to point out that this is a chat room being presented at a RailsConf talk that is very well bound under the code of context, so behave yourselves. If there's anything inappropriate, I am burning it down and breaking my computer and coming to find you,
and I have more information about you than you think. We're using a real name service, the Google app. More than that, WebSockets can give you a lot. I'll give you some details later. So, let's look over here at Friendsterbookspace. On this screen, though, like that. The future of everything. The first AI machine learning dialogue system
to leverage IoT home automation and voice recognition WebSocket technologies on a continuously integrated pass to enable MMLC. Massively multiplayer online chat room. Are you excited? Who wants to hug the future? Should I do it? All right. It's not on the screen, are you serious? I was just reading the thing. You're like looking at my garbage files.
Why are you doing that instead of what I want you to do? Now you can see? Oh my gosh. Now you know I have a messy desktop. That's like the most shameful thing a programmer can have, I feel like, right? OK, I'm going to try again. I was just reading this text here. It's not that exciting. I'm not going to read it again because it
was kind of hard the first time. But I will invite you to hug the future, which, out of context, doesn't make any sense. But as you can see, I've cleverly named the login button hug the future. So you click here. It's going to off me with my Google thing here. I will choose to not use this browser, first of all, because that would be a poor choice.
I apologize for that. But I'm here on the Friendster book space, and look at that. I am logged in. Magic. Wow, how'd that happen? Now you don't have any characters or my passwords. So I can go right in to the future here by clicking this, and I've got a chat room. And look at people talking in the chat room already. It's so exciting, right? It's a real live chat room.
Use an action cable. We finally found a use for action cable, and it's basically making Slack. Hi, mom. That's good. Yeah, it's the future. It's the future of Slack. And I want to show you why real quick, because I can say things like this, maybe.
Oh, no, that's not what we wanted to do. Did it just, OK. How about this? Now I want to do this. Please do a thing. Why are you doing that? Because people are typing. Is that really a bug I just introduced? Please stop typing.
OK. You got nothing for me? Hello, wheels conference. Oh, look at that. Yes. We just chatted to Alexa. And to show some joined up thinking, hopefully when I speak to this Alexa, that should also go in the chat room.
Ask Rosie, what is Rails build status? I'm Alexa. This is my first Rails conference. That's perfect. It wasn't quite what I wanted, but. It went great. What a good post, Alexa.
So not only can you speak to your Alexa from text, you can also do it with your voice, and then you can talk to your colleagues. So this is a remote worker's dream. Yes. It's why we all work from home in the first place, is to talk to our colleagues.
Jonan Scheffler asked, what do you want to be when you grow up? Right now, I'm translating MP3s to WAV files on the screen. I want to be the computer from Star Trek. This is a good answer. Thank you, Alexa. You can ask Alexa things. You can say things. All of the things that you ask Alexa to say and ask will happen in your own browser. So the audio is played back through me
embedding an audio element that has the S3 MP3 link in it that can then be played in the browser. You can also implement features. Yes, Alexa's got excellent jokes. You can also implement features that would allow you to tell other people. And so those channels that I was talking about creating earlier, there is one broad channel here. That is the messages channel that we're working through.
People post questions and things generally in that channel. And then each user has their own channel. So I could, hypothetically, have implemented a feature that would allow me to have Julian's computer say a thing. Raise your hand if you think that's a good idea in a live demo. No, you're wrong. Actually, incorrect. Totally incorrect. You could also implement a thing that iterated through all of the users
and sent to each of their channels anything you wanted. And I could send audio to all of your devices. If you were the sorts who all had your laptops open and the volume turned up way high right now, I could blast you all with an MP3. I'm just kidding. I'm not going to do that. But that would be something you could do with this type of thing. So the channels give you a lot of flexibility and a lot of power.
ActionKebble is a fantastic tool. Let's hop back over here very quickly. And I'll do this. And it worked. And you can see that. Do you see my dirty desktop still? Confreaks, go ahead and cut the desktop from the video. Let's see if we can find Aaron's talk again.
Well, now that it's working. Do Aaron's talk, yeah. Ask Rosie. Give details of Aaron's talk. Sorry. Couldn't find a thing. Let's try that again. We invite you to try on your own and find Julian in the hallways and try talking to his Alexa in your best British accent.
You can actually set the voice that it expects. And the thing where I was talking about Polly earlier having 16 different languages, you could very easily change this chat room code to send Japanese text and say Japanese text. And it's very good. So go and play with Polly. If you know how to do HTTP2, please teach me. Also, the other Amazon API documentation, the V1 stuff,
is very deep. But I can help you find it if you need a link. Hit us up any time. We're Red Roku, the new startup. Friends to book space. Thanks.