question

Chris Means avatar image
Chris Means asked

Slot for street intersections

I've developed a simple Alexa Skill for the CTABusTracker API (Chicago Transit Authority). Works with route #, direction and stop #. Now, I'd like to try and handle the stop intersections. They're listed as "street name" & "street name". Should I have a slot for just StreetNames and use "{StreetName} and {StreetName}" as part of the intent, or can I use {Intersection} and be able to match on both names? I will have to handle the case that a user might not say the names in the right order (so I'll have to handle both), which will be easier if I use distinct slots rather than a single one. Any suggestions or insights? Another question: Can I have intents with the same basic structure with one looking for a Stop # and the other for the Intersection? Message was edited by: Chris Means
alexa skills kitvoice-user interface
10 |5000

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
>Should I have a slot for just StreetNames and use "{StreetName} and {StreetName}" as part of the intent, >or can I use {Intersection} and be able to match on both names? If you use two slots, you need one custom slot with all of your street names in it. If you use one slot, you will need one custom slot with all possible combinations of street names in it. The first require N data points, and the second N^2 data points. I think you are far better off using two slots. Also, if Alexa manages to understand one, but not the other, you can ask the user again for just the second. With a single slot, the user has to get the entire thing right first time. Be aware: just because you define a custom slot for it does not mean that Alexa will ONLY return you things you defined. The more values you have, the more generic Alexa makes the matching. With a larger number of values, you are quite likely to get things returned off your list. So you are going to have to take than into account and perform validation on what you get back, and probably some sort of fuzzy matching. (Search the forum for DoubleMetaphone to get a few ideas.) >Can I have intents with the same basic structure with one looking for a Stop # and the other for the Intersection? Can you give examples? I'm not sure what you mean. They sound completely different to me.
10 |5000

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

Chris Means avatar image
Chris Means answered
Thanks! Regarding the second question: My intents would look like this: GetBusArrivalIntent When the {Route} {Direction} stops at {Stop} GetBusArrivalIntent When the {Route} {Direction} stops at {StreetName} and {StreetName} {Route} and {Stop} are numbers. It certainly looks different, but as a newbie, I wasn't sure if this was going to be problematic or not.
10 |5000

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
> GetBusArrivalIntent When the {Route} {Direction} stops at {Stop} > GetBusArrivalIntent When the {Route} {Direction} stops at {StreetName} and {StreetName} You have to remember that Alexa doesn't always catch what someone says correctly. The more complex your intent, the more chances Alexa will get it wrong. By mapping both of these to the same intent, you won't be able to tell which one was called if there is partial information. So you won't be able to reprompt for a subset of the input. I think you would be better off with: BusArrivalAtStopIntent When the {Route} {Direction} stops at {Stop} BusArrivalAtIntersectionIntent When the {Route} {Direction} stops at {StreetName} and {StreetName} And, so you can reprompt for incomplete information: BusRoute Route {route} BusDirection Direction {direction} BusDirection to {direction} BusDirection go {direction} BusStop Stop {stop} BusIntersection at {StreetName} and {StreetName} BusStreet at {StreetName} So what you'll need to do is let them ask, either after opening your skill or from invocation. Gather and resolve what information you can. Work out what you don't have, and prompt the user for that information. Persist the rest in either session variables or, preferably off-line storage, since Alexa will probably drop the line a lot. As you get intent, fill in the information received. When you get it all, give them the answer. If you don't, just keep asking for what you are missing. I hope you are just a newbie to Alexa, and aren't a newbie coder!
10 |5000

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

Chris Means avatar image
Chris Means answered
Thanks, I'll try following your advice. I've been paid to be a programmer (in one way or another) since the mid 80's...so not a newbie...though that's hardly an indication of whether I'm actually any good :)
10 |5000

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