建立Alexa技能的简单工具包。
lambdaskill的Python项目详细描述
使用AWS Lambda构建Alexa Skills的简单python 3工具包。
lambdaskill本身除了python之外没有外部依赖项 标准库。但是,包含的实用程序包需要 茴香8601包装。
界面非常直观。只是把技能分类 创造你自己的技能。将名为do_yourintent()的方法添加到 处理名为“yourintent”的意图。使用Response对象 准备回应。Cards可以附加到响应 渴望的。lambda函数处理程序通过调用 get_handler()新类的类方法。
下面是一个简单的演示,它将响应一个名为 具有名为“name”的插槽的“hellointent”:
fromlambdaskillimport*classDemoSkill(Skill):defdo_hellointent(self,request):slots=request.get_slots()name=slots['NAME']returnResponse.respond('Hello, {}'.format(name))handler=DemoSkill.get_handler()
注意,包含python方法中不允许的字符的意图 名称(如亚马逊内置的意图,例如: amazon.searchactionobject@WeatherForecast%5Btemperature%5D)可以是 处理方法如下(扩展上述示例):
@DemoSkill.intent('AMAZON.SearchAction<object@WeatherForecast[temperature]>')defweather_intent_handler(self,request):returnResponse.respond('You asked about the weather.')
它将使用 适当地损坏了名称。很明显,你会把这些线 在调用get_hander()之前,作为get_handler()调用 创建类的实例并返回该类的处理程序方法 实例。