OneBusAway / onebusaway-alexa

An Java-based app to communicate with Amazon Alexa for devices such as the Amazon Echo
Other
52 stars 18 forks source link

Stop numbers with "0" prefix can't be discovered #62

Closed barbeau closed 8 years ago

barbeau commented 8 years ago

Summary:

Users cannot set their stop to any stops that have a stop_code that begins with "0".

Steps to reproduce:

Set city to "Rogue Valley", and set stop to "040490".

Expected behavior:

The skill should find the stop and set the stop as my stop.

Observed behavior:

The skill says "OneBusAway could not locate your stop number. Tell me again, what is your stop number?"

It looks like Alexa is interpreting the number correctly, as this is what gets set to Lambda:

  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.d860f76a-1ef2-4464-a6b0-a47ec6f313e7",
    "timestamp": "2016-04-21T00:24:40Z",
    "intent": {
      "name": "SetStopNumberIntent",
      "slots": {
        "stopNumber": {
          "name": "stopNumber",
          "value": "040490"
        }
      }
    },

But this is the HTTP request sent to the OBA server: http://oba.rvtd.org:8080/onebusaway-api-webapp/api/where/stops-for-location.json?lat=42.4401246&lon=-122.9261546&query=40490&radius=40000&version=2&key=e5c0e97a-729d-4fdb-a3ca-2fccb20ac3ab

...which returns no results. It looks like the leading 0 is getting trimmed off the query=40490.

If you change the request to add the leading 0 back: http://oba.rvtd.org:8080/onebusaway-api-webapp/api/where/stops-for-location.json?lat=42.4401246&lon=-122.9261546&query=040490&radius=40000&version=2&key=e5c0e97a-729d-4fdb-a3ca-2fccb20ac3ab

...it correctly returns the stop.

Device:

Amazon Echo

barbeau commented 8 years ago

Looks like we're converting the string from Alexa to an integer and then back to a String. We should be able to fix this by just leaving it a String. I'm working on a fix now...