question

TL avatar image
TL asked

How would you design slots for letter and number codes?

I would like my skill to catch a mention of a 4 to 5 character code that can contain letters and numbers like AB05 or ABC12. How can I design the slots and utterances for Alexa to understand these and pass them to my skill?

alexa skills kitvoice-user interface
1 comment
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I had so much trouble with this, when trying to get slots for "ec2" and "s3" - i gave up and went to "compute" and "storage"

0 Likes 0 ·
Galactoise avatar image
Galactoise answered
I actually did this exact thing in a random skill I was playing around with for personal use. It's pretty easy to just declare a custom slot type that takes the exact range of values you want. I do seem to recall either a comment by an Amazon employee, or a piece of certification feedback someone pasted here, that said that if you're describing individual characters as a potential slot value you should always follow them with a period, which is the shorthand for "single char" that Alexa uses (and whether you define them that way or not in your slot, you will see the values come in with a period appended).
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Yes, "A." means the letter a. So, you can [i]do[/i] it, but it will work like crap. One of my first skills was a UPS package tracker. Needed 18 alpha-numeric digits. So I, dutifully, wrote an intent with 18 slots. First off, trying to say 18 digits before Alexa times out was nearly impossible. Then, the chance of Alexa hearing all 18 correctly was virtually nil. The next iteration let the user say three values at a time. Confirmed those three values, and moved on to the next three values. That was demoable. But not really workable enough to really go to market. Ultimately, Alexa is extremely poor at hearing multiple slots in a single intent. Especially if there is no "dead text" between the digits. I.e. [number] [number] [number] works badly. But [number] foo [number] bar [number] works better. Even with that, I wouldn't really consider more than two slots per intent. So, for best accuracy, you are going to want something where they enter one number at a time. This is hard to design to be easy to use. So it is tempting to design something grouping them together. But then you are going to need confirmations and editing since the accuracy will be lower.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Galactoise avatar image
Galactoise answered
Really? I had that trouble with literal slots, but once the custom slot types were added it worked pretty well. Mine was a 14 character string (so, 14 custom character slots in one intent), but I don't recall timeouts ever being a problem. It did have a couple really strange issues that I meant to blog about, though - like there was a certain pattern of characters that would always come in with an extra character appended to it, no matter how clearly it was spoken.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Levon@Amazon avatar image
Levon@Amazon answered
You can create an intent that accepts multiple custom slots in a row, with each custom slot accepting a letter or number. Until there's a better custom slots that can accept alphanumeric codes, this is the best supported way currently. Thanks!
1 comment
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

can you link to an example of this?

0 Likes 0 ·
jjaquinta avatar image
jjaquinta answered
Levon: have you ever tried this? There is a big difference between what is possible and what will work well. Sure, the SDK supports it. But, as I said, trying to have two slots together without some static text between them is problematic. I had to add significant extra logic to Starlanes because some frequent commands were in this format. ("pickup [#] [dronetype]", "drop [#] [dronetype]") Even though each was a Amazon provided NUMERIC, and the other a custom slot type, it still frequently has issues and drops one or the other.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Galactoise avatar image
Galactoise answered
> Even though > each was a Amazon provided NUMERIC, and the other a > custom slot type, it still frequently has issues and > drops one or the other. I think the difference in slot types here might be important when considering back-to-back slots. I've had a very good experience with back-to-back combinations of a single slot type (in my case, a single alphanumeric code), which I think aligns more closely to what he's doing. Now, admittedly I don't even have a theory as to [i]why[/i] the behaviors we've seen would be different - it seems like yours should've worked at least as well as mine, if not better. But I just wanted to provide a counterpoint for the OP - and for Levon if he ends up investigating - based on the success I've had with that approach.
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Brent Hunter avatar image
Brent Hunter answered

Does anyone have an example of the "Intent Schema" for "AB5 or ABC12"?

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

randal avatar image
randal answered

For a reason I can't explain, Alexa sometimes adds a dot (.) after a spoken letter. So the string that is built from multiple slots has to be stripped of dots before it is used. The following Python code strips the dots from a string called item_number. After that, the program was able to use the item_number string without failures.

#Sometimes Alexa adds a dot after a spoken letter.

item_number = item_number.replace('.','')

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

pdyck avatar image
pdyck answered

Is there a better way to do this by now?

I can't define an alphanumeric slot type because German number literals ( eins, zwei drei, vier, ... ) are not translated to digits automatically ( only when using the AMAZON.NUMBER slot type ). I tried using 12 slots ( 6 number slots, 6 letter slots ) for a 6 digit code but it doesn't work well at all. In total I had to add 64 sample utterances to model every combination of letters and numbers and it doesn't even work correctly.

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

newuser-35220db2-d8a5-4b59-8679-3cf90c8b4baf avatar image
newuser-35220db2-d8a5-4b59-8679-3cf90c8b4baf answered

I've had some luck by using the AMAZON.Book slot type and alphanumerics. However, I would love to see an alphanumeric slot type built in since Amazon wants to move into businesses. I have a feeling it works better in English only.

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.