问题
I am new in Alexa development. I have successfully create an Alexa skill with AWS lambda function and Node.js code. This is my intent schema.
{
"intents": [
{
"slots": [
{
"name": "locationName",
"type": "LOCATION_LIST"
}
],
"intent": "locationIntent"
}
]
}
Also I have used custom slot type "LOCATION_LIST" with following values.
kitchen
bedroom
bathroom
dining area
It's working fine. But I need to add more location values dynamically from my own service. Is it possible?
Based on my system architecture, we cant pre-defined the location names. Then what should i do?
回答1:
Yes, it may be possible to accomplish what you are asking.
First, let's clear something up about how slots work. As described in this Alexa blog post:
"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."
What this means is that you CAN receive words in the slot that you did not specifically list in the SLOT definition. So you just need to provide enough word examples in the SLOT list to help the Alexa NLP engine.
I suggest that you experiment with your current implementation, and try substituting a different location and see if Alexa can recognize and return it. Try writing the slot value to the log and see. You may be pleasantly surprised.
回答2:
No, you cannot add slots dynamically. Maybe a very short answer but that's the fact.
Amazon doesn't have default slots as well to match your requirement. If it is other locations like the city then there are built-in slots available like 'AMAZON.City'. Here only possible way is to add as much as possible locations in your custom slot. You can have maximum 50,000 slot values in your custom slot (totaled across all custom slots used in the interaction model).
https://developer.amazon.com/docs/custom-skills/custom-interaction-model-reference.html#custom-slot-type-values
回答3:
While @Vijayanath was right at the time of writing, the answer now will be: YES, this is possible. It's a new feature that has been added just recently (around March 2019 it seems). You can learn about it in this Blog-Post. And find the developer documentation here. This sums it up pretty well:
The new dynamic entities capability helps you personalize Alexa skill experiences by adapting your interaction model at runtime without edits, builds, or re-certification. Now your skill can handle customer, context, and conversational changes by updating existing slot values from data structures in your code, a database, or a RESTful API call.
来源:https://stackoverflow.com/questions/46827106/how-to-add-slot-values-dynamically-to-alexa-skill