我正在使用PylexaPython模块开发一个Alexa技能,该技能以美元表示比特币的价值进行响应,但每次我在Amazon的在线技能测试仪上调用它时,都会遇到以下错误:
There was an error calling the remote endpoint, which returned HTTP 400 : BAD REQUEST
在本地计算机上尝试时,我遇到以下错误:
^{pr2}$可能是什么问题?如果有帮助的话,代码部署在Heroku服务器上。如果有帮助的话,我的代码如下(我在另一项技能中使用了类似的代码,并且很有效):
import json
import os
import requests
from flask import Flask
from pylexa.app import alexa_blueprint
from pylexa.intent import handle_intent
from pylexa.app import handle_launch_request
from pylexa.response import PlainTextSpeech
app = Flask(__name__)
app.config['app_id'] = os.getenv('ALEXA_APP_ID')
app.register_blueprint(alexa_blueprint)
@handle_intent('GetBTC')
def handle_info_intent(request):
try:
print('Debug: ' + str(request.slots))
btcValue = requests.get('http://api.coindesk.com/v2/bpi/currentprice.json').json()['bpi']['USD']['rate']
print(btcValue)
return PlainTextSpeech("Currently, Bitcoin is worth " + btcValue + " dollars.")
except:
return PlainTextSpeech("I don't know.")
@handle_intent('A')
@handle_launch_request
def handle_start_message(request):
try:
print("New launch!")
btcValue = requests.get('http://api.coindesk.com/v2/bpi/currentprice.json').json()['bpi']['USD']['rate']
print(btcValue)
return PlainTextSpeech("Currently, Bitcoin is worth " + btcValue + " dollars.")
except:
return PlainTextSpeech("I don't know.")
if __name__ == '__main__':
app.run(debug=True)
意向架构:
{
"intents": [
{
"slots": [
{
"name": "BTC",
"type": "CURRENCY"
}
],
"intent": "GetBTC"
}
]
}
任何帮助都将不胜感激。在
所以问题不在于代码,而在于亚马逊的Alexa技能测试工具。在
The Issue
相关问题 更多 >
编程相关推荐