I have a simple utterance with a slot, e.g.
Start {function}
This function is defined as a custom slot type which can take two values, a and b. So if the user types in c for example, I simply want to keep asking them to reenter the data. I have made the slot type as required in the console and I can successfully tell if the value is not one from the list. What I am having trouble with is, what do I show next...I have tried this:
return handlerInput.responseBuilder
.addDelegateDirective(currentIntent)
.getResponse();
And
return handlerInput.responseBuilder
.prompt('Wrong input')
.addElicitSlotDirective(SLOT_NAME)
.getResponse();
But both of the above keep hitting my error handler. Is there an example online for this? Or can anyone help me out?
From the documentation here, ask-core-docs it seems that the appropriate syntax for what you are trying to do is addElicitSlotDirective(slotToElicit: string, updatedIntent?: Intent), which might explain why your code execution keeps hitting the error handler, please try changing it and let me know if that fixes your problem
Related
I have been trying to make a quick bot for a friend, however I have come across something I cant fix. Whenever I try to access the member from the message it returns null. I am trying to find the users roles so I can check if they have a certain one.
The root of this problem that member is null inside the message. Therefor I cannot read from a null value.
client.on('message', message => {
This is how I am declaring message, and here is a console log of message. https://pastebin.com/vrdg9Wvu
So please can someone help me find a way to compare the command users roles.
Which version of dicord.js are you using?
I don't know where this may come from, maybe if the user who sent the message has left the guild while sending, otherwise I don't know what's wrong. If it's still not working, consider using message.guild.members.cache.get(message.author.id).then(user => {}), that may work.
First, I should clarify that I have the built-in Fallback intent set up properly and it triggers every time when I try to issue a rubbish command.
The problem occurs when I issue a command that is defined in a custom slot. For example, I have a custom slot type with the following slot values defined: apple, tomato, onion.
This slot type is added in a custom intent with the following utterances: Information about {food}, info about {food}.
So, in the intent utterances, I have not defined an utterance for the slot alone, i.e. just {food}.
Now, when Alexa is expecting a command, if I say just "apple", it gives an error tone and stops the skill without any error information. I realized that this happens when Alexa can't map the utterance to any intent, but I cannot figure out why it is not triggering the Fallback intent when this happens.
I opened the Utterance Profiler and tried the command there and all I get is that no intents have been triggered with that utterance. For other utterances, in this case if I use "orange" which is not defined in the slot types, it will map to the Fallback intent.
Does anyone have any ideas how I can solve this?
I have an Alexa skill that at one point asks for names, and at another point asks for numbers. The names are being mapped to a slot of type AMAZON.FirstName and the numbers to a slot of type AMAZON.NUMBER. The problem is that Alexa is aggressively interpreting even number values as names. (e.g. Saying "eight" is likely to be cast as the name "Tate.")
From what I can tell, Dialog Delegation is useful only if you know exactly how many of each type you need to capture. But in my case there are a variable number of times I will need to capture a name, so I can't just fill that slot once and be done with it.
Ideally I would like a way to programmatically turn the slots on and off. So when I prompt the user for a name, any utterance CAN ONLY BE MAPPED TO A NAME or else rejected (obviously HELP and EXIT, etc would still work). And then when I ask for a number, any utterance WILL ONLY BE MAPPED TO A NUMBER, it won't even try to cast it into the type AMAZON.FirstName.
Is there any way to achieve that? Or are there any other workarounds for scenarios like this?
I'd change the approach you're taking. You have a great tool for validation before even getting to code itself. Click the slot you're trying to validate, then click on the "validations" tab.
Right there, you can add either one or two rules. If you do one, you can add the "not within a set of values" and you can type "one", "two", etc. in order to avoid getting those numeric values inside your name slot.
If you take the two rule validation, you will need to add a "Value within slot types' slot values". That way, you will only accept values inside the AMAZON.FirstName slot type.
You don't really need to enable/disable a slot, you can simply take both in the same utterance. Just make sure you're validating your slots properly and that way you'll avoid unvalid data from getting into your skill :)
Read more: https://developer.amazon.com/es-mx/docs/custom-skills/validate-slot-values.html
I am developing an app and everything is working good. One condition are there where I have set the utterances but if user is speaking something else, I am throwing it to the fallbackIntent. One of my utterance is {name} so user can speak any name. But I have define range of name as well that user is allowed only these names. So my problem is if the user is choosing defined names, everything working great and if user said something else like what is weather of chicago, it is going to fallbackIntent as well but the issue is if user speak some name which is not in the list, then too it is coming into defined intent. What i want that if user speak something which is correct but not in my defined name then too redirect it to the fallbackIntent. Is there any way I can call intent in giving condition? I am using php.
When you define a custom slot, Alexa take it's values as samples. So values which are not in the slot-value-list will also be passed to you. And with respect your intent, those slot values are valid, hence that intent is triggered.
The solution is to validate the slot values at your backend and return an appropriate response.
In your case, if u get any other names other than those you have defined, respond back with an error or give FallbackIntent's response.
When you create a custom slot type, a key concept to understand is
that this is training data for Alexa’s NLP (natural language
processing). The values you provide are NOT a strict enum or array
that limit what the user can say. This has two implications
1) words and phrases not in your slot values will be passed to you,
2) your code needs to perform any validation you require if what’s
said is unknown.
Is it possible that Alexa reacts right when I have in a sample utterances something like this, opened slots?
MyNameIsIntent {firstname}
ProjektIntent {projekt}
Right now she always goes back to MyNameIsIntent even if she ask a question for a ProjektIntent
The bad conversation:
Alexa: Welcome, what is your name?
Me: Frank
Alexa Hi Frank, Tell me what project is interesting for you?
Me: Teleshoping
Alexa: Hi Teleshoping, Tell me what project is interesting for you?
Im totally new to Alexa, could you give me please a tip if it is possible that Alexa answers the right question? I tried to do it with a session atributes but it doesn't work
An utterance file like that won't work. Alexa uses the text of the utterance - the stuff aside from the slot name, of which you have none - to choose an intent.
So, unfortunately you can't design your interactions to allow for a response of just 'Teleshoping'. Instead, the user would have to say something like 'I'm interested in Teleshoping' (you would need to tell them to say it like that), and the sample utterance would be 'I'm interested in {projekt}'.
You can use States do react differently on the same intents depending on the state of your application.
See https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler for the official documentation.
You create a dictionary of StateHandlers like this (in Node.js 4.3):
var askNameStateHandlers = Alexa.CreateStateHandler("askNameState",
{
"MyIntent": function () { /* ... */ }
// more handlers ...
});
Then you register your handlers like this, assuming you have a dictionary of handlers without states defaultHandlers and two with handlers for a specific state askNameStateHandlers and askProjectStateHandlers:
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(defaultHandlers, askNameStateHandlers, askProjectStateHandlers);
alexa.execute();
};
To change the state of your application, simply assign it like this inside a handler function:
this.handler.state = "askNameState";
The alexa-sdk will then take care of calling the right handler depending on your application state.
There is also a full example implementation at https://github.com/alexa/skill-sample-nodejs-highlowgame
Note that this way, you will only have one intent MyIntent who accepts the answers to both questions, deciding which of your functions should handle the result based on the application state only.
And just to add a little further clarification to Tom's answer, Alexa can't tell if the word "teleshoping" is your first name or project.
If you use longer utterances as Tom mentions, such as "my name is {firstname}" and "I want to {projekt}" then Alexa will have no trouble discerning.
You can also help Alexa tell the difference by filling in the slot values, but this assumes that you know what the possible projekt values will be.
firstname can use the builtin AMAZON.US_FIRST_NAME slottype.