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
chao2suke
October 19, 2018
Technology
1
100
Alexa-SDK-V2基礎講座@大阪
2018/10/17 Alexa Salon vol.3@大阪 登壇資料
chao2suke
October 19, 2018
Tweet
Share
More Decks by chao2suke
See All by chao2suke
天井カメラで捉えた人物をコンピュータビジョンで解析した3年間のトライアンドエラーとこれから
chao2suke
0
2.3k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.7k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.7k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
900
奥深きAPLの世界
chao2suke
0
120
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.7k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
2.8k
Other Decks in Technology
See All in Technology
CursorによるPMO業務の代替 / Automating PMO Tasks with Cursor
motoyoshi_kakaku
1
450
使いたいMCPサーバーはWeb APIをラップして自分で作る #QiitaBash
bengo4com
0
970
Javaで作る RAGを活用した Q&Aアプリケーション
recruitengineers
PRO
1
130
KubeCon + CloudNativeCon Japan 2025 Recap
ren510dev
1
190
怖くない!はじめてのClaude Code
shinya337
0
170
Delegating the chores of authenticating users to Keycloak
ahus1
0
130
Kotlin Coroutine Mechanisms: A Surprisingly Deep Rabbithole
amanda_hinchman
2
100
SpringBoot x TestContainerで実現するポータブル自動結合テスト
demaecan
0
110
Windows 11 で AWS Documentation MCP Server 接続実践/practical-aws-documentation-mcp-server-connection-on-windows-11
emiki
0
1k
JEDAI Databricks Free Editionもくもく会
taka_aki
1
110
KubeCon + CloudNativeCon Japan 2025 Recap by CA
ponkio_o
PRO
0
160
Lambda Web Adapterについて自分なりに理解してみた
smt7174
5
130
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
670
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Navigating Team Friction
lara
187
15k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
Unsuck your backbone
ammeep
671
58k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
BBQ
matthewcrist
89
9.7k
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