![]() ![]() I then had to point it to the URL of my webtask, and for my own purposes, that was all I needed to do. Here's a screen shot to give you an idea of the interface. You do not have to list every single possible iteration but the more you do, the more flexible your skill is. Each intent will have a set of sample utterances which are basically ways to express the intent. You can think of that as two intents - "Order" and "Menu". For example, when you go to Starbucks and speak to the person behind the counter, in general your conversations are limited to ordering and asking about the menu. Intents are like broad categories of communication with your skill. I went into the Alexa development portal, created my new skill, and set up the one intent it needed to operate. Again, I'm not going to go into detail about working with Alexa, but for very simple skills like mine, this was all that was required. All my code does is random select a quote and then output the correct JSON response for Alexa. Note that the quotes variable above is heavily truncated for this post. Return Math.floor(Math.random() * (max - min + 1)) + min * Using Math.round() will give you a non-uniform distribution! * Returns a random integer between min (inclusive) and max (inclusive) I created a new Webtask, my current favorite serverless platform, and whipped up the following: const quotes = Luckily, you can copy to the clipboard via the console: copy(q) The final step was to get this data out of the browser. Note I'm using hipster JavaScript fat arrow functions here and Google totally should have hired me despite my sucky Sudoku solution tester. I fixed that with a regex: q = q.map(quote => quote.replace(/\n/,'')) So the extra line break at the end bothered me a bit. quotes.forEach(quote => q.push(quote.textContent))Ĭool. I created a new empty array (again, all of this is in my browser console): let q = Īnd then loop over quotes to get the textual content. It returned a NodeList of 133 items, which seemed correct to me. ![]() ![]() The CSS selector there should match the P tags inside the tables. So I switched to my console and entered: quotes = document.querySelectorAll('table.cquote p') But then I noticed that it was wrapped in a table with class cquote. You can see the main quote is a simple P element. I've called out two things in particular in the screen shot above. I then inspected one of the quotes to look at the DOM: Here's how I built it.įirst, I Googled for "ice bear quotes", and not surprisingly, found a wiki page containing a list of them. I thought it would be cool to build an Alexa skill that would select a random Ice Bear quote. It probably doesn't translate well here, but in the show it is funny as hell. (Or adults who still play with Star Wars toys.) Ice Bear is one of three bears and speaks in the third person. This is a children's show that - like many of them nowadays - can be pretty fun for adults too. Who, or what, is Ice Bear? Ice Bear is a character from the "We Bare Bears" show. Last time I checked you still couldn't do this with Google Home devices and that's why mine has been mostly ignored.Īlright, so on to Ice Bear. Yes, stupid, but it made her happy as hell and the point is - I think it's dang cool that you can hack on Alexa devices like this. Because honestly, look at this face, it can't be her fault, right?Īll the skill does is simply pick from a random list of her siblings, Obama, and Trump. As an example, I've got a skill for my Alexa devices that allows me to ask Carol whose fault it is. That means you can build crazy, dumb, strictly personal stuff for your own devices. As a reminder, you can build any skill you want for your Alexa devices and do not have to release them to the public. Instead, I simply wanted to share a simple skill I built a week or so ago - purely for fun - as a way of demonstrating how easy it is to do. I've got a series of blog posts talking about Alexa development and I plan to create an updated tutorial early next year. Before I begin, let me stress that this is not a post meant to introduce you to Amazon Alexa development. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |