Skip to content

Commit

Permalink
docs: update ja docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhang committed Oct 26, 2018
1 parent 4728d42 commit ad2fcec
Show file tree
Hide file tree
Showing 13 changed files with 1,003 additions and 545 deletions.
4 changes: 0 additions & 4 deletions docs/en/Calling-Alexa-Service-APIs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,6 @@ Skills should initiate the Cancel action when a customer asks to cancel an exist

.. code-block:: javascript
// Skills would implement a custom intent (buyIntent below) that captures
// user's intent to buy an in-skill product and then trigger the Buy request for it.
// For e.g. 'Alexa, buy <product name>'
const cancelIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
Expand Down
6 changes: 3 additions & 3 deletions docs/en/Managing-Attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ The ``getAttributes`` operation retrieves the attributes from the DynamoDB table
``saveAttributes(requestEnvelope : RequestEnvelope, attributes : {[key : string] : any}) : Promise<void>``
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

The ``saveAttributes`` operation saves the attributes to the DynamoDB table using the partition key generated from the ``RequestEnvelope``. It uses a ``DynamoDBDocumentClient`` with ``convertEmptyValues`` set to true. So that any ``""``, ``null`` or ``undefined`` values in the attributes object will be converted.
The ``saveAttributes`` operation saves the attributes to the DynamoDB table using the partition key generated from the ``RequestEnvelope``. It uses a ``DynamoDBDocumentClient`` with ``convertEmptyValues`` set to ``true``. So that any ``""``, ``null`` or ``undefined`` values in the attributes object will be converted.

S3PersistenceAdapter
--------------------
Expand All @@ -199,7 +199,7 @@ S3PersistenceAdapter

.. note::

Because Amazon S3 provides `eventual consistency <https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html>`_ for updates to existing objects, we recommend using `ask-sdk-dynamodb-persistence-adapter <https://github.com/tianrenz/alexa-skills-kit-sdk-for-nodejs/tree/2.0.x/ask-sdk-dynamodb-persistence-adapter>`_ for persistent attributes if your skill requires read-after-write consistency.
Because Amazon S3 provides `eventual consistency <https://docs.aws.amazon.com/AmazonS3/latest/dev/Introduction.html>`_ for updates to existing objects, we recommend using `DynamoDbPersistenceAdapter`_ for persistent attributes if your skill requires read-after-write consistency.

Constructor Details
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -233,7 +233,7 @@ Config Options

* **bucketName** (string) - The name of the S3 bucket used.
* **objectKeyGenerator** (function) - Optional. The function used to generate object key using ``RequestEnvelope``. Default to generate the object key using the ``userId``.
* **s3Client** (`AWS.S3 <https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html>`_ ) - Optional. The ``S3Client`` used to query AWS S3 bucket. You can inject your ``S3Client`` with custom configuration here. Default to use ``new AWS.S3({apiVersion : 'latest'})``.
* **s3Client** (`AWS.S3 <https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html>`_) - Optional. The ``S3Client`` used to query AWS S3 bucket. You can inject your ``S3Client`` with custom configuration here. Default to use ``new AWS.S3({apiVersion : 'latest'})``.
* **pathPrefix** (string) - The prefix value added to the object key generated. This is used for s3 to mimic a file system structure. Default to empty string.

Method Details
Expand Down
2 changes: 1 addition & 1 deletion docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ Request and vote for Alexa features `here <https://alexa.uservoice.com/forums/90
.. _Building Response: Building-Response.html
.. _Managing Attributes: Managing-Attributes.html
.. _Calling Alexa Service APIs: Calling-Alexa-Service-APIs.html
.. _Configuring Skill Instance: Configuring-Skill-Instance.html
.. _Configuring Skill Instance: Configuring-Skill-Instance.html
57 changes: 18 additions & 39 deletions docs/ja/ASK-SDK-Migration-Guide.rst
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
====================
************************
ASK SDK移行ガイド
====================
************************

このガイドでは、ASK SDK v2 for Node.jsとASK SDK v1アダプターを使ってASK
SDK v1 for Node.js(alexa-sdk)で開発した既存のスキルをv2
SDK(ask-sdk)に移行する手順を詳しく説明します。
このガイドでは、ASK SDK v2 for Node.jsとASK SDK v1アダプターを使ってASK SDK v1 for Node.js(alexa-sdk)で開発した既存のスキルをv2 SDK(ask-sdk)に移行する手順を詳しく説明します。

後方互換性
-----------------
=======================

ASK SDK v1アダプターにはASK SDK
v1インターフェースとの後方互換性があるため、v1のAlexaスキルを簡単にSDK
v2に移行できます。v1アダプターを使うと、v1とv2の形式でコーディングされたリクエストハンドラーを共存させることができます。これにより、既存のAlexaスキルをv2形式のリクエストハンドラーで拡張でき、同時に既存のハンドラーを都合の良いタイミングでアップデートできます。新規のスキルの場合、v2の機能を活用するために最初からASK
SDK v2 for Node.jsで開発するようにしてください。
ASK SDK v1アダプターにはASK SDK v1インターフェースとの後方互換性があるため、v1のAlexaスキルを簡単にSDK v2に移行できます。v1アダプターを使うと、v1とv2の形式でコーディングされたリクエストハンドラーを共存させることができます。これにより、既存のAlexaスキルをv2形式のリクエストハンドラーで拡張でき、同時に既存のハンドラーを都合の良いタイミングでアップデートできます。新規のスキルの場合、v2の機能を活用するために最初からASK SDK v2 for Node.jsで開発するようにしてください。

前提条件
-----------------

- インストールされた標準ASK
SDKモジュールとの依存関係を持つ\ `NPM <https://www.npmjs.com/>`__
プロジェクト。標準ASK SDKモジュールのインストールについては\ `ASK
SDK v2 for
Node.jsのセットアップ <Setting-Up-The-ASK-SDK.html>`__\
セクションを参照してください。ASK SDK v1アダプターには、標準ASK SDK
v2 for Node.js配布パッケージ(ask-sdk)とのpeer依存関係があります。
- 適切なNode.js開発環境。ASK SDK v2 for
Node.jsには、Node.jsのバージョン4.3.2以上が必要です。
=============

- インストールされた標準ASK SDKモジュールとの依存関係を持つ\ `NPM <https://www.npmjs.com/>`__ プロジェクト。標準ASK SDKモジュールのインストールについては\ `ASK SDK v2 for Node.jsのセットアップ <Setting-Up-The-ASK-SDK.html>`__\ セクションを参照してください。ASK SDK v1アダプターには、標準ASK SDK v2 for Node.js配布パッケージ(ask-sdk)とのpeer依存関係があります。
- 適切なNode.js開発環境。ASK SDK v2 for Node.jsには、Node.jsのバージョン4.3.2以上が必要です。

移行の手順
===============

ASK SDK v1アダプターをプロジェクトに追加する
---------------------------------------------------

NPMプロジェクトから、以下のコマンドを実行してASK SDK
v1アダプターモジュールをインストールします。
NPMプロジェクトから、以下のコマンドを実行してASK SDK v1アダプターモジュールをインストールします。

::

npm install --save ask-sdk-v1adapter

移行の手順
----------------------------------

import文をアップデートする
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-----------------------------

ASK SDK v1 for
Node.jsを使用するスキルコードを移植するには、\ ``alexa-sdk``\ パッケージではなく\ ``ask-sdk-v1adapter``\ パッケージからインポートする必要があります。アダプターは内部のロジック解釈を処理してASK
SDK v2 for Node.jsを使用する ``Skill``\ インスタンスを作成します。
ASK SDK v1 for Node.jsを使用するスキルコードを移植するには、\ ``alexa-sdk``\ パッケージではなく\ ``ask-sdk-v1adapter``\ パッケージからインポートする必要があります。アダプターは内部のロジック解釈を処理してASK SDK v2 for Node.jsを使用する ``Skill``\ インスタンスを作成します。

コードの以下の部分を変更します。

Expand All @@ -71,19 +56,13 @@ SDK v2 for Node.jsを使用する ``Skill``\ インスタンスを作成しま
};

v2リクエストハンドラーを追加する
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
----------------------------------------------------

ASK SDK
v1アダプターを使用することで、v1とv2のリクエストハンドラーを共存させることができます。ただし、Alexaスキルを拡張している場合は、ASK
SDK v2 for
Node.jsの機能をフルに活用できるv2のリクエストハンドラーを使用することをお勧めします。
ASK SDK v1アダプターを使用することで、v1とv2のリクエストハンドラーを共存させることができます。ただし、Alexaスキルを拡張している場合は、ASK SDK v2 for Node.jsの機能をフルに活用できるv2のリクエストハンドラーを使用することをお勧めします。

リクエストを処理できるv1ハンドラーがない場合のみ、v1のリクエストハンドラーの後にv2のリクエストハンドラーにアクセスします。そのため、v1ハンドラーをv2ハンドラーで置き換えた場合、v1ハンドラーのコードを必ず削除してください。

以下のコードサンプルでは、
``AMAZON.HelpIntent``\ を処理できるv2リクエストハンドラーを既存の\ `hello
worldサンプルスキル <https://github.com/alexa/skill-sample-nodejs-hello-world/tree/last-with-sdk-v1>`__\ に追加しています。この例では、元のv1の\ ``AMAZON.HelpIntent``
ハンドラーが\ ``handlers``\ 定数から削除されています。
以下のコードサンプルでは、 ``AMAZON.HelpIntent``\ を処理できるv2リクエストハンドラーを既存の `hello worldサンプルスキル <https://github.com/alexa/skill-sample-nodejs-hello-world/tree/last-with-sdk-v1>`_ に追加しています。この例では、元のv1の\ ``AMAZON.HelpIntent`` ハンドラーが\ ``handlers``\ 定数から削除されています。

.. code:: javascript
Expand Down
215 changes: 145 additions & 70 deletions docs/ja/Building-Response.rst
Original file line number Diff line number Diff line change
@@ -1,88 +1,163 @@
====================
*****************
応答のビルド
====================
*****************

標準的な応答
=================

Lambdaをスキルのエンドポイントに使用している場合は、Alexaがユーザーリクエストに応答するための応答本文を提供するだけで済みます。応答本文のJSON構造についてのドキュメントは、 `こちら <https://developer.amazon.com/ja/docs/custom-skills/request-and-response-json-reference.html#response-format>`_ を参照してください。

応答本文には、次のプロパティが含まれる場合があります:

* version
* sessionAttributes
* response

ASK SDK v2 for Node.jsを使用すると、versionとsessionAttributesを入力してくれるので、ボイラープレートコード(毎回書かなければならないお決まりのコード)を書く手間が省けるので、その分応答の作成に集中できます。

ResponseBuilder
---------------

SDKには応答を作成するためのヘルパー関数が含まれています。\ ``Response``\ には複数の要素が含まれる場合があり、ヘルパー関数によって応答を生成しやすくなり、各応答の要素を初期化したり設定したりする時間を削減できます。

**インターフェース**

.. code:: typescript
interface ResponseBuilder {
speak(speechOutput: string): this;
reprompt(repromptSpeechOutput: string): this;
withSimpleCard(cardTitle: string, cardContent: string): this;
withStandardCard(cardTitle: string, cardContent: string, smallImageUrl?: string, largeImageUrl?: string): this;
withLinkAccountCard(): this;
withAskForPermissionsConsentCard(permissionArray: string[]): this;
addDelegateDirective(updatedIntent?: Intent): this;
addElicitSlotDirective(slotToElicit: string, updatedIntent?: Intent): this;
addConfirmSlotDirective(slotToConfirm: string, updatedIntent?: Intent): this;
addConfirmIntentDirective(updatedIntent?: Intent): this;
addAudioPlayerPlayDirective(playBehavior: interfaces.audioplayer.PlayBehavior, url: string, token: string, offsetInMilliseconds: number, expectedPreviousToken?: string): this;
addAudioPlayerStopDirective(): this;
addAudioPlayerClearQueueDirective(clearBehavior: interfaces.audioplayer.ClearBehavior): this;
addRenderTemplateDirective(template: interfaces.display.Template): this;
addHintDirective(text: string): this;
addVideoAppLaunchDirective(source: string, title?: string, subtitle?: string): this;
withShouldEndSession(val: boolean): this;
addDirective(directive: Directive): this;
getResponse(): Response;
}
以下の例は、ResponseBuilderヘルパー関数を使用して応答を作成する方法を示しています。

.. code:: javascript
const handle = function(handlerInput) {
return handlerInput.responseBuilder
.speak('foo')
.reprompt('bar')
.withSimpleCard('title', 'cardText')
.getResponse();
}
===============

``ResponseBuilder`` には応答を作成するためのヘルパーメソッドが含まれています。 ``Response`` には複数の要素が含まれる場合があり、ヘルパーメソッドによって、各応答の要素を初期化したり設定したりする必要がなくなり、応答を生成しやすくなります。 ``ResponseBuilder`` は、 ``HandlerInput`` コンテナオブジェクトからハンドラーで使用できます。 ``ResponseBuilder`` の詳細については、 `TypeDoc <http://ask-sdk-node-typedoc.s3-website-us-east-1.amazonaws.com/classes/responsebuilder.html>`_ を参照してください。

利用可能なメソッド
----------------------------------

.. code-block:: typescript
speak(speechOutput: string): this;
reprompt(repromptSpeechOutput: string): this;
withSimpleCard(cardTitle: string, cardContent: string): this;
withStandardCard(cardTitle: string, cardContent: string, smallImageUrl?: string, largeImageUrl?: string): this;
withLinkAccountCard(): this;
withAskForPermissionsConsentCard(permissionArray: string[]): this;
addDelegateDirective(updatedIntent?: Intent): this;
addElicitSlotDirective(slotToElicit: string, updatedIntent?: Intent): this;
addConfirmSlotDirective(slotToConfirm: string, updatedIntent?: Intent): this;
addConfirmIntentDirective(updatedIntent?: Intent): this;
addAudioPlayerPlayDirective(playBehavior: interfaces.audioplayer.PlayBehavior, url: string, token: string, offsetInMilliseconds: number, expectedPreviousToken?: string, audioItemMetadata? : AudioItemMetadata): this;
addAudioPlayerStopDirective(): this;
addAudioPlayerClearQueueDirective(clearBehavior: interfaces.audioplayer.ClearBehavior): this;
addRenderTemplateDirective(template: interfaces.display.Template): this;
addHintDirective(text: string): this;
addVideoAppLaunchDirective(source: string, title?: string, subtitle?: string): this;
withShouldEndSession(val: boolean): this;
addDirective(directive: Directive): this;
getResponse(): Response;
次のResponseBuilderメソッドは、 `public beta SDK <https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/tree/2.x_public-beta>`__ でのみ使用できます:

.. code-block:: typescript
withCanFulfillIntent(canFulfillIntent : CanFulfillIntent) : this;
以下の例は、 ``ResponseBuilder`` ヘルパーメソッドを使用して応答を作成する方法を示しています。

.. tabs::

.. code-tab:: javascript

const response = handlerInput.responseBuilder
.speak('foo')
.reprompt('bar')
.withSimpleCard('title', 'cardText')
.getResponse();

.. code-tab:: typescript

const response = handlerInput.responseBuilder
.speak('foo')
.reprompt('bar')
.withSimpleCard('title', 'cardText')
.getResponse();

.. note::

speakとreprompt値のコンテンツはSSMLタグで囲みます。つまり、値に含まれるXMLの特殊文字はエスケープ処理をする必要があります。たとえば、 ``handlerInput.responseBuilder.speak("I like M&M's")`` では、このままでは失敗します。文字 ``&`` を ``&amp`` と記述する必要があります。他にも処理が必要な文字は、 ``<`` -> ``&lt``;、および ``>`` -> ``&gt;`` などがあります。

画像とテキストのヘルパー
------------------------------
============================================

ASK SDK v2 for Node.jsは以下のヘルパークラスを提供しています。これらは、Echo Showと互換性のあるスキルで広く使用されるテキストや画像の要素の作成に便利です。

ImageHelper
-----------

.. tabs::

.. code-tab:: javascript

const Alexa = require('ask-sdk-core');

const myImage = new Alexa.ImageHelper()
.withDescription('FooDescription')
.addImageInstance('http://BarImageSource')
.getImage();

.. code-tab:: typescript

import { ImageHelper } from 'ask-sdk-core';
import { interfaces } from 'ask-sdk-model';
import Image = interfaces.display.Image;

const myImage : Image = new ImageHelper()
.withDescription('FooDescription')
.addImageInstance('http://BarImageSource')
.getImage();

PlainTextContentHelper
----------------------

.. tabs::

.. code-tab:: javascript

const Alexa = require('ask-sdk-core');

const myTextContent = new Alexa.PlainTextContentHelper()
.withPrimaryText('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();

ASK SDK v2 for
Node.jsは以下のヘルパークラスを提供しています。これらは、Echo
Showと互換性のあるスキルで広く使用されるテキストや画像の要素の作成に便利です。
.. code-tab:: typescript

**``ImageHelper``**
import { PlainTextContentHelper } from 'ask-sdk-core';
import { interfaces } from 'ask-sdk-model';
import TextContent = interfaces.display.TextContent;

.. code:: javascript
const myTextContent : TextContent = new PlainTextContentHelper()
.withPrimaryText('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();

const Alexa = require('ask-sdk');

const myImage = new Alexa.ImageHelper()
.withDescription('FooDescription')
.addImageInstance('http://BarImageSource')
.getImage();
RichTextContentHelper
---------------------

**``PlainTextContentHelper``**
.. tabs::

.. code:: javascript
.. code-tab:: javascript

const Alexa = require('ask-sdk');
const Alexa = require('ask-sdk-core');

const myTextContent = new Alexa.PlainTextContentHelper()
.withPrimaryTexT('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();
const myTextContent = new Alexa.RichTextContentHelper()
.withPrimaryText('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();

**``RichTextContentHelper``**
.. code-tab:: typescript

.. code:: javascript
import { RichTextContentHelper } from 'ask-sdk-core';
import { interfaces } from 'ask-sdk-model';
import TextContent = interfaces.display.TextContent;

const Alexa = require('ask-sdk');
const myTextContent : TextContent = new RichTextContentHelper()
.withPrimaryText('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();

const myTextContent = new Alexa.RichTextContentHelper()
.withPrimaryTexT('Foo')
.withSecondaryText('Bar')
.withTertiaryText('Baz')
.getTextContent();
Loading

0 comments on commit ad2fcec

Please sign in to comment.