Custom Slot wildcard value? - wildcard

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.

Related

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.

Why use DELETE/POST instead of PUT for 'unfollowing/following' a user?

Referencing this API tutorial/explanation:
https://thinkster.io/tutorials/design-a-robust-json-api/getting-and-setting-user-data
The tutorial explains that to 'follow a user', you would use:
POST /api/profiles/:username/follow.
In order to 'unfollow a user', you would use:
DELETE /api/profiles/:username/follow.
The user Profile initially possesses the field "following": false.
I don't understand why the "following" field is being created/deleted (POST/DELETE) instead of updated from true to false. I feel as though I'm not grasping what's actually going on - are we not simply toggling the value of "following" between true and false?
Thanks!
I think that the database layer have to be implemented in a slightly more complex way than just having a boolean column for "following".
Given that you have three users, what would it mean that one of the users has "following": true? Is that user following something? That alone cannot mean that the user is following all other users, right?
The database layer probably consists of (at least) two different concepts: users and followings; users contain information about the user, and followings specify what users follow one another.
Say that we have two users:
[
{"username": "jake"},
{"username": "jane"}
]
And we want to say that Jane is following Jake, but not the other way around.
Then we need something to represent that concept. Let's call that a following:
{"follower": "jane", "followee": "jake"}
When the API talks about creating or deleting followings, this is probably what they imagine is getting created. That is why they use POST/DELETE instead of just PUT. They don't modify the user object, they create other objects that represent followings.
The reason they have a "following": true/false part in their JSON API response is because when you ask for information about a specific user, as one of the other users, you want to know if you as a user follows that specific user.
So, given the example above, when jane would ask for information about jake, at GET /api/profiles/jake, she would receive something like this:
{
"profile": {
"username": "jake",
"bio": "...",
"image": "...",
"following": true
}
}
However, when jake would ask for the profile information about jane, he would instead get this response:
{
"profile": {
"username": "jane",
"bio": "...",
"image": "...",
"following": false
}
}
So, the info they list as the API response is not what is actually stored in the database about this specific user, it also contains some information that is calculated based on who asked the question.
Using a microPUT would certainly be a reasonable alternative. I don't think anybody is going to be able to tell you why a random API tutorial made certain design decisions. It may be that they just needed a contrived example to use POST/DELETE.
Unless the author sees this question, I expect it's unanswerable. It's conceivable that they want to store meta information, such as the timestamp of the follow state change, but that would be unaffected by POST/DELETE vs. PUT.

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.

Publish Embedded Document Array to Meteor

I have meteor application made up of "notepads", each containing an array of "notes" which can be inserted into at any position, deleted from or have rows edited. This array is contained within an object with a variety of other information (ex. name, users, etc). Each object in my primary document will contain one of these arrays. For example:
{
"_id": "1234",
"name": "NotePad123",
"notes": [ {note: "this is my first test note"},
{note: "this is my second test note"},
{note: "this is my third test note"} ]
},{
"_id": "4321",
"name": "NotePad321",
"notes": [ {note: "noteA"},
{note: "noteB"},
{note: "noteC"} ]
}
Is there any way I can pass the "notes" as its own collection to my client so that the client can directly edit it as if it were not embedded? I am worried about a performance hit if I need to be passing the full notes array to the server every time I want to update it as there may be many updates it could become quite large.
I realize that I could create a new document and reference it, as described here, but this could become quite hectic with many "notepads" as ordering is important and I will have many rows associated with each of my primary objects.
You can make a client-side collection that you put the notes in. Then, call a method to make the changes once you want to save.
Here's how you make a client-side collection:
var notes = new Meteor.Collection(null)

freebase api getting a country code for a city

I'm trying to use freebase to return a cities related country ISO code.
I have this MQL which works but it doesn't work on certain cities and there's probably a more straight forward way to do the same thing?
{
"id": "/en/amarillo",
"/location/location/containedby": [
"/location/country/iso3166_1_alpha2": null,
"type": "/location/country"
]
}​
It doesn't work occasionally for smaller cities. Even better would be a way to use the Freebase suggest (which I use to gather the city) to return the ISO code in the same request?
jQuery ->
$("#city_name")
.suggest(type: "/location/citytown")
.bind "fb-select", (e, data) ->
$("#city_freebase_id").val data.id
That's basically how I'd do it, but, as you've discovered, the data isn't incredibly fully populated. One tweak that you could make to improve your odds of finding something would be to go up an additional level in case, for example, the city is contained by a state which is contained by a country. You're also missing a set of curly braces in your subquery which will probably cause your query to fail in the API (the query editor silently fixes up stuff like this).
A revised query that goes up an additional level and fixes the braces would look like this:
{
"id": "/en/avondale",
"/location/location/containedby": [{
"/location/country/iso3166_1_alpha2": null,
"type": "/location/country"
}],
"l2:/location/location/containedby": [{
"id":null,
"/location/location/containedby": [{
"/location/country/iso3166_1_alpha2": null,
"type": "/location/country"
}]
}]
}​
The search API has an mql_output parameter that could be used to do what you want, but I'm not sure it's used by Freebase Suggest. It's not documented to be available. If it's not in the code either, it wouldn't be too hard to hack the widget to add this.

Resources