$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Alexa SDK V2基礎講座
Search
chao2suke
October 26, 2018
2
88
Alexa SDK V2基礎講座
2018/10/26 Alexa Salon vol.3 資料
chao2suke
October 26, 2018
Tweet
Share
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.4k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.7k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.8k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
930
奥深きAPLの世界
chao2suke
0
130
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.7k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.9k
Featured
See All Featured
A Tale of Four Properties
chriscoyier
162
23k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Leo the Paperboy
mayatellez
0
1.3k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
680
Mind Mapping
helmedeiros
PRO
0
39
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
710
Prompt Engineering for Job Search
mfonobong
0
130
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
170
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
580
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Reality Check: Gamification 10 Years Later
codingconduct
0
1.9k
Transcript
Alexa-SDK V2 基礎講座 Alexa-SDK V2 Training course 1 Classmethod, Inc.
せーの
#AlexaSalon 2
!3 ( ) A I A l e x a
& V U I / O /
ί ϛ ϡ χ ς Ο [ A l e
x a S a l o n ] ओ ࠵ A m a z o n ެ ࣜ ϋ ϯ ζ Φ ϯ τ Ϩ ʔ χ ϯ ά ς Ϋ χ Χ ϧ α ϙ ʔ τ A m a z o n ެ ࣜ τ Ϩ ʔ χ ϯ άϖ ʔ δ ੍ ࡞ A l e x a S k i l l A w a r d s ެ ࣜ ϋ ο Χ ι ϯ : ς Ϋ χ Χ ϧ α ϙ ʔ τ ܾ উ ৹ ࠪ һ ॳ ৺ ऀ ͚ A l e x a ຊ ࣥ ච !4
Agenda • • S k i l l B u
i l d e r • • H a n d l e r • R e s p o n s e B u i l d e r • A t t r i b u t e M a n a g e r 5
6
Hello World 7 const MyHandler = { canHandle(handlerInput) { return
true; }, handle(handlerInput) { return handlerInput.responseBuilder .speak('͜Μʹͪ') .getResponse(); } };
8
9
10
Skill Builder 11
Skill Builder 12 Skill
Skill Instance 13 const skillBuilder = Alexa.SkillBuilders.custom(); exports.handler = skillBuilder
.addRequestHandlers( LaunchRequestHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler ) .addErrorHandlers(ErrorHandler) .lambda();
Skill Instance 14 const skillBuilder = Alexa.SkillBuilders.custom(); exports.handler = skillBuilder
.addRequestHandlers( LaunchRequestHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler ) .addErrorHandlers(ErrorHandler) .lambda(); ͜Εɻ
Skill Builder 15 Standard Custom શ෦ೖΓ ཉ͍͠ͱ͜Ζ͚ͩ
16 Skill Builder(Custom) Core Model
17 Skill Builder(Custom) Core DB Model Persistant Adapter
18 Skill Builder(Custom) Core DB API Model Persistant Adapter APIClient
19 Skill Builder(Custom) Custom Core 基本機能 Model 定義情報 Dynamodb-persistance-adapter DynamoDBによる永続化
S3-peresistance-adapter S3による永続化 Api-client AlexaサービスAPIの使⽤
20 インストール
インストール 21 $ npm install --save ask-sdk
インストール(Coreのみ) 22 $ npm install --save ask-sdk-model $ npm install
--save ask-sdk-core
Customビルダーでの宣⾔ 23 ライブラリのインストール コード冒頭でrequired Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 24 ライブラリのインストール $ npm install --save ask-sdk-dynamodb- persistence-adapter $
npm install --save ask-sdk-model $ npm install --save ask-sdk-core
Ex.CustomでDynamoDBを使う 25 'use strict'; const aws = require('aws-sdk-core'); const Adapter
= require('ask-sdk-dynamodb- persistence-adapter'); コード冒頭でrequired
Ex.CustomでDynamoDBを使う 26 const config = {tableName: 'alexa-salon-vol3', createTable: true}; const
DynamoDBAdapter = new Adapter.DynamoDbPersistenceAdapter(config); Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 27 const skillBuilder = Alexa.SkillBuilders.custom(); exports.handler = skillBuilder .addRequestHandlers(
LaunchRequestHandler, ) .withPersistenceAdapter(DynamoDBAdapter) .addErrorHandlers(ErrorHandler) .lambda(); Skill Builderにメソッド追加
H a n d l e r 28
Handler 29 CanHandle Handle
canHandle 30 Handler Intent True / False
canHandle 31 Handler Intent canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'MenuIntent'; },
32 CanHandle Tips Handler CanHandle exports.handler = skillBuilder .addRequestHandlers( LaunchRequestHandler,
OrderProgressIntentHandler, OrderCompletedIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler )
Handler Tips 33 Handler-A: Slot Handler-B: Slot Handler-C: 近くの店舗をお知らせする 郵便番号を調べて確認する
郵便番号を聞く
handle 34 handle(handlerInput) { return setMenu(handlerInput, null); }
Slotのとり⽅ 35 handlerInput.requestEnvelope.request.intent.slots.hand.value
36 Slot Tips requestまでは⼀緒なので変数化する handlerInput.requestEnvelope.request.intent.slots.hand.value var request = handlerInput.requestEnvelope.request; var
slot = request.intent.slots.hand.value;
Response 37
38 Response Builder Tips ResponseBuilderはチェーンで書く return handlerInput.responseBuilder .speak('͢Έ·ͤΜɺΑ͘ฉ͖औΕ·ͤΜͰͨ͠ɻ͏Ұݴͬͯ Β͑·͔͢?') .reprompt('͏ҰݴͬͯΒ͑·͔͢?')
.getResponse();
Response Builder 39 ଟ͗͢Δ
カテゴリに分けてみる。 40
Response Builder 41
Response Builder 42 発話系 speak/response カード系 withXXXcard Dialog Model系 delegate/ElicitXXX/addConfirmXXX
AudioPlayer系 addAudioPlayerXXX Display系 addRenderTemplateDirective Video系 addVideoAppLaunchDirective セッション管理系 withShouldEndSession
Ex.BodyTemplate 43 handlerInput.responseBuilder .speak(speechText) .reprompt(speechText) .addRenderTemplateDirective({ type: 'ListTemplate1', backButton: 'HIDDEN',
backgroundImage: logoImage, listItems: listitems, title: 'ϝχϡʔ', token : gToken, }) .getResponse();
44 Response Builder Tips ResponseBuilderはバラバラに書いて良い
45 Response Builder Tips handlerInput.responseBuilder .speak(‘͜Ε͚ͩͩͱ͚ͩ͢’); if (canReprompt) { .reprompt(‘͜Ε͕ೖΔͱ͍͔͚ʹͳΔ’);
} handlerInput.responseBuilder.getResponse();
Response Builder Tips じゃんけんであいこの時だけ もう⼀度聞き直す ディスプレイのついているデバイスからのリ クエストのみDisplayRenderをつける 46
Attribute Manager 47
48 AttributeManager RequestAttributes SessionAttributes PersistentAttributes
͍ํ 49 let attributes = await handlerInput.attributesManager.getPersistentAttributes() handlerInput.attributesManager.setPersistentAttributes(a ttributes); await
handlerInput.attributesManager.savePersistentAttributes( );
50 ͍ํ
51 ͍ํ
52
None