Alexa Skills Kit: Can't get AMAZON.NUMBER, AMAZON.DATE to work - alexa-skills-kit

This should be simple and straightforward, but I am having a hard time getting it to work. So:
Using AMAZON.LITERAL for a number like below works fine:
IntentSchema:
{
"intent": "Group_Size",
"slots":[
{
"name": "GroupSize",
"type": "AMAZON.LITERAL"
}
]
}
Sample Utterance:
Group_Size {forty thousand|GroupSize}
BUT when I change the slot type to AMAZON.NUMBER (which is what it should be) and utter 'forty thousand' or 'three nine six seven four' it stops working. The returned intent is one that is intended for Help and not Group_Size anymore (in other words, an irrelevant/incorrect intent is returned).
Same issue when I use AMAZON.DATE for one of my other intents.
I am fairly new to A-S-K, so is there anything special I need to do to get these predefined types to work? I went through the documentation and some code samples, but didn't find any gotchas. Any pointers please?

Worked when I passed NUMBER instead of AMAZON.NUMBER.

Related

Custom Slot wildcard value?

First off, I do not want to use AMAZON.Literal as it is for US only (I'm UK based) and I doubt it will be supported much longer.
I need a wildcard slot to allow users to say a place name (name of a shop for example), followed by the city.
City is easy, no problem.
The issue is the place name. I have a custom slot, but I can't list every shop in every city in the values.
I put a value of any in, which kind of works, but in my response, I'm only getting the last word if the user says a name that contains a few words e.g. Pound Land would just return Land.
Has anyone managed to do this?
As of 2018, you can use phrases to get user input that you may not be able to predefine.
{
"intents": [
{
"name": "SearchIntent",
"slots": [
{
"name": "Query",
"type": "AMAZON.SearchQuery"
},
{
"name": "CityList",
"type": "AMAZON.US_CITY"
}
],
"samples": [
"search for {Query} near me",
"find out {Query}",
"search for {Query}",
"give me details about {CityList}"
]
}
]
}
https://developer.amazon.com/blogs/alexa/post/a2716002-0f50-4587-b038-31ce631c0c07/enhance-speech-recognition-of-your-alexa-skills-with-phrase-slots-and-amazon-searchquery
When using custom slot types, AWS may return values from outside of the list yet it will try to map to the values. You can "hack" this behavior by providing a huge list of possible values. Maybe try to scrap a list of places and use that. I once tried with a list of 3000 landmarks and it was definitely returning slot values that were not in the list. The recognition was not great but I had an acoustic similarity function that allowed me to retrieve items from the list when needed. That was a while ago when they first talked about deprecating Amazon.LITERAL but eventually left it so I didn't have to worry about this.

What would be a good API format for “IS NOT SET” clause?

I have a query API against my service, that looks like this (JSON-ish format):
{
filter: {
,attribute2: [val21, val22]
,attribute3: []
}
}
means effectively, select data WHERE attribute2 in ("val21", "val22") AND attribute3 IS NOT NULL in SQL-ish syntax (meaning, the object being returned has attribute 3 set, but I really don't care what its value is. SQL isn't very good at expressing this of course, as my data is key-value store where a key may be "not set" at all instead of being null valued).
I need to expand this API to be able to express IS NOT SET predicate, and I'm at a loss as to what a good way to do so would be.
The only thing I can possibly think of is to add a special "NOT_SET" value in the request API, that would produce NOT SET semantics; but it seems really klunky and hard to grasp:
The API syntax can be thought of as JSON as far as its expressiveness/capability
An ideal answer would reference some well accepted rules on API design, to show that it's "good".
{
filter: {
,attribute2: [val21, val22]
,attribute4: [__NOT_SET__]
}
}
My suggestion would be to move away from trying to use a key-value pair to represent a predicate phrase. You should have a lot more flexibility with a structure similar to:
{
filters: [
{ attribute: "attribute2", verb: "IN", values: [val21, val22] },
{ attribute: "attribute2", verb: "NOT IN", values: [val21, val22] },
{ attribute: "attribute4", verb: "IS NOT SET" },
]
}
You'd want an enum of verbs, of course, and values would have to be optional. You can add more verbs later if you need them, and you're no longer putting quite so much pressure on the poor :. You can also provide to the client a list of supported verbs and how many values (if any) of what type they take, so the client can build the UI dynamically, if desired.
Of course, this is a breaking change, which may or may not be an issue.

Alexa not recognizing some slot values dependent on the sample utterances

I created an Amazon Alexa skill that has one intent (MyIntent) and two custom slot types (SlotA and SlotB). The intent schema looks like that:
{
"intents": [
{
"intent": "Foo",
"slots": [
{
"name": "CustomA",
"type": "CUSTOM_A"
},
{
"name": "CustomB",
"type": "CUSTOM_B"
}
]
}
]
}
Each slot has a couple of values, like SlotA having
865985
710000
927291
514000
and SlotB having
Photo
Car
Bed
Kitchen
My sample utterances look like that:
MyIntent foo bar {SlotA}
MyIntent bar baz {SlotB}
MyIntent {SlotA}
MyIntent {SlotB}
The problem is, that Alexa doesn't recognize some of my slot values, like "bed", but does recognize others like "kitchen". This applies to both slot types.
The interesting thing is, that all values get recognized, if I keep only the simple sample utterances and remove the ones including phrases and my sample utterances look like that:
MyIntent {SlotA}
MyIntent {SlotB}
The order of the values or the sample utterances is irrelevant. I tried every combination. Also having two slots (combining all slot values in one) does not make any difference.
Why are the sample utterances with phrases blocking the recognition of some of the slot values?
EDIT:
By "doesn't recognize" I mean the user's input is not mapped to MyIntent. While being in a dialog (session) I just get a SessionEndedRequest.
Amazon had a bug in their system, preventing the language recognition from being build correctly. After the bug was removed, everything is fine again. Here is the email from the Amazon support:
We recently made new tools available to help with the creation and
testing of skills. The new features inadvertently impacted a small
number of skills. We fixed the issue yesterday and all live skills
should work as expected. Please post here if you have any more issues
and we will monitor and provide assistance. For skills in development,
you can now resolve this issue by clicking ‘Save’ on the interaction
model tab or by clicking Build Model in Skill Builder (beta). We
apologize for the inconvenience.

failed to keep user on the same prompt when they enter the wrong nunber?

we'd like to keep user on the same prompt when they enter the wrong number, we have tried anything_else, and "true", "jump to", but it messed up, please take a look at the attached to reproduce it, Thanks
pleae enter "how much"
if you enter 6, it will lock the prompt(I assign 1 to 5 to different identification), this behavior is correct .
then enter 2, we will get messed up...
please import this json to reproduce it, thanks
https://drive.google.com/file/d/0B1YdUMoS4l7ub1BZdUg1c1dQeG8/view?usp=sharing
The better form is use the entitie pre-defined by IBM, #sys-number to get numbers from the user input. And you can use use with conditions and to get the number with context variable too, check the JSON example:
{
"context": {
"number": "<? #sys-number ?>"
},
"output": {
"text": {
"values": [
"Now is $hora. Sector please?"
],
"selection_policy": "sequential"
}
}
}
If user type two or 2, the entitie recognize!
You can use regex expression to obtain only the numbers you have pre-defined too!
How to active: -> Entities -> System Entities -> sys-number = ON:
Obs.: Waiting Watson TRAINNING after you active this entitie.
Example, with sys-number add in your node condition:
#sys-number:1
Check the image:
If user type the number correct:
Check the dialog if user dont type the correct number with true condition:
I did the example for you understand what I do for that:
Download the JSON for verify how to do it with REGEX here.
Download the JSON for verify how to do it with SYS-NUMBER here.
EDIT:
Refer your questions
In this case you can use regex, and use the context variable for make conditions in other node. My workspace with regex can help you with numbers. And, the variable $number you can use in the next node to verify if the user typed correctly the number.
And, the other case is to use the Jump to inside conversation. And use true if the user dont type the number correctly again.
Check my image:
Download the new workspace here.
Study more about conditions here.

Watson Conversation: condition matching input to context array

Taking the car dashboard example, I altered the initial #genre node to be #genre:classical. I also added a list to the contex
"choices":["Beethoven","Mahler 9","Brahms 3rd"]
and the Watson response is "I have 3 selections". The condition on the next node is $choices.contains(input.text). The "Found a match" response is just for testing. It looks like this:
When I test this in the api tool and type "Beethoven" both "Found a match" and "Great choice!..." appear. Same for the other two choices, but only if I type the exact choice, e.g., "Mahler 9". Typing "Mahler" or "mahler" doesn't get a match. I read through the SpEL documentation but couldn't see a way in a one-line condition to parse through the list looking for partial matches.
So my question is, is there an condition expression that would match partial user input, e.g., "Mahler"? I'll be using the Java SDK to code the app server, so alternatively I wondered if I could add a temporary #entity just for this sequence instead of using the context list then delete it when the conversation is done? Or is there a way to construct a more complex condition in the MessageRequest and will Watson recognize it? Or is this just not the right way to go about this? Any pointers, examples or docs much appreciated.
So my question is, is there an condition expression that would match partial user input
You can't add temporary entities or intents. As adding them forces Watson to start training itself (even if you could it through code).
You can however create quite complex regular expressions, pass them in as a context variable.
For example your advanced node can have:
{
"output": {
"text": "Please ask me a question."
},
"context": {
"rx": "fish|[0-9]+"
}
}
Then in you condition you would write.
input.text.matches(context.rx)
This will then trigger if the person mentions a number, or the word fish. So you can create your partial user input checking that way.

Resources