【问题标题】:"There was a problem with the requested skill's response" In Alexa Developer Console“请求的技能响应有问题”在 Alexa 开发者控制台中
【发布时间】:2019-01-12 04:08:35
【问题描述】:

情况: 因此,我在 youtube 上关注了 sentdex 的 3 个视频简短教程,名为“Alexa Skills w/ Python and Flask-Ask”第 1、2 和 3 部分。基本上,当我运行此技能时,alexa 会读给我来自 reddit.com 的前 10 个标题/r/worldnews(不幸的是,这篇文章的 URL 不能超过 8 个)。

我遇到的错误: 我遵循了所有步骤,但当我在 Amazon Alexa 开发网站上对其进行测试时,我不断收到此错误消息:“请求的技能响应存在问题”。我遇到的一个问题是,alexa 开发控制台几个月前已经更新并且完全不同,所以我不知道我是否做错了什么。我看过的所有 youtube 视频都是旧版本,它有不同的做事方式。我将准确概述我所做的事情,希望你们能指出我做错了什么。

我尝试了什么: 我还想提一下,我已经尝试用返回命令替换 get_headlines 函数的内容,该命令返回一个字符串让 Alexa 说:“它有效”。但是我在开发站点上收到了相同的错误消息。所以我猜我的代码很好,但我可能在我的 Alexa 开发帐户中配置了错误的设置。下面,我附上了我为这个简单程序所做的每一步的图片。

我已采取的确切步骤:

1) 我已经使用 pip 安装程序安装了 flask、flask-ask 和 unidecode

2) 我下载了 ngrok 来托管我的网站

3) 代码: 这是我运行的代码(出于显而易见的原因取出了我的 reddit 用户名和密码)。它没有错误,主页运行良好。所以我想代码本身没有问题。

from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
import json     
import requests 
import time
import unidecode 

app = Flask(__name__) 
ask = Ask(app, "/big_reader") 

def get_headlines(): # DESCRIPTION: get_headlines function will grab the headlines from redit and then its going "stringify" all the headlines together
    # 1) LOG INTO REDDIT API
    user_pass_dict = {
        'user': 'ENTER_YOUR_REDDIT_USERNAME',#'ENTER_YOUR_USERNAME',
        'passwd': 'YOUR_REDDIT_PASSWORD',
        'api_type': 'json'
    }
    # Requesting a session from api
    sess = requests.Session()
    sess.headers.update( {'User-Agent': 'I am testing Alexa Here'} ) 
    sess.post('https://www.reddit.com/api/login', data=user_pass_dict) 
    time.sleep(1) 

    url = 'https://reddit.com/r/worldnews/.json?limit=10' 
    html = sess.get(url)
    data = json.loads(html.content.decode('utf-8'))
    titles = [] 
    for listing in data['data']['children']:
        titles.append( unidecode.unidecode(listing['data']['title']) ) 
    titles = '...'.join([i for i in titles]) 
    return titles

################################# ALEXA STUFF ###################################################################################################
@app.route('/') 
def homepage():
    return "This is the Homepage"
# A) ALEXA ASKS SOMETHING: 
@ask.launch 
def start_skill():
    welcome_message = 'Sup, You want some news?'
    return question(welcome_message)    

# B) MY RESPONSE: 
@ask.intent("YesIntent")
def share_headlines():
    headlines = get_headlines() 
    headline_msg = 'The current world news headlines are {}'.format(headlines) #string format the headlines?
    return statement(headline_msg)
@ask.intent("NoIntent")
def no_intent():
    bye_text = 'bye'
    return statement(bye_text)

# RUN
if __name__ == '__main__':
    app.run(debug=True)

4) 我如何设置我的 ALEXA 技能的图片:这里有 10 张图片准确地显示了我的 alexa 开发者网页的样子

https://ibb.co/ZdMdgGF

https://ibb.co/4N4JygL

https://ibb.co/c2HDw8h

https://ibb.co/BP6ck2L

https://ibb.co/3k5J7wZ

https://imgur.com/H6QGWOo

https://ibb.co/3s3tVQH

https://ibb.co/wgF7GQ4

【问题讨论】:

标签: python-3.x alexa alexa-skills-kit alexa-skill flask-ask


【解决方案1】:

我遇到了同样的问题。

我通过使用pip install cryptography==2.1.4 将密码学降级到 2.1.4 来修复它

【讨论】:

    【解决方案2】:

    我在 Raspberry Pi 上托管自己的技能后端,使用 ngrok 在 Amazon 和 localhost 之间创建隧道。对我来说,当我创建并登录我的 ngrok 帐户,将 ./ngrok authtoken 剪切并粘贴到 Linux 命令行中,然后运行命令来创建授权令牌 yaml 文件时,这个问题就消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 2019-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多