Amazon Alexa - One intent enable utterances - alexa-skills-kit

In Amazon Alexa is there a way to have one intent initialize a set of utterances?
I ask because I need to identify models of cars in addition to times and places. Adding slots for cars/places seems ridiculous as there would probably be 8000+ possibilities.
ex:
valetService.prototype.launch = fucntion(intent, session, response){
if(intent.slots['vehicleType'] === 'car'){
response.ask('Which vehicle?', *activate utterance*);
}
};
If this isnt possible, could I create a series of functions that handle each piece of information necessary and then change the target function for a single-word-intent each time?

You don't need to do what your question is aimed at. What you're trying to avoid --not defining a Custom Slot Type-- is actually the answer to your problem.
You can use a Custom Slot Type for what you want. I agree that it would be ridiculous to list all the possible options, but that's the catch: you don't have to!
All you have to do is to define a Custom Slot Type, perhaps add a few values, because I'm not sure you can get away without and you're done. Alexa WILL SEND the value for the slot to your skill, even if it is not in the list. In Amazon words:
Note that 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. Although input to a custom slot type is weighted towards the values in the list, it is not constrained to just the items on the list. Your code still needs to include validation and error checking when using slot values. See the “Handling Possible Input Errors” section of Handling Requests Sent by Alexa.
You can find all about it here.

Related

alexa sdk custom logic to determine if slot is required

i have an intent with two slots: 1 custom slot called "name" and one called "number" of type AMAZON.NUMBER.
Now for some names the number is required and for others it isn't.
How can i make alexa ask for the number if one of those names is given without a number?
Can i use the CanFulFillIntentRequest for that?
If so, all the sites about it say that i have to enable it under interfaces, but i can't find it there. Has it been removed?
btw, i'm using alexa sdk v2 for node.js in my lambda function
If you CanFulFillIntentRequest for both slots the intent will hit lamdba only if 2 slots are filled.You can make CanFulFillIntentRequest for necessary one (name) and in the backend(lambda) you can check for number.If name that requires number is required give necessary response for number.
One way to do this that can be updated without having to change the code is:
Create a JSON with the names that are required to have a number and store it in S3.
Make your Lambda function to retrieve it.
Make your Lambda function check the value of the Name Slot is among those in the JSON or not.
If so, then take control of the Dialog then. I strongly suggest you to check this
If not, then just continue.
Seems a bit complex mostly because of taking control of the dialog yourself. The other option is making the number required and let Alexa do the Dialog Management the thing is what to do when the number is not required.
If you know which names are required to have a number I would use a different slot for those and make the number required and let Alexa do the dialog management, the downside of this solution is that you will need to update manually those names (or use Bulk operations).
I think any of those 2 solutions can workout.
I hope you find this useful.

Watson Conversation supports nested Intents?

Does anyone have a good example of nested Intents especially where #yes and #no are child nodes. The situation i am getting is that the API is returning with Intent value but the output text from "Anything else"!
There is an undocumented feature that if the confidence is <0.2 then it will automatically jump to the Anything Else node.
So to get it to go to the right intent node, you will need to train the intents a bit better.
Alternatively for dealing with multiple intents you can access the intents array using the intents object.
Example:
intents[0].matches('yes|no')
OR
intents[1].matches('yes|no')
From a coding point of view you can set the flag alternate_intents and then review the returned intents array.

How to use QSettings?

If you have a lot of small classes (that are often created and destroyed), and they all depend on the settings, how would you do that?
It would be nice not to have to connect each one to some kind of "settings changed" signal, and even if I did, all the settings will be updated, even those objects whose settings didn't change.
When faced with that myself, I've found it's better to control the save/load settings from a central place. Do you really need to save/load the settings on a regular basis or can you have a master object (likely with a list of the sub-objects) control when savings actually need to be done? Or, worst case, as the objects are created and destroyed have them update an in-memory setting map in the parent collection and save when it thinks it should be saved, rather than child object destruction.
One way of implementing it is given below.
If you wish, the central location for the settings can be a singleton derived from QAbstractItemModel, and you can easily connect the dataChanged(...) signal to various objects as necessary, to receive notifications about changed settings. Those objects can decide whether an applicable setting was changed. By judicious use of helper and shim classes, you can make it very easy to connect your "small classes" with notifications. This would address two issues inherent in the model driven approach to settings.
The possibly large number of subscribers, all receiving notifications about the settings they usually don't care about (the filtering issue).
The extra code needed to connect the subscriber with the item model, and the duplication of information as to what indices of the model are relevant (the selection issue).
Both filtering and selection can be dealt with by a shim class that receives all of the dataChanged notifications, and for each useful index maintains a list of subscribers. Only the slots of the "interested" objects would then be invoked. This class would maintain the list of subscriber-slot pairs on its own, without offering any signals for others to connect to. It'd use invokeMethod or a similar mechanism to invoke the slots.
The selection issue can be dealt with by observing that the subscriber classes will, upon initialization, query the model for initial values of all of the settings that affect their operation - that they are "interested" in. All you need is a temporary proxy model that you create for the duration of the initialization of the subscriber. The proxy model takes the QObject* instance of the caller, and records all of the model indices that were queried (passing them onto the singleton settings model). When the proxy model is finally destroyed at the return from the initialization of the subscriber class, it feeds the information about the model indices for this QObject to the singleton. A single additional call is needed to let the singleton know about the slot to call, but that's just like calling connect().
What I typically do is to create a class handling all my settings, with one instance per thread. To make it quicker to write this class, I implemented a couple of macros that let me define it like this:
L_DECLARE_SETTINGS(LSettingsTest, new QSettings("settings.ini", QSettings::IniFormat))
L_DEFINE_VALUE(QString, string1, QString("string1"))
L_DEFINE_VALUE(QSize, size, QSize(100, 100))
L_DEFINE_VALUE(double, temperature, -1)
L_DEFINE_VALUE(QByteArray, image, QByteArray())
L_END_CLASS
This class can be instantiated once per thread and then used without writing anything to the file. A particular instance of this class, returned from LSettingsTest::notifier(), emits signals when each property changes. If exposed to QML, each property work as regular Qt property and can be assigned, read and used in bindings.
I wrote more info here. This is the GitHub repo where I placed the macros.

RESTful collections & controlling member details

I have come across this issue a few times now, and each time I make a fruitless search to come up with a satisfying answer.
We have a collection resource which returns a representation of the member URIs, as well as a Link header field with the same URIs (and a custom relation type). Often we find that we need specific data from each member in the collection.
At one extreme, we can have the collection return nothing but the member URIs; the client must then query each URI in turn to determine the required data from each member.
At the other extreme, we return all of the details we might want on the collection. Neither of these is perfect; the first can result in a large number of API calls, and the second may return a lot of potentially unneeded information.
Of the two extremes I favour the second in our case, since we rarely use this for more than one sutiation. However, for a more general approach, I wondered if anyone had a nice way of dynamically specifying which details should be included for each member of the collection? I guess a query string parameter would be most appropriate, but I don't want to break the self-descriptiveness of the resource.
I prefer your first option..
At one extreme, we can have the
collection return nothing but the
member URIs; the client must then
query each URI in turn to determine
the required data from each member.
If you are wanting to reduce the number of HTTP calls over the wire, for example calling a service from a handset app (iOS/Android). You can include an additional header to include the child resources:
X-Aggregate-Resources-Depth: 2
Your server side code will have to aggregate the resources to the desired depth.
Sounds like you're trying to reinvent PROPFIND (RFC 4918, Section 9.1).
I regularly contain a subset of elements in each item within a collection resource. How you define the different subsets is really up to you. Whether you do,
/mycollectionwithjustlinks
/mycollectionwithsubsetA
/mycollectionwithsubsetB
or you use query strings
/mycollection?itemfields=foo,bar,baz
either way they are all different resources. I'm not sure why you believe this is affecting the self-descriptive constraint.

howto avoid massive notification in DataBinding

I guess it's quite a common problem in databinding scenarios.
What do you usually do, if you are running a batch update and want to avoid that a propertychanged-dependend calculations/actions/whatever are executed for every single update?
The first thing which usually comes to my mind, is to either introduces a new boolean or unhook/hook the eventhandler, ...
What I don't like about this approaches is:
they introduce new complexity (has to be maintained, ...)
they are error prone, because you have to make sure that a suppressed notifications are sent afterwards
I'm wondering if somebody addressed this problem already in a more convenient way that is more easy to handle?
tia
Martin
Edit: not to missunderstand me. I know about the things .NET provides like RaiseListChangedEvents from BindingList, ... They are all addressing the problem in more/less the same way as I described, but I'm searching for a different way which doesn't have to listed drawbacks.
Maybe I'm on the wrong track, but I though I give it a try here...
There isn't a single one-size-fits-all solution, unfortunately. I've applied or seen the following solutions:
There are two singals. One signal is emitted when the change comes from a user action, the other always fires. This allows to distinguish between changes in the UI and updates by code.
A boolean to protect code
The property event framework stops propagating events automatically when a value didn't really change.
A freeze/thaw method on the signal or the signal manager (i.e. the whole framework)
A way to merge signals into a single one. You can do N updates and they get collected into M signals where M <= N. If you change the same property 100 times, you still only get 1 signal.
Queuing of signals (instead of synchronous execution). The queuing code can then merge signals, too. I've used this with great success in an application that doesn't have a "Save" button. All changes are saved to the database as you make them. When you change a text, the changes are merged over a certain time (namely until the previous DB update returns) and then, they are committed as a single change.
An API to set several values at once; only a single signal is emitted.
The signal framework can send signals at different levels of granularity. Say you have a person with a name. When you change the name, you get two signals: One for the name change and one "instance field changed". So if you only care "has something changed", then you can hook into the instance instead of all the fields.
What platform? The post makes me think .NET.
What is the underlying objects? For example, BindingList<T> as a source allows you to disable notifications by setting RaiseListChangedEvents to false while doing the update.
Other than that (or similar); yes, disconnect the binding during big updates
The easiest route to take is to use the BindingSource component for your data binding. Instead of binding your controls to a particular object (or IList), use that object as the DataSource for the BindingSource, then bind the controls to the BindingSource.
The BindingSource class has SuspendBinding() and ResumeBinding() functions.

Resources