一个用于构建alexa技能的python包。

skillful的Python项目详细描述


|PyPIVersion||BuildStatus||Coverage|

一个用于构建amazon-alexa技能的python包。

功能

  • custom skills
  • 的请求和响应对象
  • 每个请求类型的响应逻辑的简单定义
  • 内置的请求解析/验证、意图分派和响应 结构

安装

pip install skillful

示例

import skillful
from skillful.tests import data

application_id = 'amzn1.echo-sdk-ams.app.000000-d0ed-0000-ad00-000000d00ebe'
skill = skillful.Skill(application_id)

@skill.launch
def on_launch():
    print('Launched: {}'.format(skill.request.session.session_id))
    text = 'Welcome to skillful. Would you like to build an Alexa skill?'
    skill.response.set_speech_text(text)
    ssml = ('<speak>Please tell me if you would like to build an Alexa '
            'skill.</speak>')
    skill.response.set_reprompt_ssml(ssml)

@skill.intent('yes')
def on_intent_yes():
    text = ('Great! Building Alexa skills is easy with skillful. Open '
            'the Alexa app to see more information on skillful, a '
            'Python package for building Alexa skills.')
    skill.response.set_speech_text(text)
    title = 'skillful'
    content = ('A Python package for building Alexa skills.\n\n'
               'Visit: https://github.com/bmweiner/skillful')
    skill.response.set_card_simple(title, content)
    skill.terminate()

@skill.intent('no')
def on_intent_no():
    text = ('Well, if you change your mind, open the Alexa app to see '
            'more information on skillful, a Python package for '
            'building Alexa skills.')
    skill.response.set_speech_text(text)
    title = 'skillful'
    content = ('A Python package for building Alexa skills.\n\n'
               'Visit: https://github.com/bmweiner/skillful')
    skill.response.set_card_simple(title, content)
    skill.terminate()

@skill.session_ended
def on_session_ended():
    print('Ended: {}'.format(skill.request.session.session_id))
    skill.terminate()

# simulate request body
body = data.SAMPLE_LAUNCH_REQUEST
skill.process(body)

输出:

Launched: amzn1.echo-api.session.0000000-0000-0000-0000-00000000000

{
  "version": "1.0",
  "response": {
    "outputSpeech": {
      "text": "Welcome to skillful. Would you like to build an Alexa skill?",
      "type": "PlainText"
    },
    "shouldEndSession": false,
    "reprompt": {
      "outputSpeech": {
        "ssml": "<speak>Please tell me if you would like to build an Alexa skill.</speak>",
        "type": "SSML"
      }
    }
  }
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java游戏!框架伪造应用程序它实际上做什么?   java如何在JavaFx中显示表视图中的即时更改?   对象类的equals()方法的java重载   xpages介绍如何部署java。IBM Notes中的策略更改   java如何访问侦听器中的另一个视图?   java getDefaultDisplay()的替代方法是什么   java opencv匹配模板   java Android Firebase写入数据时的常量超时   在Java中,如何将包含大量空格的数字字符串转换为一系列Int变量。   带有GUI的swing Java模拟无法运行模拟   java NoSuchElementException在特定的Web端上使用无头铬和硒   java对文件进行迭代,即使文件在目录中也会出现“未找到文件”异常。你能告诉我为什么吗?谢谢   递归Java 8,匿名递归嵌套方法   java为什么我看到枚举常量的字段值会被序列化/反序列化?在哪种情况下,枚举中哪些内容没有序列化?   java在运行sonar scanner和Spotbugs规则时出错,用于单片项目?   java如何检查硬件键盘是否可用?(黑莓)   tile游戏动作侦听器循环中的java错误   sockets Java线程池与高请求场景中的新线程   java如何使用Hibernate注释在联接表上创建索引?