Alexa навык с запросом Python API - PullRequest
0 голосов
/ 18 января 2019

Предполагается, что мой навык alexa берет данные от пользователя, а затем ищет код маршрута и вводит его в URL-адрес запроса API.В локальном тестировании это работает, но теперь по какой-то причине мой код при тестировании с alexa не вводит код_правы. Я не уверен, что может отсутствовать или где он испортился, потому что он действительно успешно совпадает, когда я смотрю на JSON.В настоящее время он просто выводит repromt_text, а не сообщение, которое должно быть из запроса API

Ниже показано, где он работает не так, как ожидалось.Полный код здесь https://github.com/meyrickj/Alexa-skill-Philly-Tranist/blob/master/lambda_function.py

def get_status(intent):
session_attributes = {}
card_title = "Septa Status"
speech_output = "I'm not sure which route you wanted the status for. " \
                "Please try again. Try asking about the Market Frankford line or a bus route, such as Route 66."
reprompt_text = "I'm not sure which route you wanted the status for. " \
                "Try asking about the Market Frankford line or a bus route, such as Route 66."
should_end_session = False

if "Route" in intent["slots"]:
    route_name = intent["slots"]["Route"]["value"]

    route_code = get_route_code(route_name.lower())

    if (route_code != "unkn"):

        response = urllib2.urlopen(API_BASE_URL + "/Alerts/get_alert_data.php?req1=" + route_code)
        route_status = json.load(response)  

        if len(route_status[0]["current_message"]) > 0:
            speech_output = "The current status of" + route_status[0]["route_name"] + route_status[0]["current_message"] 
        else:
            speech_output = "The " + route_status[0]["route_name"] + " is running normally."   

        reprompt_text = ""

return build_response(session_attributes, build_speechlet_response(
   card_title, speech_output, reprompt_text, should_end_session))
...