I'd like Alexa to be able to accept a variable-length list of English letters to my custom skill. It will allow users to search based on a string.
There's two steps to this:
- Getting good representation for individual letters that Alexa can understand
- Enumerating sample utterances with variable number of letters
For the first, one way would be to define a custom slot that has as its enumerated values of the English alphabet:
SLOT_LETTER
ay
bee
see
dee
ee
eff
gee
... etc
but that feels hacky. Does Amazon support any way to do this or is there a cleverer way?
I'd really rather not use NATO phonetic ("alpha bravo charlie" for "A-B-C") because it's a terrible user experience and very few people actually know them.
For the second issue (sample utterances), for AMAZON.LITERAL
I want to define something like:
SpellIntent find me things starting with {first second|SLOT_LETTER}
SpellIntent find me things starting with {first second third|SLOT_LETTER}
SpellIntent find me things starting with {first second third fourth|SLOT_LETTER}
But I don't think Amazon will let you define a variable length LITERAL using a custom slot (since they are different "types")?
It isn't very well documented, but you can use "a.", "b.", "c." etc to represent the letter, as opposed to the sound. Create a custom slot and use these as the values. That should do you for the slot.
For the intent, create an intent with, say, five slots, all with the same slot type. Create five utterances against the intent, with one, two, three, four and five slots filled. When the user spells something, the intent will be invoked. Any slots the user did not specify will be null.
Having two slots in one intent not separated by a word often does not perform well. But try it and see. With a restricted vocabulary like this, it could do OK.
Lastly, if it has trouble distinguishing, say, "b." and "v.", you might try adding NATO call codes to your list. Alpha, Bravo, Charlie, etc. Then, in your processing, just take the first character of whatever value comes in for the slot.
You might enable the "Star Lanes" skill and experiment with the "Set Call Sign to X Y Z" intent. I do the above in that skill and it works fairly well.
I would avoid this kind of interface because it can be difficult for users to spell things, and difficult for Alexa to differentiate letters (b or v, perhaps). But if you want to try this, consider using the literal type and asking for letters in groups of three or four.
AV: "Spell the first four letters now"
User: "see ay are tee"
AV: "You spelled C, H, R, T. Would you like to add more letters, make a correction or search now?"
User: "Cancel. I'll just use my damn phone."
来源:https://stackoverflow.com/questions/39397892/alexa-skill-user-input-for-spelling-out-letters