Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Alexa-SDK-V2基礎講座@大阪
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
chao2suke
October 19, 2018
Technology
110
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Alexa-SDK-V2基礎講座@大阪
2018/10/17 Alexa Salon vol.3@大阪 登壇資料
chao2suke
October 19, 2018
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.4k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.8k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.9k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.2k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
1k
奥深きAPLの世界
chao2suke
0
130
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2.1k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.8k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
3k
Other Decks in Technology
See All in Technology
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
1
220
「エンジニア進化論」2028年の開発完全自動化、エンジニアはどう進化するか
cyberagentdevelopers
PRO
4
3.1k
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
580
Socrates × Looker 〜セマンティックレイヤーで進化するデータ分析エージェント〜
hanon52_
3
1.9k
実装は速くなった、レビューはどうする? ― 自身のレビューをAIで再現させるサーヴァントエンジニアリングのすゝめ / Implementation got faster. So what about reviews? — An invitation to Servant Engineering: Recreating your own code reviews with AI
nrslib
8
4.5k
自律型AIエージェントは何を破壊するのか
kojira
0
140
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
810
手塩にかけりゃいいってもんじゃない
ming_ayami
0
130
OCI Oracle AI Database Services新機能アップデート(2026/03-2026/05)
oracle4engineer
PRO
0
330
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
EventBridge Connection
_kensh
5
680
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
A Tale of Four Properties
chriscoyier
163
24k
The Curious Case for Waylosing
cassininazir
1
380
Code Reviewing Like a Champion
maltzj
528
40k
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
Thoughts on Productivity
jonyablonski
76
5.2k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
GitHub's CSS Performance
jonrohan
1033
470k
Scaling GitHub
holman
464
140k
Writing Fast Ruby
sferik
630
63k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
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 • コードブロック概要 • Skill Builderについて • インストール⽅法 • Handlerについて
• Response Builderについて • Attribute Managerについて 5
コードブロック概要 6
Hello World 7 const MyHandler = { canHandle(handlerInput) { return
true; }, handle(handlerInput) { return handlerInput.responseBuilder .speak('͜Μʹͪ') .getResponse(); } };
8
9
10
Skill Builder 11
12 Skill Builderとは Skillインスタンスを作るもの
13 Skill Builder Standard Custom
14 Skill Builder Standard Custom 全部⼊り 欲しいところだけ
15 Skill Builder(Custom) Core 基本機能だけ動けばいい Model
16 Skill Builder(Custom) Core DB使いたい Model Persistant Adapter
17 Skill Builder(Custom) Core DBとAPI使いたい Model Persistant Adapter APIClient
18 Skill Builder(Custom) Customコンポーネント Core 基本機能 Model 定義情報 Dynamodb-persistance-adapter DynamoDBによる永続化
S3-peresistance-adapter S3による永続化 Api-client AlexaサービスAPIの使⽤
インストール 19
インストール 20 $ npm install --save ask-sdk
インストール(Coreのみ) 21 $ npm install --save ask-sdk-model $ npm install
--save ask-sdk-core
Customビルダーでの宣⾔ 22 ライブラリのインストール コード冒頭でrequired Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 23 ライブラリのインストール $ npm install --save ask-sdk-dynamodb- persistence-adapter $
npm install --save ask-sdk-model $ npm install --save ask-sdk-core
Ex.CustomでDynamoDBを使う 24 'use strict'; const aws = require('aws-sdk-core'); const Adapter
= require('ask-sdk-dynamodb- persistence-adapter'); コード冒頭でrequired
Ex.CustomでDynamoDBを使う 25 const config = {tableName: 'alexa-salon-vol3', createTable: true}; const
DynamoDBAdapter = new Adapter.DynamoDbPersistenceAdapter(config); Skill Builderにメソッド追加
Ex.CustomでDynamoDBを使う 26 const skillBuilder = Alexa.SkillBuilders.custom(); exports.handler = skillBuilder .addRequestHandlers(
LaunchRequestHandler, ) .withPersistenceAdapter(DynamoDBAdapter) .addErrorHandlers(ErrorHandler) .lambda(); Skill Builderにメソッド追加
Handler 27
28 Handler CanHandle Handle
canHandle 29 このHandlerはどのIntentを処理するか True / False
canHandle • このハンドラーはどのIntentを処理するか 30 canHandle(handlerInput) { return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'MenuIntent'; },
31 CanHandle Tips Handlerは登録した順番でCanHandleする exports.handler = skillBuilder .addRequestHandlers( LaunchRequestHandler, OrderProgressIntentHandler,
OrderCompletedIntentHandler, HelpIntentHandler, CancelAndStopIntentHandler, SessionEndedRequestHandler )
handle • 実際の処理内容 32 handle(handlerInput) { return setMenu(handlerInput, null); }
33 Handler Tips Handler-A: 郵便番号がSlotに⼊っている Handler-B: 住所がSlotに⼊っている Handler-C: 何も⼊っていない 近くの店舗をお知らせする
郵便番号を調べて確認する 郵便番号を聞く
Slotのとり⽅ 34 handlerInput.requestEnvelope.request.intent.slots.hand.value
35 Slot Tips requestまでは⼀緒なので変数化する handlerInput.requestEnvelope.request.intent.slots.hand.value var request = handlerInput.requestEnvelope.request; var
slot = request.intent.slots.hand.value;
Response 36
37 Response Builder Tips ResponseBuilderはチェーンで書く return handlerInput.responseBuilder .speak('͢Έ·ͤΜɺΑ͘ฉ͖औΕ·ͤΜͰͨ͠ɻ͏Ұݴͬͯ Β͑·͔͢?') .reprompt('͏ҰݴͬͯΒ͑·͔͢?')
.getResponse();
Response Builder 38 ଟ͗͢Δ
カテゴリに分けてみる。 39
Response Builder 40
Response Builder 41 発話系 speak/response カード系 withXXXcard Dialog Model系 delegate/ElicitXXX/addConfirmXXX
AudioPlayer系 addAudioPlayerXXX Display系 addRenderTemplateDirective Video系 addVideoAppLaunchDirective セッション管理系 withShouldEndSession
Ex.BodyTemplate 42 handlerInput.responseBuilder .speak(speechText) .reprompt(speechText) .addRenderTemplateDirective({ type: 'ListTemplate1', backButton: 'HIDDEN',
backgroundImage: logoImage, listItems: listitems, title: 'ϝχϡʔ', token : gToken, }) .getResponse();
43 Response Builder Tips ResponseBuilderはバラバラに書いて良い
44 Response Builder Tips handlerInput.responseBuilder .speak(‘͜Ε͚ͩͩͱ͚ͩ͢’); if (canReprompt) { .reprompt(‘͜Ε͕ೖΔͱ͍͔͚ʹͳΔ’);
} handlerInput.responseBuilder.getResponse();
Response Builder Tips • じゃんけんであいこの時だけ もう⼀度聞き直す • ディスプレイのついているデバイスからの リクエストのみDisplayRenderをつける 45
Attribute Manager 46
47 Alexa-SDK V2Ͱͷηογϣϯཧ AttributeManager RequestAttributes SessionAttributes PersistentAttributes
͍ํ let attributes = await handlerInput.attributesManager.getPersistentAttributes() handlerInput.attributesManager.setPersistentAttributes(a ttributes); await handlerInput.attributesManager.savePersistentAttributes(
);
͍ํ
͍ํ
None