How does Alexa's conversation flow work? - alexa

I want to write a quiz/interview game where the flow is like this:
"Alexa, start Movie Trivia."
Welcome to Movie Trivia. Do you need to hear the rules?
"No."
What category would you like to play? Comedy, drama, or animation?
"Comedy."
Question 1. In what year was Star Wars released? A, 1970. B, 1977. C, 1980.
"B."
Correct. Your score is 1. Question 2...
I managed to write spaghetti code to accomplish this, with lots of if session.attributes.category, if session.attributes.needsRules, etc stuff, 3 pages of nested if-elsing.
I'm using Node and the official Alexa SDK, so I read its documentation cover to cover, but it's quite confusing and broken in places (examples that haven't worked since June, instructions for old UIs and so on). My question is: what kind of flow is 'correct'/traditional for something like this?
In the code I was writing, I used elicitSlot a lot, which is nice because it lets me listen solely for the things I expect to hear (eg answerType "A", "B", "C"). But elicitSlot leads to you re-triggering the same intent. So would it be a matter of having each intent check if a slot is filled, and if not, speak a question and elicit that slot, and if so, set a session attribute and then forward to a different intent?
That seems sloppy. Maybe the solution is to define an askingRulesState, askingCategoryState, askingQuestionState, etc, each with only a single handler. But states with only a single handler seems... wrong?
If I'm going to ask the user a question like "What category would you like to play?", does that mean I need to create a SetCategoryIntent? And if so, how would I prevent the user from triggering that intent except when I want them to?
I realise this is a bit of a big vague question but it's really difficult for me to boil it down to something smaller and clearer, since my issue is that the flow in general is really disorienting to me. I'd appreciate even the smallest tip!

You might have a look here, this will handle a lot of the if else's and elicit slots you wrote. For the questions and such you wil indeed probably have to make a state so you can check if you are in question asking state or just in the set-up state. This will help your skill deter men what it has to do. (don't forget to ALWAYS put this state back in because Alexa is tricky if you do not do this sometimes. You can find more info over here. This also looks like a pretty good example of what you are trying to make.
Hope this helps you forward a bit.

Related

Eliciting states and counties with Alexa

I have a skill that elicits a U.S. state and county from the user and then retrieves some data. The backend is working fine, but I am concerned about how to structure the conversation. So far, I have created an intent called GetInfoIntent, which has two custom slots, state_name, and county_name
There are about 3,000 U.S. counties with many duplicate names. It seems silly to me that I am asking for a county, without first "narrowing down", by states. Another way I can think of to do the conversation is to have 50 intents, "GetNewHampshireInfo, GetCaliforniaInfo, etc. If I did it this way, I'd need a custom slot type for each state, like nh_counties, ca_counties. etc.
This must be a pretty generic problem. Is there a standard approach, or best practice, I can use?
My (not necessarily best practice) practice tips:
Single slot for single data type. Meaning only have one slot for a four digit number even if you use it in more than one place for two different things in the skill.
As few intents as you need
no more no less. You certainly can and should break up the back end code with helper code, but try and not break the intents into too many smaller pieces. It can lead to difficulty when Alexa is trying to choose the intended intent.
Keep it voice focused. How would you ask in a
conversation. Voice first development is always the way to go.
For the slot filling I think it is fine to ask both state and county.
If the matching is not correct ask for confirmation.
Another option is to not use auto filling within the Alexa skill and use the dialog interface. Ask the county first and then only when it has more than one state option and is ambiguous continue the dialog to fill the state.
Even if you did have 50 separate intents you really never want to have two slots that can be filled by the same word. For example having a mo_counties and ky_counties that Clack satisfies both is ambiguous and can cause unneeded difficultly.
So for someone looking for the "best practice" I have learning that there isn't one yet (maybe never will be). Do what makes sense for the conversation and try and keep it as simple as it needs to be and no less on the back end.
I also find it helpful to find a non-developer to test your conversation flow.
This wasn't really technical and is all opinion, but that is a lot of what Alexa development is. I would suggest Tuesday Alexa office hours at https://www.twitch.tv/amazonalexa very helpful and you can ask questions about stuff like this.

First Lua program--formatting text, color, background

I'm brand new here, and also to Lua, so please bear with me...
I'm building an Airport in Minecraft, with my kids. I'm an overachiever and a dreamer, and at some point, my brain decided it would be a FANTASTIC idea to add in a cosmetic element that I have absolutely NO idea how to do. Smart, right?!
See, I got it in my head that I want to have display screens in our Airport that show the flight information of incoming/outgoing flights. Fast forward to my discovery of the Opencomputers mod for Minecraft, a few hours of watching tutorials on how to operate it, and thus began my search for knowledge of that which is the Lua language. Fortunately, I have a wee bit of coding experience (thanks to my college days) and I picked up the very basic of the basics. (It seems similar to C.) I've gleaned just enough to accomplish the bigger part of my goal: I've managed to write the bare bones of the program I dreamed up, and it works...for the most part. (I still need to figure out some redundancies and such...all in good time.)
But...it's so very plain, and not fancy at all. It doesn't look even remotely like what I was picturing in my head, and this simply will not do. So now I am on a quest to discover how to format the output of my program and make it look fantastic...or at least, as close as I can get it to what was in my head. I have managed to figure out how to change the gpu screen colors (foreground, background) so that is why it's blue/white. But it's not quite what I wanted, and it resets if the system is turned off. My goal is to change the format of the program output itself, not just the Opencomputers screen block. I've googled this until I'm blue in the face, and I have pored over forums and code tutorials and the like...only to fail at finding the information I need. It's possible that I've passed up the answer, simply because I'm still very new to the language, but that's another good reason for me to be here, right?
And so, I turn to you, O Great Dwellers of the Interwebs, the Keepers of Vast Programming Knowledge, for assistance. Please, pretty please, help me make my program look awesome. My kids just may think I'm the coolest Mom on the planet, and that would be more than fantastic...Not to mention we'd have one kickass airport to play around in. :)
Here's what you'll probably want to know:
First, This pic is what I want, (on the left) and what I have (on the right).
And here is the code for my program: http://pastebin.com/60nPfpB8
I apologize up front for all of the noob mistakes that my code is more than likely riddled with. I haven't figured out yet how to make the functions repeat themselves, or a good way to utilize a 24 hour clock for the "time" function. So any suggestions there would be welcome as well.
Thank you for taking the time to read, and I appreciate any help I can get with this. :)

How can I implement an AI-driven conversation system?

I want to implement a conversation system into my RPG (trying to get advanced AI as possible). Conversation as in, the player types:
"Hi, I would like a beer"
and the bartender would respond with
"Coming right up"
and then hand the player a beer.
I've got some ideas and some things I'd like to try, but first I would like to look at what's already been done. But extensive Googling does not turn up anything, so I'm wondering: has this been done or is there research being done in it? (I know this is very complicated, but I'm willing to give it a shot.)
Sure it has. Have a look at the "Eliza" program and its descendants. There's also a Wiki article on chatterbots that might interest you. Have a look at AIML as a way to represent the rules you might use.
For an advanced design, look up the game "Façade". The game's site describes the technologies used and gives links to relevant papers. There was also recently an extensive article in Gamasutra about this, called Beyond Façade: Pattern Matching for Natural Language Applications.
You may also want to look into the Turing Test and it's relevant scientific following/conferences/publications to see what has been done in the humanizing of AI speech.

How to create a smart chat-bot? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I know that it's still an open problem so I don't expect to see complete answers here. I just want to find some approaches to solve the next problem:
I have a model (assume that is's bot's memory), and different words are associated with different objects in the model. Speaking with the bot is like executing sql-queries with a DB. Language is a very hard formalizable protocol. And we can't just write a million lines of code to implement some real language. But I believe that it's absolutely possible to implement some self-learning mechanism. How can it be implemented? Is it possible to implement learning "from scratch" or "from few basic words"? Just want to hear your ideas.
Actually, English is a very strict language and it's one of the easiest languages for experimenting with AI. Many other languages allow you to change the order of words (for example). And in some cases changed order can change the whole meaning or just add some intonation. I really don't have any ideas how to teach a bot for these things.
The first step, in taking this game to the next level, is ...
...to have a very clear view of prior art!
(and pardon me to say, the question doesn't suggest that you have such an extensive insight into the matter [and you're not alone, count me in ;-)])
Even, and maybe in particular, if your intention is to apply completely novel techniques and models, it seems important to review the literature on current and past practices. Aside from possibly identifying elements that may be adapted or reused in a new implementation, a survey of the domain will provide an keen understanding of the nature of the problem[s].
I've personally tried -on various and multiple occasions!- either the naive approach or the sophomoric approach to tackling broadly-defined problems. With the naive approach, one has but a very slight idea of the true nature and scope of the problem. The sophomoric sees us better equipped with domain knowledge and also with related tools, but this can also be misleading because without a deeper understanding, we tend to mis-read/mis-understand new material offered to us and also misuse some of the tools (a bit like the the fellow who's "good with a hammer" for whom many things look like a nail...)
It is particularly easy to make these mistakes in the field of NLP. That's because
Common sense seems to be all is required: after all a child, who's native tongue is English understands subtleties like
"He's not really an expert"
"He's really not an expert" (small wink at the OP's reference to the ordering of word in the English language)
We live in such exciting times, technology and knowledge wise: Processing power, programming language and tools, mathematical techniques, availability of affordable corpora... to name a few of these things that make this moment in time so special.
Far from me the idea of discouraging you in your chat-bot endeavor, I just hope that this long and generic exposé will encourage to look-before-you-leap, as this will truly save you time in the long run, I think in two ways:
provide you some frames of references (again, even if your intention is to "think outside these boxes")
maybe entice you to redefine the problem, for example by limiting it to particular domains of conversation (sports, or health, or life at a particular university campus...) or by focusing on a particular aspect of the problem (semantic awareness, smooth, natural sounding grammar, use of colloquial forms...)
Good luck ;-)
Check out MegaHAL's implementation for some ideas. We've used a variant of this bot for ages in an IRC channel of ours, and he does on occasion appear to be the intelligent mixture of many of our dominant personalities.
You "train" the bot -
each time the bot answer, you rank (or the tester) the answer - if the answer is good/logical - give high rank, if the answer is bad... low/negative rank.
use the ranking in the future to choose the answer, and this is how the bot learns...
There's a great description of Eliza in Paradigms of AI Programming. You should be able to implement a simple Eliza bot in a few days of work.
This isn't a learning algorithm, but it's surprising how realistic answers can be from something so simple.
You can create your own chat bot on BOT libre, http://www.botlibre.com.
The bots learns, can be trained, can be scripted, and your can program them, or let them program themselves.
Thew site supports embedding your bot on your own site, has REST API access, Android, IRC, Twitter. Free hosting, even for commercial bots.
AIML from the AliceBot project may help you out. It's a whole XML schema (if that doesn't put you off) for the branch of AI its concerned with.
An example from Wikipedia:
<category>
<pattern>WHAT IS YOUR NAME</pattern>
<template>My name is <bot name="name"/>.</template>
</category>
RebbeccaAIML is one quite well documented implementation.

Modelling C applications

I would like to know if there are any tools that can help me model C applications i.e. Functional programming.
E.g. I'm currently building a shared library.
But to communicate my design visually, I need something like UML. I would like to do this so that the person reviewing my design need not read through 100s of pages of functions, variables and so on.
I have read about UML for C, which I'm considering.
If there is anything better out there, please let me know.
The bottom line is to visualize the design of C applications and modules without reading through 100s of pages of text, because it takes time and is difficult for the reviewers.
Any help in this area from the experts here would be much appreciated.
Thanks.
A well written text documentation brings you a far. Much further than any UML diagram could ever achieve.
You should split this in two parts:
What do you want to say?
What's the best way to saying it?
Whatever formalism you use to answer the second part, you should be sure it's not ambigous.
The good of UML is that a lot of semantic is already defined by the language so you don't have to include a definition of what those boxes, lines and arrows mean in a collaboration diagram.
But most importantly, documenting something means create a path for others to understand the subject you are documenting. A very precise description that offers no clue on how to read it is as good as none. So, use UML, Finite state machines, ER diagrams, plain English, whatever you want but be sure to include a logical path that your "readers" can follow to understand what's going on.
I had a friend that was a fan of "preciseness at all cost" and it would ask us to go through all the details before some sort of meaning would emerge.
I once ask him to do this experiment: on his next trip to an unknown city, he would have to carry the most precise map he could get. Much better, he would have to carry a 1:1 map of the city with every single detail exactly reported in scale. That way he couldn't get lost!
He declined but I would love to see him trying to use that map. Just even folding it! :)
Whatever you like. It's not a standard but many devs use it and understand it. If it does help you to communicate with other people and document your work -> its for you. If it just takes too much time and you think it's not effective, drop it. Also, don't bother with all details, as long as it resembles UML and your team can work with it, it's fine.
It's meant to help you, not waste you time.

Resources