Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Alexa SDK V2基礎講座
Search
chao2suke
October 26, 2018
94
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Alexa SDK V2基礎講座
2018/10/26 Alexa Salon vol.3 資料
chao2suke
October 26, 2018
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.5k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.8k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.9k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.2k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
1.1k
奥深きAPLの世界
chao2suke
0
140
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2.1k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.8k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
3.1k
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
GitHub's CSS Performance
jonrohan
1033
470k
Thoughts on Productivity
jonyablonski
76
5.4k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
490
The untapped power of vector embeddings
frankvandijk
2
1.9k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
690
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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