2017-12-12 9 views
0

は、Amazonアレクサ EGでthis.emit(:ask)this.response(:speak)の違いです:アマゾンのAlexaのスキルキット(ASK)

let handler = { 
    'PlayVideoIntent' : function() { 

     // VideoApp.Play directives can be added to the response 
     if (this.event.context.System.device.supportedInterfaces.VideoApp) { 
      this.response.playVideo('http://path/to/my/video.mp4'); 
     } else { 
      this.response.speak("The video cannot be played on your device. " + 
       "To watch this video, try launching the skill from your echo show device."); 
     } 

     this.emit(':responseReady'); 
    } 
} 

答えて

0

はStackOverflowのへようこそ。答えは質問自体にあります。

askがある場合は、セッションがまだ維持されており、Alexaがユーザーから何かを期待していることを意味します。また、一方でtellを使用している場合は、利用可能なセッションがないことを意味します。以下の例が役立ちます。

User: Alexa, how are you doing. 

Alexa: I'm doing good thank you. 

--Conversation ended 

が、これはあなたを助け

User: Alexa set an alarm 
Alexa: sure, at what time? <-- This is where we use ask, as the conversation is incomplete 
User: at 5:30 AM 
Alexa: Alarm set <-- This is where we use tell, as the task is done and there is no use of user's input anymore. 

希望を聞いて教えてください。

ハッピーコーディング!

0

Alexaスキルキットdocumentation詳細な説明があります。

Response vs ResponseBuilderセクションから:

現在、Node.jsのSDKで応答オブジェクトを生成するための2つの方法があります。最初の方法は、形式this.emit(:${action}, 'responseContent')に従う構文を使用しています。

独自の応答を手動で作成する場合は、this.responseを使用してください。 this.responseには、応答のさまざまなプロパティを設定するために使用できる一連の関数が含まれています。これにより、Alexaスキルキットに組み込まれているオーディオおよびビデオプレーヤーのサポートを利用できます。レスポンスを設定したら、this.emit(':responseReady')に電話してAlexaに返信することができます。 this.responseの機能も連鎖可能ですので、好きなだけ多くの行を使用できます。

レスポンスの設定が完了したら、this.emit(':responseReady')に電話して応答をオフにしてください。

例1:以下は、いくつかのレスポンスオブジェクトとレスポンスの構築2つの例です

this.response.speak(speechOutput) .listen(repromptSpeech); this.emit(':responseReady');

例2

this.response.speak(speechOutput) .cardRenderer(cardTitle, cardContent, cardImage) .renderTemplate(template) .hint(hintText, hintType); this.emit(':responseReady');

responseBuilderがリッチ応答オブジェクトを構築するために、より柔軟性があるので、我々このメソッドを使用してレスポンスを構築することをお勧めします。

関連する問題