项目介绍

terrenjpeterson/hurricane 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,目前获得 4 个 Star、1 次 Fork。

仓库全名
terrenjpeterson/hurricane
Star 数
4
Fork 数
1
未关闭 Issue
6

README 摘要

Alexa Skill - Hurricane Center This is an Alexa skill that provides updates on hurricanes based on data from the National Hurricane Center. It was first published to the Alexa Skill store in 2016, and has been used in three hurricane seasons (2016, 2017, 2018). The main logic for the skill is in the lambda.js file. The data folder contains different arrays of information that are used in generating responses by the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

hurricane 用什么语言开发?

主要使用 JavaScript 编写,目前有 4 个 Star。

如何获取 hurricane 的源码?

可以直接克隆仓库:git clone https://github.com/terrenjpeterson/hurricane.git,默认分支为 master;安装与运行步骤见仓库 README。

hurricane 最近还在维护吗?

仓库最近一次更新为 2020年6月3日,当前有 6 个未关闭 Issue;Star 数为 4,可作为社区活跃度的参考。

关于

Alexa Skill for providing hurricane updates based on data that comes from the National Hurricane Center.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
7
价值分
2
活跃状态
活跃

README

Alexa Skill - Hurricane Center

This is an Alexa skill that provides updates on hurricanes based on data from the National Hurricane Center. It was first published to the Alexa Skill store in 2016, and has been used in three hurricane seasons (2016, 2017, 2018).

The main logic for the skill is in the lambda.js file. The data folder contains different arrays of information that are used in generating responses by the skill. For example, an index of storm names that the skill has additional details on, and the storm names for the current year.

Table of Contents

Overview NLU Models

All of the files and configurations needed for setting up the skill for the Alexa Voice Service in the Amazon developer console are in the interaction_model folder. This includes the hurricane logos that are used in the Alexa skill store.

Structure of SDK

In the lambda.js file is the Alexa Skill used to process requests coming from the Alexa Voice Service. The skill is deployed as a Lambda function in AWS using nodeJS.

The framework used has a series of handler functions. This came from the template used to author the application.

  • onSessionStarted - called when the session starts.
  • onLaunch - called when the user launches the skill without specifing what they want.
  • onIntent - called when the user specifies an intent for the skill.
  • onSessionEnded - called when the user ends the session.

Intents in Skill

When processing intents, the following functions are called in the Alexa Skill that contains the specific response processing.

Intent Function
ListStormNames getStormNames()
SetOceanPreference setOceanInSession()
StormsFromPriorYears getWhichYear()
ThisYearsStorms getThisYearStorm()
CompleteListOfStorms getCompleteList()
GetStormDetail getStormDetail()
AMAZON.HelpIntent getHelpResponse()
AMAZON.StartOverIntent getWelcomeResponse()
AMAZON.RepeatIntent getWelcomeResponse()
AMAZON.StopIntent handleSessionEndRequest()
AMAZON.CancelIntent handleSessionEndRequest()

There are also a set of helper functions within the framework that package the json response properly.

  • buildSpeechletResponse (title, output, repromptText, shouldEndSession)
  • buildResponse (sessionAttributes, speechletResponse)

Storm Data from NHC

The hurricane data comes from the National Hurricane Center website. This data is available via RSS feed, but I’m not aware of any API call that publishes this detail. Each time a new tropical storm becomes active, the NHC creates an html webpage with a public advisory including the data about the storm. The data formatting is very old school, almost like a ticker tape.

A lambda function gets created based on the nhcDataGather.js template that makes a https request to gather that page, then parse through it to convert the human readable version into a valid json object. That object is then updated in an S3 bucket that is accessible by the skill. A cloudwatch event is created that triggers the lambda function every fifteen minutes, thus keeping the data current. The lambda function for the Alexa skill (lambda.js) is straight forward, and just reads the s3 object to gather the data.

The NHC updates storm forecasts either every three or six hours. The exact timing of when the content is published varies, but is normally ten minutes before the hour, with the main six hour updates at 5AM, 11AM, 5PM, 11PM ET.

Visual Rendering for Echo Show

This skill was originally written in early 2016, using a prior version of the NodeJS SDK. When the Echo Show was released, this skill was updated with this prior version to work with the Alex Show. For an example of how to use the Echo Show in the current SDK, use this repo To determine if the device has a screen, it looks for the context.System.device.supportedInterfaces.Display attribute in the main handler of the function, then passes the attribute to functions processed in the intent. The helper that renders the Speechlet response was modified to look for this attribute, then formats the JSON response to include the hurricane background using the BodyTemplate1 format.

Years Covered

This has been updated with storm data for 2018.

Alexa Native Integration

This skill is currently participating in the beta program to use Name-free Interaction which integrates into requests natively handled by Alexa, and not done within a custom skill. Name-free interaction is where Alexa gets a native question that it cannot handle, and then forwards to a custom skill.

Alexa generates a CanFulfillIntentRequest, that is forwarded to the skill by the platform querying if a certain question can be answered. The skill responds back with a response object with a series of questions answered indicating if it can fulfill on the question. Here is a sample response object if a forecast is requested for a current storm (i.e. what is the forecast for Tropical Storm Chris).

{
  "version": "1.0",
  "response": {
    "canFulfillIntent": {
      "canFulfill": "YES",
      "slots": {
        "Storm": {
          "canUnderstand": "YES",
          "canFulfill": "YES"
        }
      }
    }
  }
}

The skill indicates that it can handle the request, and a subsequent intent is triggered with the actual user intent.

For all but the setting of the ocean preference (SetOceanPreference), each of the intents answers back to this query with a positive fulfillment.

评论

暂无评论