Amazon Alexa Intent not recognizing slot - alexa

I have a simple Alexa app. Language is en-AU.
I am testing in the console. I am typing, not using a microphone, so the problem is not in speech recognition.
On launch, I ask the user for the bus stop number. The intent definition JSON is below.
If I type "it is 3038" it works. Alexa calls my custom intent and the number is recognized and passed to lambda function. All good.
But if I type "it's 3038" it doesn't work! A built-in fallback intent is triggered instead.
Also, if I just put a number, it doesn't work. A lot of other phrases don't work either even though I am typing exactly the same phrase from the intent slot definition.
Why is this not working reliably and how can I let users provide just a number without using a specific phrase that Alexa likes.
{
"name": "GetBusStopIntent",
"slots": [
{
"name": "stop",
"type": "AMAZON.FOUR_DIGIT_NUMBER"
}
],
"samples": [
"Stop number is {stop}",
"It is {stop}",
"Bus stop number is {stop}",
"It's {stop}",
"{stop}"
]
}

To specify spoken numbers in the Amazon provided testing suite as in your specific use case.
stop 3038 would be rendered as ‘my stop is three zero three eight’ also play with just utilizing AMAZON.NUMBER instead of FOUR_DIGIT_NUMBER my experience is you’ll get better reckoning of the utterance

I also faced the same issue and the fix was very simple.
As you are using the keyboard to enter text for the SLOT for 4 digit number, you want to enter in WORDS, and not as digits
you are trying "it is 3038" instead you should type "it is three zero three eight"

Related

Pass simple string phrases to an alexa skill

I'm developing an Alexa skill and want to pass simple utterances like "How much are five oranges" to it.
My idea was to define utterances like
how much are {amount} {articleName}
with the slots amount of type NUMBER and articleName of type AMAZON.SearchQuery
But AMAZON.SearchQuery cannot be combined with other slot types. Thus, are there other ways to pass simple, non typed-strings like article names to a skill?
You could just use a custom slot type:
Overview of custom slot types
Create your custom slot type for articleName and just add a number of example slot values. This should work for you.
If the slot value can be 1 word as well as 2 words - make sure you add examples for both.
Once you've set this up in the developer console, you could test it (without deploying code), using the utterance profiler.
You can then tweak / revise as needed.
A custom slot type is not the equivalent of an enumeration.
Values outside the list are still returned if recognized by the spoken
language understanding system
Although input to the slot type is weighted towards the values in the list, it is not constrained to just the items on the list.
Ref here.

How to sample random numbers in Watson Assistant?

I'm using IBM Watson Assistant for creating a chatbot. I'm using the web interface with the intents, entities and dialog flow|tree (I don't know how it is called, I'm just calling it web interface).
I would like to define an array of the numbers [1,2,3,4,5]. Then one node should sample a random number without replacement from that array (e.g. 2), i.e. the remaining array is then [1,3,4,5]. After some time another node should pick another number at random from the array (say 4). And so on. How can this be implemented? I know about variables (e.g. $var) but I don't know how to represent arrays and sample random numbers.
Thank you so much for your answers in advance. And happy new year to everybody.
As a general rule about what might be possible we use the doc for the Spring Expression Language. Based on that, you could select a value from some data structure $some_array like this:
{
"context": {
"randomNumber": "<? (new java.util.Random().nextInt($some_array.size())) ?>"
}
}
After that, you access your value using
{
"context": {
"element": "<? $some_array.get($randomNumber) ?>",
"shorter_array": "<? $some_array.remove($randomNumber) ?>"
}
}
Now there are some issues (probably the bug mentioned in the comment), as the remove method should be the one from the gson JsonArray and behave like this:
Removes the element at the specified position in this array. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the array.
However, it returns the array with the element removed, not the element itself.
1) In your Dialog Node, define slots
2) In the first one, generate the random value (if array defined and not empty)
3) In the second, get the element and remove
Note, that even though this works, you should probably not use it in a production version of your Chatbot. Instead, put most of the logic in your application (including the control of the dialogue). The Web Interface is very difficult to test and the way the variables are parsed might change at some point.

One-word slot amazon alexa

I am trying to make a slot that can capture one word. I just want the whole directive to be one word long, and any English word will trigger the intent. I tried using Amazon.LITERAL but that can capture a whole phrase, which is not what I want. Is there any way to do this in Alexa?
There is not a way currently to limit the number of words returned in a slot.
You can prompt the user in a way that makes it clear that you only expect a single word, and your lambda code can verify that only a single word is provided in the slot.
For example, have Alexa say "tell me a word that ... you can say 'alexa, tell your-skill-name that the word is lucky'". You might say this for example during the LaunchRequest.
You can then verify that only one word was specified in the slot, and reprompt as needed.
The intent for the answer could look something like "MyWordIntent the word is {Word}"

Alexa Custom Slot Type: No value in intent

I've already posted this question to the amazon developer forum but don't receive an answer there. I guess Stackoverflow should've been the first choice from the beginning:
From my understanding if I use a Custom Slot Type even if the list of its possible values does not contain the spoken word the spoken word is still passed to the function. The documentation says
A custom slot type is not the equivalent of an enumeration. Values outside the list may still be returned if recognized by the spoken language understanding system.
Now I have a Custom Slot Type LIST_OF_PERSONS with values Matthias|Max and an utterance of
EmployeeDetailsIntent {Person}
If I call this intend with a value not in LIST_OF_PERSONS the Intent still gets called but the JSON does not contain a "value" key for the Slot:
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.a943e233-0713-4ea5-beba-d9287edb6083",
"locale": "de-DE",
"timestamp": "2017-03-09T14:38:29Z",
"intent": {
"name": "EmployeeDetailsIntent",
"slots": {
"Person": {
"name": "Person"
}
}
}
}
Is this "works as designed" or a bug? How do I access the spoken word in the Intent then? As this.event.request.intent.slots.Person.value is undefined?
My code lives in AWS lambda and I'm using the nodejs alexa-sdk Version 1.0.7. The language of my Skill is German.
(disclaimer: this post summarises my own "workaround". It might or might not be the "best way". Seems to have worked for me so thought I would share / document it here briefly)
I've recently bumped into similar issues for an utterance that looks like this:
"tell me about {townName}"
If I say "tell me about London", it works.
If I say "tell me about" (deliberately missing a {townName}), the program "dies" (and returns a JSON looking similar to your one, with undefined this.event.request.intent.slots.townName.value)
Though I'm not 100% sure whether this is meant to be a "feature" (i.e. we need to write smarter code to work around this) or "problem" (i.e. Alexa team needs to address or fix). This scenario has caused a real issue when it came to the certification process for me recently.
To get through this, I've implemented a workaround (or fix, whatever you call it) to avoid Alexa from "dying" as a result of this edge case.
From the Alexa skill-sample-nodejs-trivia index.js file, I've found a snippet function that helped me work around this (I've edited it a bit for my example for simplicity):
function isAnswerSlotValid(intent) {
var answerSlotFilled = intent && intent.slots &&
intent.slots.townName && intent.slots.townName.value;
return answerSlotFilled
}
(i.e. this function returns True for valid values for the slot townName and and False for undefined / otherwise).
When it comes to defining the intent, I could use this function to "get around" an empty slot value scenario:
var startHandlers = Alexa.CreateStateHandler(states.START,{
// bla bla bla//
"AnswerIntent": function() {
// handel missing slot value
var answerSlotValid = isAnswerSlotValid(this.event.request.intent);
if (answerSlotValid && moreConditions) {
// do something fun
}
else {
// handle empty slot scenario
}
}
// bla bla bla//
}
Would be interested to see if there are better / more "proper" solutions to this to handle empty / undefined slots more elegantly.
I have seen this happen when an intent has both utterances with and without a slot. For example:
myIntent what makes a car go fast
myIntent what makes a {CAR_TYPE} go fast
where CAR_TYPE has a list of different types of cars.
myIntent still needs to define the slot CAR_TYPE for the myIntent in the schema, but the first intent doesn't use it.
In this case, it might be best to include 'car' in CAR_TYPE and eliminate the first utterance. In other cases though, the sentence grammar really doesn't permit it, so you need to expect an empty slot like you're seeing.
I believe the issue is that utterances using a Custom Slot Type must be used with at least one other value.
For example
EmployeeDetailsIntent get {Person}
will work, while
EmployeeDetailsIntent {Person}
will not
Had same thing, get custom slot name, but value was missing in Json Input. Worked with normal slots. Using Alexa Developer Console. Had to add an "ID" value to my custom slot values and then I started getting values. I thought I had tried that before but maybe I had not put an ID on each value. That did the trick for me though where the other answers did not work for me.

'8 Ball' Program

I've tried looking on google but i guess I can just not get the right search phrases to find what I want. If you are familiar with the afterNET IRC server, there is a command '.8' which is an 8 ball. It answers more than just yes/no questions tho. It gives you a variety of answers based on certain words you use in your question, like when, where, color, etc
I'd like to make something like this but have no idea where to start. I've recently studied DFA (Deterministic Finite Automata), is that where I should start? I understand I don't want to be scripting out every possible combination of words people use, but it would be nice to have a system that feels sorta realistic (like the 8ball program on the IRC server), and is expandable for more 'words' whenever I want.
Thanks for any help/links!
You may be giving most 8ball implementations more credit than they deserve. I think the point is that the questions are for yes/no answers, so the provided answers only have to cover a fairly predictable set of possibilities.
Most 8ball scripts that I am aware of (example) will just use an array and a random number to grab an answer.
Magic 8ball bots are very popular on irc as they are very easy to implement - simply respond to text with a given marker (in this case ".8") and respond with a random answer.
I have never heard of a magic 8ball using a deterministic approach, Cleverbot style. Actually, trying that, I'm not even sure how deterministic that is as most of the responses are also totally random and unrelated to what I was saying.
// our answers array
String[] answers = [ "yes", "no", "for sure", "unlikely", "most certainly", "definitely not" ];
public String ask8Ball() {
// rand returns a float between 0>=res>1, the (int) cast rounds down
int index = (int)(java.lang.Math.random() * 7);
return answers[index];
}

Resources