Django应用程序可以轻松创建Amazon Alexa技能
django2-alexa的Python项目详细描述
Django2应用程序,用于创建Alexa技能
Django应用程序可以轻松创建Amazon Alexa技能。作者Tim Woocker&Malte Mosler
目录
一先决条件
如果您使用的是Apache HTTP服务器,请使用v2.4.10或更高版本! 来自Amazon's Docs:
Note: if you are using Apache HTTP Server to host your web service, use version 2.4.10 or later. Earlier versions of Apache HTTP Server send an "unrecognized name" warning if the server is not configured with a ServerName or ServerAlias in the configuration files. This prevents the Alexa service from sending the customer's request to your server. To address this, either upgrade to 2.4.10 or later, or add ServerName / ServerAlias to your server's configuration file.
2开始
您可以使用PIP安装此应用程序:
pip install django2-alexa
在djangosettings.py中,将"django2_alexa"
添加到INSTALLED_APPS
:
INSTALLED_APPS=[...'django2_alexa',...]
在您当前的路径中创建一个django应用程序:
pythonmanage.pystartappYourAppName
导入并在views.py中创建Skill
对象:
fromdjango2_alexa.interfaces.alexaimportSkillskill=Skill()
在urls.py中导入skill
,并将视图添加到urlpatterns:
fromYourAppName.viewsimportskillurlpatterns=[...path('',skill.view)...]
在settings.py中,可以在打开DEBUG
模式的情况下使用此库但是,将跳过对时间戳的amazon服务器验证。如果您试图以DEBUG
模式发布技能,这将导致amazon不接受您的技能。
现在你准备好为alexa发展你自己的技能了你可以找到几个例子here。
三设置
此django应用程序为您的项目添加一些设置:
Name | Type | Default | Description |
---|---|---|---|
^{ | ^{ | ^{ | This setting specifies if every request to an alexa skill should be verified against the amazon servers. This is useful when testing your skill without Amazon's service. |