dasevilla/asana-alexa-skill

语言: JavaScript

git: https://github.com/dasevilla/asana-alexa-skill

Asana的Alexa技巧
Alexa Skill for Asana
README.md (中文)

Asana Alexa Skill

这不是官方的Asana项目。

Alexa Skill,可让您轻松地向Asana添加任务。您可以选择将任务添加到项目中。

示例短语:

  • Alexa,告诉Asana添加买牛奶
  • Alexa,告诉Asana将培根加入市场

查看SampleUtterances.txt文件以获取更多示例。

限制

认证

现在你必须硬编码你的Asana访问令牌。虽然Alexa确实支持OAuth 2.0隐式授权,但有两个问题:

  • Asana需要重定向URI,但亚马逊在创建授权URL时不包含它
  • Asana访问令牌限制为12小时,因此您需要经常重新授权应用程序

您可以通过在Alexa技能授权URL设置中手动指定redirect_uri参数来解决第一个问题。

默认工作区

理想情况下,您可以告诉Alexa您要使用哪个工作空间作为默认值。这需要存储在某个地方,我不想实现它,因为我们已经由于授权限制而硬编码设置。

您可以在sample.env中指定默认工作区设置ASANA_DEFAULT_WORKSPACE_ID。查找工作区标识符是留给读者的练习。

配置新的Alexa技能

您需要的所有内容都可以在speech-assets目录中找到。设置自定义插槽时,文件名应为自定义插槽的名称。

发展

该项目假设您将部署到Amazon Lambda。将sample.env复制到.env并填写值。然后安装包:

npm install

要测试event.json中定义的事件,请调用:

grunt lambda_invoke

在dist中创建一个包:

grunt lambda_package

部署:

export AWS_ACCESS_KEY_ID=KEY
export AWS_SECRET_ACCESS_KEY=SECRET
grunt lambda_deploy

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

Asana Alexa Skill

This is not an official Asana project.

Alexa Skill that lets you easily add tasks to Asana. You can optionally add a task to a project.

Example phrases:

  • Alexa, tell Asana to add buy milk
  • Alexa, tell Asana to add bacon to market

Checkout the SampleUtterances.txt file for more examples.

Limitations

Authentication

Right now you have to hard-code your Asana access token. While Alexa does support the OAuth 2.0 implicit grant, there's two issues:

  • Asana requires the redirect URI, but Amazon doesn't included it when creating the authorization URL
  • Asana access tokens are limited to twelve hours, so you'll need to re-authorize the application often

You can workaround the first issue by manually specifying the redirect_uri parameter in the Alexa Skill authorization URL setting.

Default workspace

Ideally you could tell Alexa which workspace you want to use as the default. That would need to be stored somewhere and I didn't want to implement that since we're already hard-coding settings due to the authorization limitation.

You can specify the default workspace be setting the ASANA_DEFAULT_WORKSPACE_ID in sample.env. Finding your workspace identifiers is an exercises left to the reader.

Configure a new Alexa Skill

Everything you need can be found in the speech-assets directory. When setting up the custom slots, the file name should be the name of the custom slot.

Develop

This project assumes you'll be deploying to Amazon Lambda. Copy sample.env to .env and fill in the values. Then install the packages:

npm install

To test the event defined in event.json, invoke:

grunt lambda_invoke

To create a package in dist:

grunt lambda_package

To deploy:

export AWS_ACCESS_KEY_ID=KEY
export AWS_SECRET_ACCESS_KEY=SECRET
grunt lambda_deploy