问题
I'm writing an Alexa skill that captures a ticket number from one intent and captures age from different intent. and Basically, these two are of type number.
When I'm trying to enter a number, it is being captured in the first Intent's slot. Here is my intent schema.
{
"intents": [
{
"slots": [
{
"name": "TicketNumber",
"type": "AMAZON.NUMBER"
}
],
"intent": "CheckStatusIntent"
},
{
"slots": [
{
"name": "ageAndCurrency",
"type": "AMAZON.NUMBER"
}
],
"intent": "ClientSuggestIntent"
}
]
}
and my sample utterances are
CheckStatusIntent I want to check on the status of a ticket
CheckStatusIntent {TicketNumber}
ClientSuggestIntent I have a client meeting tomorrow.
ClientSuggestIntent {ageAndCurrency}
ClientSuggestIntent {personName}
In my ClientSuggestIntent
, the flow should be as below.
User: I have a client meeting tomorrow. Alexa: What is the Client's name. User: Sara John Alexa: What is Sara John's age User: 65
Here when I give 65
, instead of matching with in the ClientSuggestIntent
, it is matching with the TicketNumber
of CheckStatusIntent
.
This is very confusing, please let me know where am I going wrong and how can I fix this.
Thanks
回答1:
You need to use "state handlers" do do this. Here is a video I did that explains how to do it. https://youtu.be/ukR0Aw5P3W8.
If you're using the ask-sdk for node you'd use Alexa.CreateStateHandler(...)
to create one state handler with your CheckStatusIntent function in it and another state handler with your ClientSuggestIntent function.
Also read https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs#making-skill-state-management-simpler
回答2:
To elaborate a bit on Steve's answer above, the problem is that Alexa cannot tell the difference between "CheckStatusIntent {TicketNumber}" and "ClientSuggestIntent {ageAndCurrency}" since both are just a number.
You need to either give Alexa a way to differentiate between each of your intents. For example, "ticket {TicketNumber}" and "my age is {age}".
Or alternatively, you can setup a context as described by Steve, and use a single intent to handle either/any number-only input.
I hope this helps clarify things. I know its complicated when your just getting started. I found it easiest to keep things very simple using multiple, unique intents.
来源:https://stackoverflow.com/questions/46878839/multiple-intents-sharing-the-same-slot-value