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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
chao2suke
October 19, 2018
Technology
1
110
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.4k
結局普通のエンジニアが今SageMaker使うと何ができるのかわかるLT
chao2suke
0
1.7k
機械学習の知識ゼロでも動かせるAIツールキットの世界
chao2suke
0
1.8k
「今」のAI技術と「3年後」のAI技術のご紹介
chao2suke
0
1.1k
Alexaに詳しい人は普段Alexaをどう扱っているか
chao2suke
0
950
奥深きAPLの世界
chao2suke
0
130
Alexaスキル & レジレスCafeにおけるStripe活用の取り組み
chao2suke
0
2k
Alexa x 機械学習でスキルをよりリッチにする方法
chao2suke
0
1.7k
#AAJUG vol.2 APL ハンズオン
chao2suke
0
3k
Other Decks in Technology
See All in Technology
EMからICへ、二周目人材としてAI全振りのプロダクト開発で見つけた武器
yug1224
5
490
OpenClawで回す組織運営
jacopen
3
650
自動テストが巻き起こした開発プロセス・チームの変化 / Impact of Automated Testing on Development Cycles and Team Dynamics
codmoninc
3
1.3k
わたしがセキュアにAWSを使えるわけないじゃん、ムリムリ!(※ムリじゃなかった!?)
cmusudakeisuke
1
450
8万デプロイ
iwamot
PRO
2
200
DX Improvement at Scale
ntk1000
3
410
楽しく学ぼう!コミュニティ入門 AWSと人が つむいできたストーリー
hiroramos4
PRO
1
170
[AEON TECH HUB #24] お客様の長期的興味の理解に向けて
alpicola
0
120
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
8
7.1k
Evolution of Claude Code & How to use features
oikon48
1
540
Datadog の RBAC のすべて
nulabinc
PRO
3
360
Fundraising Gala’s in 2026 What’s Changing & What Still Works
auctria
PRO
0
100
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
320
Skip the Path - Find Your Career Trail
mkilby
1
73
Deep Space Network (abreviated)
tonyrice
0
86
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
240
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.1k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
210
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Prompt Engineering for Job Search
mfonobong
0
180
The SEO Collaboration Effect
kristinabergwall1
0
380
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